forked from Roll20/roll20-api-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Emas.js
166 lines (153 loc) · 4.89 KB
/
Emas.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// GIST: https://gist.github.com/shdwjk/42f34ecfd167ec56c9f7
var Emas = Emas || (function() {
'use strict';
var version = 0.5,
ch = function (c) {
var entities = {
'<' : 'lt',
'>' : 'gt',
"'" : '#39',
'@' : '#64',
'{' : '#123',
'|' : '#124',
'}' : '#125',
'[' : '#91',
']' : '#93',
'"' : 'quot',
'-' : 'mdash',
' ' : 'nbsp'
};
if(_.has(entities,c) ){
return ('&'+entities[c]+';');
}
return '';
},
showHelp = function(who) {
sendChat('',
'/w '+who+' '
+'<div style="border: 1px solid black; background-color: white; padding: 3px 3px;">'
+'<div style="font-weight: bold; border-bottom: 1px solid black;font-size: 130%;">'
+'Emas v'+version
+'</div>'
+'<div style="padding-left:10px;margin-bottom:3px;">'
+'<p>Emas provides the <b>!emas</b> command, which looks like /emas but '
+'works for everyone, as well as the <b>!as</b> command, which looks like '
+'/as but works for everyone. <b>!w</b>, <b>!r</b>, <b>!gr</b> as '
+'well.</p>'
+'</div>'
+'<b>Commands</b>'
+'<div style="padding-left:10px;">'
+'<b><span style="font-family: serif;">!emas '+ch('<')+'message'+ch('>')+'</span></b>'
+'<div style="padding-left: 10px;padding-right:20px">'
+'<p>Sends a message in the same manner as <i>/emas</i> does for GMs.</p>'
+'<ul>'
+'<li style="border-top: 1px solid #ccc;border-bottom: 1px solid #ccc;">'
+'<b><span style="font-family: serif;">'+ch('<')+'message'+ch('>')+'</span></b> '+ch('-')+' The message to output as part of the emote.'
+'</li> '
+'</ul>'
+'</div>'
+'</div>'
+'<div style="padding-left:10px;">'
+'<b><span style="font-family: serif;">!as '+ch('<')+'message'+ch('>')+'</span></b>'
+'<div style="padding-left: 10px;padding-right:20px">'
+'<p>Sends a message in the same manner as <i>/as</i> does for GMs.</p>'
+'<ul>'
+'<li style="border-top: 1px solid #ccc;border-bottom: 1px solid #ccc;">'
+'<b><span style="font-family: serif;">'+ch('<')+'message'+ch('>')+'</span></b> '+ch('-')+' The message to output as part of the emote.'
+'</li> '
+'</ul>'
+'</div>'
+'</div>'
+'<div style="padding-left:10px;">'
+'<b><span style="font-family: serif;">!w '+ch('<')+'message'+ch('>')+'</span></b>'
+'<div style="padding-left: 10px;padding-right:20px">'
+'<p>Sends a message in the same manner as <i>/w</i> does.</p>'
+'<ul>'
+'<li style="border-top: 1px solid #ccc;border-bottom: 1px solid #ccc;">'
+'<b><span style="font-family: serif;">'+ch('<')+'message'+ch('>')+'</span></b> '+ch('-')+' The message to output as part of the emote.'
+'</li> '
+'</ul>'
+'</div>'
+'</div>'
+'<div style="padding-left:10px;">'
+'<b><span style="font-family: serif;">!r '+ch('<')+'message'+ch('>')+'</span></b>'
+'<div style="padding-left: 10px;padding-right:20px">'
+'<p>Sends a message in the same manner as <i>/r</i> does.</p>'
+'<ul>'
+'<li style="border-top: 1px solid #ccc;border-bottom: 1px solid #ccc;">'
+'<b><span style="font-family: serif;">'+ch('<')+'message'+ch('>')+'</span></b> '+ch('-')+' The message to output as part of the emote.'
+'</li> '
+'</ul>'
+'</div>'
+'</div>'
+'<div style="padding-left:10px;">'
+'<b><span style="font-family: serif;">!gr '+ch('<')+'message'+ch('>')+'</span></b>'
+'<div style="padding-left: 10px;padding-right:20px">'
+'<p>Sends a message in the same manner as <i>/gr</i> does.</p>'
+'<ul>'
+'<li style="border-top: 1px solid #ccc;border-bottom: 1px solid #ccc;">'
+'<b><span style="font-family: serif;">'+ch('<')+'message'+ch('>')+'</span></b> '+ch('-')+' The message to output as part of the emote.'
+'</li> '
+'</ul>'
+'</div>'
+'</div>'
+'</div>'
);
},
handleInput = function(msg) {
var args, who;
if (msg.type !== "api") {
return;
}
args = msg.content.split(/\s+/);
who=getObj('player',msg.playerid).get('_displayname').split(' ')[0];
switch(args[0]) {
case '!emas':
if(1 === args.length) {
showHelp(who);
} else {
sendChat('','/emas '+_.rest(args).join(' '));
}
break;
case '!as':
if(1 === args.length) {
showHelp(who);
} else {
sendChat('','/as '+_.rest(args).join(' '));
}
break;
case '!w':
if(1 === args.length) {
showHelp(who);
} else {
sendChat(msg.who,'/w '+who+' '+_.rest(args,2).join(' '));
sendChat(msg.who,'/w '+_.rest(args).join(' '));
}
break;
case '!r':
if(1 === args.length) {
showHelp(who);
} else {
sendChat('','/r '+_.rest(args).join(' '));
}
break;
case '!gr':
if(1 === args.length) {
showHelp(who);
} else {
sendChat('','/gr '+_.rest(args).join(' '));
}
break;
}
},
registerEventHandlers = function() {
on('chat:message', handleInput);
};
return {
RegisterEventHandlers: registerEventHandlers
};
}());
on("ready",function(){
'use strict';
Emas.RegisterEventHandlers();
});