|
1 | 1 | class Kandan.Plugins.Emoticons
|
2 | 2 |
|
3 | 3 | @options:
|
4 |
| - regex: /\([a-zA-Z]\)/g |
| 4 | + regex: /\([a-zA-Z]+\)/g |
5 | 5 | template: _.template '''
|
6 |
| - <img class="emoticon-embed" src="/assets/<%= emoticon %>" height="20" width="20" /> |
| 6 | + <img class="emoticon-embed" src="/assets/emoticons/<%= emoticon %>" height="20" width="20" /> |
7 | 7 | '''
|
8 | 8 |
|
9 | 9 |
|
10 | 10 | @emoticons: {
|
11 |
| - "(yuno)": "y_u_no.jog" |
| 11 | + "(alone)" : "alone.jpg", |
| 12 | + "(awwyea)" : "awwyea.jpg", |
| 13 | + "(badass)" : "badass.png", |
| 14 | + "(bitchplease)" : "bitchplease.jpg", |
| 15 | + "(cereal)" : "cereal.jpg", |
| 16 | + "(challenge)" : "challenge.jpg", |
| 17 | + "(fuckyeah)" : "fuckyeah.jpg", |
| 18 | + "(ilied)" : "ilied.jpg", |
| 19 | + "(megusta)" : "megusta.jpg", |
| 20 | + "(notbad)" : "notbad.jpg", |
| 21 | + "(okay)" : "okay.jpg", |
| 22 | + "(omgface)" : "omgface.jpg", |
| 23 | + "(pokerface)" : "pokerface.jpg", |
| 24 | + "(rageguy)" : "rageguy.jpg", |
| 25 | + "(seriously)" : "seriously.jpg", |
| 26 | + "(sweetjesus)" : "sweetjesus.jpg", |
| 27 | + "(truestory)" : "truestory.jpg", |
| 28 | + "(youdontsay)" : "youdontsay.png", |
| 29 | + "(yuno)" : "yuno.jpg" |
12 | 30 | }
|
13 | 31 |
|
14 | 32 | @init: ()->
|
15 |
| - Kandan.Modifiers.register @regex, (message, state)=> |
16 |
| - matches = message.content.match(@regex) |
| 33 | + Kandan.Modifiers.register @options.regex, (message, state) => |
| 34 | + matches = message.content.match(@options.regex) |
17 | 35 | for match in _.unique(matches)
|
18 | 36 | emoticon = @emoticons[match]
|
19 |
| - search = new Regex(match, 'g') |
| 37 | + needle = match.replace('(', '\\(').replace(')', '\\)') |
| 38 | + search = new RegExp(needle, 'g') |
| 39 | + console.log(search) |
20 | 40 | replacement = @options.template({ emoticon: emoticon })
|
21 |
| - message.content.replace(search, replacement) if emoticon |
22 |
| - return Kandan.Helpers.Activities.build_from_base_template(message) |
| 41 | + message.content = message.content.replace(search, replacement) if emoticon |
| 42 | + console.log(message.content) |
| 43 | + return Kandan.Helpers.Activities.buildFromBaseTemplate(message) |
23 | 44 |
|
24 | 45 | # Kandan.Plugins.register "Kandan.Plugins.Emoticons"
|
0 commit comments