-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.js
More file actions
193 lines (167 loc) · 6.93 KB
/
plugin.js
File metadata and controls
193 lines (167 loc) · 6.93 KB
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
var format = require("util").format;
module.exports = {
init: function (client, imports) {
const requiresAdmin = imports.admin.requiresAdmin;
const requiresAdminHelp = "Requires admin privileges.";
return {
handlers: {
"!join": requiresAdmin(function (command) {
if (command.args[0]) {
client.notice(format("PluginControl", "Joining %s - requested by %s", command.channel, command.prefix));
client.join(command.args.join(" "));
}
}),
"!part": requiresAdmin(function (command) {
var channel;
if (command.args[0]) {
channel = command.args[0];
} else if (!command.isQuery) {
channel = command.channel;
} else {
return;
}
client.notice(format("PluginControl", "Parting %s - requested by %s", channel, command.prefix));
client.part(channel);
}),
"!quit": requiresAdmin(function (command) {
client.notice(format("PluginControl", "Quitting network - requested by %s", command.prefix));
var reason = command.args.join(" ");
if (/^\s*$/.test(reason)) {
reason = format("Requested by %s", command.nickname);
}
client.quit(reason);
}),
"!nick": requiresAdmin(function (command) {
if (command.args[0]) {
client.notice(format("PluginControl", "Changing nickname to %s - requested by %s", command.args[0], command.prefix));
client.nick(command.args[0]);
}
}),
"!say": requiresAdmin(function (command) {
var target = command.args[0];
if (target === "<reply>") {
target = command.channel;
} else if (target === "<query>") {
target = command.nickname;
}
return {
target: target,
message: command.args.slice(1).join(" ")
};
}),
"!act": requiresAdmin(function (command) {
var target = command.args[0];
if (target === "<reply>") {
target = command.channel;
} else if (target === "<query>") {
target = command.nickname;
}
return {
target: target,
intent: "act",
message: command.args.slice(1).join(" ")
};
}),
"!ctcp": requiresAdmin(function (command) {
var target = command.args[0];
if (target === "<reply>") {
target = command.channel;
} else if (target === "<query>") {
target = command.nickname;
}
return {
target: target,
intent: "ctcp",
message: [command.args[1], command.args.slice(2).join(" ")]
};
}),
"!notice": requiresAdmin(function (command) {
var target = command.args[0];
if (target === "<reply>") {
target = command.channel;
} else if (target === "<query>") {
target = command.nickname;
}
return {
target: target,
intent: "notice",
message: command.args.slice(1).join(" ")
};
}),
"!mode": requiresAdmin(function (command) {
if (command.args.length < 2) {
return {
query: true,
intent: "say",
message: "Error: mode command sent without enought parameters."
};
} else if (command.args.length === 2) {
client.rawf("MODE %s %s", command.args[0], command.args[1]);
} else {
client.rawf("MODE %s %s :%s", command.args[0], command.args[1], command.args.slice(2).join(" "));
}
})
},
help: {
"join": [
"{{!}}join <channel>",
" ",
"Join specifed channel.",
requiresAdminHelp
],
"part": [
"{{!}}part [<channel>]",
" ",
"Part specified channel.",
"If no channel is given, parts channel message was sent in.",
requiresAdminHelp
],
"quit": [
"{{!}}quit [<reason>]",
" ",
"Quit from network with given reason.",
requiresAdminHelp
],
"nick": [
"{{!}}nick <newnick>",
" ",
"Change bot\"s nickname to the new nickname.",
requiresAdminHelp
],
"say": [
"{{!}}say <target> <message>",
" ",
"Send a message to the target.",
requiresAdminHelp
],
"act": [
"{{!}}act <target> <action>",
" ",
"Perform the action to the target.",
requiresAdminHelp
],
"ctcp": [
"{{!}}ctcp <target> <ctcpType> <ctcpBody>",
" ",
"Send a CTCP of ctcpType to target with specified body.",
requiresAdminHelp
],
"notice": [
"{{!}}notice <target> <message>",
" ",
"Send a notice to the target.",
requiresAdminHelp
],
"mode": [
"{{!}}mode <target> <mode changes> <parameters>",
" ",
"Perform the mode changes.",
"Acts like /mode in your client.",
requiresAdminHelp
]
},
commands: ["join", "part", "quit", "nick", "say", "act", "ctcp", "notice", "mode"]
};
},
requires: ["admin"]
};