Skip to content

Commit 26440cc

Browse files
committed
Added emoticons and logic
1 parent 3584aba commit 26440cc

20 files changed

+29
-8
lines changed

app/assets/images/emoticons/alone.jpg

3.28 KB
Loading
4.09 KB
Loading
29 KB
Loading
2.64 KB
Loading
3.03 KB
Loading
1.68 KB
Loading
2.87 KB
Loading

app/assets/images/emoticons/ilied.jpg

3.19 KB
Loading
7.2 KB
Loading
3.28 KB
Loading

app/assets/images/emoticons/okay.jpg

3.05 KB
Loading
4.22 KB
Loading
2.69 KB
Loading
4.52 KB
Loading
3.15 KB
Loading
3.8 KB
Loading
22.7 KB
Loading
21.8 KB
Loading
Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,45 @@
11
class Kandan.Plugins.Emoticons
22

33
@options:
4-
regex: /\([a-zA-Z]\)/g
4+
regex: /\([a-zA-Z]+\)/g
55
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" />
77
'''
88

99

1010
@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"
1230
}
1331

1432
@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)
1735
for match in _.unique(matches)
1836
emoticon = @emoticons[match]
19-
search = new Regex(match, 'g')
37+
needle = match.replace('(', '\\(').replace(')', '\\)')
38+
search = new RegExp(needle, 'g')
39+
console.log(search)
2040
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)
2344

2445
# Kandan.Plugins.register "Kandan.Plugins.Emoticons"

0 commit comments

Comments
 (0)