-static void neonhelp_event_quit(struct UserNode *target, char *reason) {
- struct ClientSocket *client;
- int userHasRequest;
- for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
- if(client->botid == BOTID) {
- userHasRequest = 0;
- struct NeonHelpNode *helpnode, *prev_helpnode = NULL;
- if(client->flags & SOCKET_HAVE_HELPNODE) {
- for(helpnode = client->botclass_helpnode; helpnode; helpnode = helpnode->next) {
- if(helpnode->user == target) {
- userHasRequest = 1;
- break;
- } else
- prev_helpnode = helpnode;
- }
- }
- if(!userHasRequest) continue;
- //free the user's support request
- if(prev_helpnode)
- prev_helpnode->next = helpnode->next;
- else
- client->botclass_helpnode = helpnode->next;
- destroy_support_request(client, helpnode, 0);
- }
+static void neonhelp_event_invite(struct ClientSocket *client, struct UserNode *user, char *channel) {
+ if(client->botid != BOTID)
+ return;
+ MYSQL_RES *res;
+ MYSQL_ROW row;
+ 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);
+ res = mysql_use();
+ if ((row = mysql_fetch_row(res)) == NULL) {
+ reply(client, user, "NS_INVITE_FAIL", channel, client->user->nick);
+ return;
+ }
+ if(!strcmp(row[2], "1")) {
+ reply(client, user, "MODCMD_CHAN_SUSPENDED");
+ return;
+ }
+ int botid = atoi(row[0]);
+ struct ClientSocket *bot;
+ for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
+ if(bot->clientid == botid)
+ break;
+ }
+ if(bot) {
+ struct ChanNode *chan = getChanByName(channel);
+ if(chan && isUserOnChan(bot->user, chan)) {
+ reply(client, user, "NS_INVITE_ON_CHAN", bot->user->nick, chan->name);
+ } else
+ putsock(bot, "JOIN %s", channel);