1 /* bot_NeonHelp.c - NeonServ v5.4
2 * Copyright (C) 2011-2012 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "../module.h"
20 #include "bot_NeonHelp.h"
21 #include "../../modcmd.h"
22 #include "cmd_neonhelp.h"
23 #include "../../lang.h"
24 #include "../../mysqlConn.h"
25 #include "../../ClientSocket.h"
26 #include "../../UserNode.h"
27 #include "../../ChanNode.h"
28 #include "../../ChanUser.h"
29 #include "../../IRCEvents.h"
30 #include "../../IRCParser.h"
31 #include "../../bots.h"
32 #include "../../DBHelper.h"
33 #include "../../WHOHandler.h"
35 #define BOTID NEONHELP_BOTID
36 #define BOTALIAS "NeonHelp"
38 static const struct default_language_entry msgtab[] = {
39 {"NH_NOT_ON_CHAN_1", "You cannot open this request as you are not in %s."}, /* {ARGS: "#test"} */
40 {"NH_NOT_ON_CHAN_2", "You cannot open this request as you are not in %s or %s."}, /* {ARGS: "test", "#test-support"} */
41 {"NH_REQUEST_RECORDED", "Your message has been recorded and assigned request ID#%d A helper should contact you shortly."}, /* {ARGS: 5} */
42 {"NH_REQUEST_OTHERS_0", "There are no other unhandled requests."},
43 {"NH_REQUEST_OTHERS_1", "There is 1 other unhandled request."},
44 {"NH_REQUEST_OTHERS_2", "There are %d other unhandled requests."}, /* {ARGS: 1337} */
45 {"NH_REQUEST_FOOTER_1", "Everything you tell me until you are helped (or you leave %1$s) will be recorded. If you part %1$s, your request will be lost."}, /* {ARGS: "#test"} */
46 {"NH_REQUEST_FOOTER_2", "Everything you tell me until you are helped (or you leave %1$s or %2$s) will be recorded. If you part %1$s or %2$s, your request will be lost."}, /* {ARGS: "#test", "#test-support"} */
47 {"NH_NEW_REQUEST", "New request #%d by %s: %s"}, /* {ARGS: 5, "pk910", "Help, I've fallen and I can't get up!"} */
48 {"NH_NEXT_NONE", "No more requests."},
49 {"NH_NEXT_NOT_FOUND", "No request found."},
50 {"NH_NEXT_HEADER", "$bNext request: #%d %s$b"}, /* {ARGS: 5, "pk910"} */
51 {"NH_NEXT_HELPER", "Your helper for request ID#%d is %s (Current nick: %s)."}, /* {ARGS: 5, "pk910", "Skynet"} */
52 {"NH_NEXT_JOIN", "Please /join %s now."}, /* {ARGS: "#test-support"} */
53 {"NH_DELETED", "Your request ID#%d has been deleted."}, /* {ARGS: 5} */
54 {"NH_DELETED_STAFF", "Request deleted: #%d (%s)"}, /* {ARGS: 5, "pk910"} */
55 {"NH_REMIND_OPEN_REQUESTS_1", "There is %d unhandled request!"}, /* {ARGS: 1} */
56 {"NH_REMIND_OPEN_REQUESTS_2", "There are %d unhandled requests!"}, /* {ARGS: 4} */
57 {"NH_REQUESTS_HEADER_ID", "ID"},
58 {"NH_REQUESTS_HEADER_STATUS", "State"},
59 {"NH_REQUESTS_HEADER_NICK", "Nick"},
60 {"NH_REQUESTS_HEADER_TIME", "Time"},
61 {"NH_REQUESTS_HEADER_REQUEST", "Question"},
62 {"NH_REQUESTS_STATE_ACTIVE", "active"},
63 {"NH_REQUESTS_STATE_PENDING", "pending"},
64 {"NH_REQUESTS_STATE_ERROR", "ERROR"},
65 {"NH_STATS_HEADER_USER", "User"},
66 {"NH_STATS_HEADER_LAST_24H", "last 24h"},
67 {"NH_STATS_HEADER_LAST_7DAY", "last 7d"},
68 {"NH_STATS_HEADER_LAST_30DAY", "last 30d"},
72 static void neonhelp_bot_ready(struct ClientSocket *client) {
73 if(client->botid != BOTID)
78 printf_mysql_query("SELECT `automodes`, `oper_user`, `oper_pass` FROM `bots` WHERE `id` = '%d'", client->clientid);
80 if ((row = mysql_fetch_row(res)) != NULL) {
81 if(row[1] && row[2]) {
82 putsock(client, "OPER %s %s", row[1], row[2]);
84 putsock(client, "MODE %s +%s", client->user->nick, row[0]);
87 printf_mysql_query("SELECT `channel_name`, `channel_key` FROM `bot_channels` LEFT JOIN `channels` ON `chanid` = `channel_id` WHERE `botid` = '%d' AND `suspended` = '0'", client->clientid);
90 while ((row = mysql_fetch_row(res)) != NULL) {
91 putsock(client, "JOIN %s %s", row[0], row[1]);
95 static void neonhelp_trigger_callback(int clientid, struct ChanNode *chan, char *trigger) {
98 loadChannelSettings(chan);
99 if(!(chan->flags & CHANFLAG_CHAN_REGISTERED)) {
100 strcpy(trigger, "!");
103 printf_mysql_query("SELECT `trigger`, `defaulttrigger` FROM `bot_channels` LEFT JOIN `bots` ON `botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '%d'", chan->channel_id, BOTID);
105 if(!(row = mysql_fetch_row(res))) {
106 strcpy(trigger, "!");
109 if(row[0] && *row[0])
110 strcpy(trigger, row[0]);
112 strcpy(trigger, ((row[1] && *row[1]) ? row[1] : "!"));
115 static void start_bots(int type) {
116 struct ClientSocket *client;
117 MYSQL_RES *res, *res2;
120 if(type == MODSTATE_STARTSTOP) {
121 printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID);
124 while ((row = mysql_fetch_row(res)) != NULL) {
125 client = create_socket(row[3], atoi(row[4]), row[10], row[5], row[0], row[1], row[2]);
126 client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0);
127 client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0);
128 client->flags |= (strcmp(row[9], "0") ? SOCKET_FLAG_SSL : 0);
129 client->flags |= SOCKET_FLAG_SILENT;
130 client->flags |= SOCKET_FLAG_REQUEST_INVITE;
131 client->botid = BOTID;
132 client->clientid = atoi(row[7]);
133 connect_socket(client);
134 //close old, still opened requests
135 printf_mysql_query("UPDATE `helpserv_requests` SET `status` = '2' WHERE `botid` = '%d'", client->clientid);
139 printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access`, `flags` FROM `bot_binds` WHERE `botclass` = '%d'", BOTID);
141 while ((row = mysql_fetch_row(res2)) != NULL) {
142 if(bind_cmd_to_command(BOTID, row[0], row[1])) {
143 if(row[2] && strcmp(row[2], "")) {
144 bind_set_parameters(BOTID, row[0], row[2]);
147 bind_set_global_access(BOTID, row[0], atoi(row[3]));
150 bind_set_channel_access(BOTID, row[0], row[4]);
152 if(strcmp(row[5], "0"))
153 bind_set_bind_flags(BOTID, row[0], atoi(row[5]));
156 bind_unbound_required_functions(BOTID);
159 static void neonhelp_event_privmsg_async(struct ClientSocket *client, struct UserNode *user, struct UserNode *target, char *message);
160 static USERAUTH_CALLBACK(neonhelp_event_privmsg_nick_lookup);
161 struct neonhelp_event_privmsg_cache {
162 struct ClientSocket *client;
163 struct UserNode *user, *target;
167 static void neonhelp_event_privmsg(struct UserNode *user, struct UserNode *target, char *message) {
168 struct ClientSocket *client;
169 for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
170 if(client->user == target) {
171 if(client->botid != BOTID) return;
175 if(!client) return; //we got the message but we have no client that could receive it???
176 if(user->flags & USERFLAG_ISAUTHED) {
177 neonhelp_event_privmsg_async(client, user, target, message);
179 struct neonhelp_event_privmsg_cache *cache = malloc(sizeof(*cache));
181 cache->client = client;
183 cache->target = target;
184 cache->message = strdup(message);
185 get_userauth(user, module_id, neonhelp_event_privmsg_nick_lookup, cache);
189 static USERAUTH_CALLBACK(neonhelp_event_privmsg_nick_lookup) {
190 struct neonhelp_event_privmsg_cache *cache = data;
191 neonhelp_event_privmsg_async(cache->client, cache->user, cache->target, cache->message);
192 free(cache->message);
196 static TIMEQ_CALLBACK(neonhelp_remind_open_requests);
198 static void neonhelp_event_privmsg_async(struct ClientSocket *client, struct UserNode *user, struct UserNode *target, char *message) {
201 printf_mysql_query("SELECT `helpserv_support`, `helpserv_public`, `helpserv_intern`, `helpserv_intern_announce` FROM `helpserv_settings` WHERE `helpserv_botid` = '%d'", client->clientid);
203 if (!(row = mysql_fetch_row(res))) return;
204 //check if the user is a supporter (access in the support channel)
205 if((user->flags & USERFLAG_ISAUTHED)) {
208 if(user->flags & USERFLAG_HAS_USERID)
209 userid = user->user_id;
211 printf_mysql_query("SELECT `user_id` FROM `users` WHERE `user_user` = '%s'", escape_string(user->auth));
213 if ((row2 = mysql_fetch_row(res)) != NULL) {
214 userid = atoi(row2[0]);
215 user->user_id = userid;
216 user->flags |= USERFLAG_HAS_USERID;
220 printf_mysql_query("SELECT `chanuser_access`, `chanuser_flags` FROM `chanusers` LEFT JOIN `channels` ON `chanuser_cid` = `channel_id` WHERE `chanuser_uid` = '%d' AND `channel_name` = '%s'", userid, escape_string(row[0]));
222 if ((row2 = mysql_fetch_row(res)) != NULL) {
223 int cflags = atoi(row2[1]);
224 if(!(cflags & DB_CHANUSER_SUSPENDED))
225 caccess = atoi(row2[0]);
227 if(caccess) return; //ignore messages from supporters
229 //check if the user is in one of the bot's channels
230 struct ChanUser *chanuser;
231 struct ChanNode *chan;
232 for(chanuser = getUserChannels(target, NULL); chanuser; chanuser = getUserChannels(target, chanuser)) {
233 chan = chanuser->chan;
234 if((!stricmp(chan->name, row[0]) || (row[1] && !stricmp(chan->name, row[1]))) && isUserOnChan(user, chan))
239 reply(client, user, "NH_NOT_ON_CHAN_2", row[0], row[1]);
241 reply(client, user, "NH_NOT_ON_CHAN_1", row[0]);
244 //check if there is already a support request
246 if(client->flags & SOCKET_HAVE_HELPNODE) {
247 struct NeonHelpNode *helpnode;
248 for(helpnode = client->botclass_helpnode; helpnode; helpnode = helpnode->next) {
249 if(helpnode->user == user) {
250 //simply append the message to the database
251 printf_mysql_query("SELECT `text` FROM `helpserv_requests` WHERE `id` = %d", helpnode->suppid);
253 if ((row2 = mysql_fetch_row(res)) != NULL) {
254 char *old_msg = escape_string(row2[0]);
255 char *new_msg = escape_string(message);
256 printf_long_mysql_query(1024 + strlen(old_msg) + strlen(new_msg), "UPDATE `helpserv_requests` SET `text` = '%s\n%s' WHERE `id` = %d", old_msg, new_msg, helpnode->suppid);
264 struct NeonHelpNode *helpnode = malloc(sizeof(*helpnode));
265 if(!helpnode) return;
266 helpnode->user = user;
267 helpnode->logchan = getChanByName(row[0]);
268 helpnode->status = 0;
269 helpnode->announce = (row[2] && strcmp(row[3], "0") ? 1 : 0);
270 if(helpnode->announce) {
272 sprintf(nameBuf, "neonhelp_%d", client->clientid);
273 if(!timeq_name_exists(nameBuf)) {
274 int *cidptr = malloc(sizeof(int));
275 *cidptr = client->clientid;
276 timeq_add_name(nameBuf, 300, module_id, neonhelp_remind_open_requests, cidptr);
279 printf_mysql_query("INSERT INTO `helpserv_requests` (`botid`, `host`, `hand`, `nick`, `status`, `supporter`, `time`, `text`) VALUES ('%d', '%s@%s', '%s', '%s', '0', '-1', UNIX_TIMESTAMP(), '%s')", client->clientid, escape_string(user->ident), escape_string(user->host), ((user->flags & USERFLAG_ISAUTHED) ? escape_string(user->auth) : "*"), escape_string(user->nick), escape_string(message));
280 helpnode->suppid = (int) mysql_insert_id(get_mysql_conn());
281 helpnode->log = NULL;
282 helpnode->next = ((client->flags & SOCKET_HAVE_HELPNODE) ? client->botclass_helpnode : NULL);
283 client->botclass_helpnode = helpnode;
284 client->flags |= SOCKET_HAVE_HELPNODE;
285 //build the user reply...
286 char user_reply[MAXLEN];
287 int user_reply_pos = 0;
288 char reply_buff[MAXLEN];
289 //1st part: NH_REQUEST_RECORDED
290 strcpy(user_reply + user_reply_pos, build_language_string(user, reply_buff, "NH_REQUEST_RECORDED", helpnode->suppid));
291 user_reply_pos += strlen(reply_buff);
292 //2nd part: NH_REQUEST_OTHERS_0 / NH_REQUEST_OTHERS_1 / NH_REQUEST_OTHERS_2
293 user_reply[user_reply_pos++] = ' ';
295 strcpy(user_reply + user_reply_pos, build_language_string(user, reply_buff, (others ? "NH_REQUEST_OTHERS_1" : "NH_REQUEST_OTHERS_0")));
297 strcpy(user_reply + user_reply_pos, build_language_string(user, reply_buff, "NH_REQUEST_OTHERS_2", others));
298 user_reply_pos += strlen(reply_buff);
299 //3th part: NH_REQUEST_FOOTER_1 / NH_REQUEST_FOOTER_2
300 user_reply[user_reply_pos++] = ' ';
302 strcpy(user_reply + user_reply_pos, build_language_string(user, reply_buff, "NH_REQUEST_FOOTER_2", row[0], row[1]));
304 strcpy(user_reply + user_reply_pos, build_language_string(user, reply_buff, "NH_REQUEST_FOOTER_1", row[0]));
305 user_reply_pos += strlen(reply_buff);
306 reply(client, user, "%s", user_reply);
307 //sent a message to the internal channel / onotice to supp channel
308 build_language_string(user, reply_buff, "NH_NEW_REQUEST", helpnode->suppid, user->nick, message);
310 putsock(client, "PRIVMSG %s :%s", row[2], reply_buff);
312 putsock(client, "NOTICE @%s :%s", row[0], reply_buff);
316 static TIMEQ_CALLBACK(neonhelp_remind_open_requests) {
317 int clientid = *((int*)data);
320 printf_mysql_query("SELECT `helpserv_support`, `helpserv_public`, `helpserv_intern`, `helpserv_intern_announce` FROM `helpserv_settings` WHERE `helpserv_botid` = '%d'", clientid);
322 if (!(row = mysql_fetch_row(res)) || !row[2]) {
326 struct ClientSocket *client;
327 for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
328 if(client->clientid == clientid)
335 //count open requests
337 struct NeonHelpNode *helpnode;
338 if(client->flags & SOCKET_HAVE_HELPNODE) {
339 for(helpnode = client->botclass_helpnode; helpnode; helpnode = helpnode->next) {
340 if(helpnode->status == 0) {
347 sprintf(nameBuf, "neonhelp_%d", client->clientid);
348 if(!timeq_name_exists(nameBuf)) {
349 timeq_add_name(nameBuf, 300, module_id, neonhelp_remind_open_requests, data);
351 char replybuf[MAXLEN];
352 build_language_string(NULL, replybuf, (requests == 1 ? "NH_REMIND_OPEN_REQUESTS_1" : "NH_REMIND_OPEN_REQUESTS_2"), requests);
353 putsock(client, "PRIVMSG %s :%s", row[2], replybuf);
358 static void neonhelp_event_chanmsg(struct UserNode *user, struct ChanNode *chan, char *message) {
359 char logline[MAXLEN];
360 sprintf(logline, "<%s> %s", user->nick, message);
361 struct ClientSocket *client;
362 for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
363 if(client->botid == BOTID) {
364 struct NeonHelpNode *helpnode;
365 if(client->flags & SOCKET_HAVE_HELPNODE) {
366 for(helpnode = client->botclass_helpnode; helpnode; helpnode = helpnode->next) {
367 if(helpnode->logchan == chan && helpnode->status == 1) {
369 helpnode->log = calloc(LOGBUFFERLINES, sizeof(char*));
370 if(!helpnode->log) return;
373 for(i = 0; i < LOGBUFFERLINES; i++) {
374 if(!helpnode->log[i]) {
375 helpnode->log[i] = strdup(logline);
379 if(i == LOGBUFFERLINES) {
380 //write buffer to database
381 char logbuff[MAXLEN * LOGBUFFERLINES];
383 for(i = 0; i < LOGBUFFERLINES; i++) {
384 len += sprintf(logbuff + len, "%s\n", helpnode->log[i]);
385 free(helpnode->log[i]);
386 helpnode->log[i] = NULL;
388 printf_long_mysql_query(1024 + len, "UPDATE `helpserv_requests` SET `log` = CONCAT(`log`, '%s') WHERE `id` = %d", escape_string(logbuff), helpnode->suppid);
398 static void destroy_support_request(struct ClientSocket *client, struct NeonHelpNode *helpnode, int do_reply) {
399 //write buffer to database
400 char logbuff[MAXLEN * LOGBUFFERLINES];
404 for(i = 0; i < LOGBUFFERLINES; i++) {
405 if(!helpnode->log[i]) break;
406 len += sprintf(logbuff + len, "%s\n", helpnode->log[i]);
407 free(helpnode->log[i]);
408 helpnode->log[i] = NULL;
413 printf_long_mysql_query(1024 + len, "UPDATE `helpserv_requests` SET `status`='2', `log` = CONCAT(`log`, '%s') WHERE `id` = %d", escape_string(logbuff), helpnode->suppid);
415 reply(client, helpnode->user, "NH_DELETED", helpnode->suppid);
420 static void neonhelp_event_kick(struct UserNode *user, struct ChanUser *target, char *reason) {
421 struct ClientSocket *client;
424 struct ChanNode *support, *public;
426 for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
427 if(client->botid == BOTID && isUserOnChan(client->user, target->chan)) {
429 struct NeonHelpNode *helpnode, *prev_helpnode = NULL;
430 if(client->flags & SOCKET_HAVE_HELPNODE) {
431 for(helpnode = client->botclass_helpnode; helpnode; helpnode = helpnode->next) {
432 if(helpnode->user == target->user) {
436 prev_helpnode = helpnode;
439 if(!userHasRequest) continue;
440 printf_mysql_query("SELECT `helpserv_support`, `helpserv_public`, `helpserv_intern` FROM `helpserv_settings` WHERE `helpserv_botid` = '%d'", client->clientid);
442 if (!(row = mysql_fetch_row(res))) continue;
443 support = getChanByName(row[0]);
444 public = (row[1] ? getChanByName(row[1]) : NULL);
445 if(target->chan == support || !((support && isUserOnChan(target->user, support)) || (public && isUserOnChan(target->user, public)))) {
446 //free the user's support request
448 prev_helpnode->next = helpnode->next;
450 client->botclass_helpnode = helpnode->next;
451 destroy_support_request(client, helpnode, 1);
457 static void neonhelp_event_part(struct ChanUser *target, char *reason) {
458 struct ClientSocket *client;
461 struct ChanNode *support, *public;
463 for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
464 if(client->botid == BOTID && isUserOnChan(client->user, target->chan)) {
466 struct NeonHelpNode *helpnode, *prev_helpnode = NULL;
467 if(client->flags & SOCKET_HAVE_HELPNODE) {
468 for(helpnode = client->botclass_helpnode; helpnode; helpnode = helpnode->next) {
469 if(helpnode->user == target->user) {
473 prev_helpnode = helpnode;
476 if(!userHasRequest) continue;
477 printf_mysql_query("SELECT `helpserv_support`, `helpserv_public`, `helpserv_intern` FROM `helpserv_settings` WHERE `helpserv_botid` = '%d'", client->clientid);
479 if (!(row = mysql_fetch_row(res))) continue;
480 support = getChanByName(row[0]);
481 public = (row[1] ? getChanByName(row[1]) : NULL);
482 if(target->chan == support || !((support && isUserOnChan(target->user, support)) || (public && isUserOnChan(target->user, public)))) {
483 //free the user's support request
485 prev_helpnode->next = helpnode->next;
487 client->botclass_helpnode = helpnode->next;
488 destroy_support_request(client, helpnode, 1);
494 static void neonhelp_event_quit(struct UserNode *target, char *reason) {
495 struct ClientSocket *client;
497 for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
498 if(client->botid == BOTID) {
500 struct NeonHelpNode *helpnode, *prev_helpnode = NULL;
501 if(client->flags & SOCKET_HAVE_HELPNODE) {
502 for(helpnode = client->botclass_helpnode; helpnode; helpnode = helpnode->next) {
503 if(helpnode->user == target) {
507 prev_helpnode = helpnode;
510 if(!userHasRequest) continue;
511 //free the user's support request
513 prev_helpnode->next = helpnode->next;
515 client->botclass_helpnode = helpnode->next;
516 destroy_support_request(client, helpnode, 0);
521 static void neonhelp_event_invite(struct ClientSocket *client, struct UserNode *user, char *channel) {
522 if(client->botid != BOTID)
526 printf_mysql_query("SELECT `botid`, `bot_channels`.`id`, `suspended` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` LEFT JOIN `channels` ON `chanid` = `channel_id` WHERE `channel_name` = '%s' AND `botclass` = '%d'", escape_string(channel), client->botid);
528 if ((row = mysql_fetch_row(res)) == NULL) {
529 reply(client, user, "NS_INVITE_FAIL", channel, client->user->nick);
532 if(!strcmp(row[2], "1")) {
533 reply(client, user, "MODCMD_CHAN_SUSPENDED");
536 int botid = atoi(row[0]);
537 struct ClientSocket *bot;
538 for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
539 if(bot->clientid == botid)
543 struct ChanNode *chan = getChanByName(channel);
544 if(chan && isUserOnChan(bot->user, chan)) {
545 reply(client, user, "NS_INVITE_ON_CHAN", bot->user->nick, chan->name);
547 putsock(bot, "JOIN %s", channel);
551 void init_NeonHelp(int type) {
552 set_bot_alias(BOTID, BOTALIAS);
555 if(type == MODSTATE_REBIND) return;
558 bind_bot_ready(neonhelp_bot_ready, module_id);
559 bind_privmsg(neonhelp_event_privmsg, module_id);
560 bind_chanmsg(neonhelp_event_chanmsg, module_id);
561 bind_part(neonhelp_event_part, module_id);
562 bind_kick(neonhelp_event_kick, module_id);
563 bind_quit(neonhelp_event_quit, module_id);
564 bind_invite(neonhelp_event_invite, module_id);
566 set_trigger_callback(BOTID, module_id, neonhelp_trigger_callback);
568 register_default_language_table(msgtab);
571 void loop_NeonHelp() {
575 void free_NeonHelp(int type) {
576 unbind_allcmd(BOTID);
577 if(type == MODSTATE_STARTSTOP) {
578 //disconnect all our bots
579 struct ClientSocket *client;
580 for(client = getBots(0, NULL); client; client = getBots(0, client)) {
581 if(client->botid == BOTID) {
582 unbind_botwise_allcmd(0, client->clientid);
583 close_socket(client);