-
Notifications
You must be signed in to change notification settings - Fork 405
Plugin Colors
gabceb edited this page Feb 13, 2013
·
1 revision
Plugins to show hex and rgb colors
Add a hex (i.e: #fefefe
) or rgb (rgb(255,255,255)
) to a message
class Kandan.Plugins.HexColorEmbed
@options:
regex: /#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/g
template: _.template '''<span class="color-preview" style="background-color:<%= hex %>;"/>'''
@init: ()->
Kandan.Modifiers.register @options.regex, (message, state) =>
for hex in message.content.match(@options.regex)
replacement = @options.template({hex: hex}) + hex
message.content = message.content.replace(hex, replacement)
return Kandan.Helpers.Activities.buildFromMessageTemplate(message)
class Kandan.Plugins.RgbColorEmbed
@options:
regex: /rgb\((\d{1,3}),\s?(\d{1,3}),\s?(\d{1,3})\)/g
template: _.template '''<span class="color-preview" style="background-color:<%= rgb %>;"/>'''
@init: ()->
Kandan.Modifiers.register @options.regex, (message, state) =>
for rgb in message.content.match(@options.regex)
replacement = @options.template({rgb: rgb}) + rgb
message.content = message.content.replace(rgb, replacement)
return Kandan.Helpers.Activities.buildFromMessageTemplate(message)
Copyright © 2012-2013 - KandanApp