From 5eb5b18743971f7ee31746fdad2880186da9e903 Mon Sep 17 00:00:00 2001 From: pk910 Date: Wed, 30 Nov 2011 00:25:42 +0100 Subject: [PATCH] added auto-rejoin on kick to bot_NeonSpam.c --- src/bot_NeonSpam.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/bot_NeonSpam.c b/src/bot_NeonSpam.c index 33e9cbf..056a82e 100644 --- a/src/bot_NeonSpam.c +++ b/src/bot_NeonSpam.c @@ -89,6 +89,31 @@ static struct NeonSpamJoinNode *getNeonSpamJoinNode(struct ChanUser *chanuser); #include "event_neonspam_join.c" #include "event_neonspam_chanmsg.c" +static void neonspam_event_kick(struct UserNode *user, struct ChanUser *target, char *reason) { + struct ChanNode *chan = target->chan; + if(isBot(target->user)) { + struct ClientSocket *client = getChannelBot(chan, 0); + struct ClientSocket *bot = client; + for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) { + if(client->user == target->user) { + break; + } + } + if(!client) return; + if(bot && bot != client && (isModeSet(chan->modes, 'i') || isModeSet(chan->modes, 'a') || isModeSet(chan->modes, 'l'))) { + struct ChanUser *chanuser = getChanUser(bot->user, chan); + if(chanuser && chanuser->flags & CHANUSERFLAG_OPPED) + putsock(bot, "INVITE %s %s", target->user->nick, chan->name); + } + char *key = ""; + if(isModeSet(chan->modes, 'k')) { + key = getModeValue(chan->modes, 'k'); + } + putsock(client, "JOIN %s %s", chan->name, key); + return; + } +} + static void neonspam_bot_ready(struct ClientSocket *client) { MYSQL_RES *res; MYSQL_ROW row; @@ -295,6 +320,7 @@ void init_NeonSpam() { bind_join(neonspam_event_join); bind_chanmsg(neonspam_event_chanmsg); bind_privctcp(general_event_privctcp); + bind_kick(neonspam_event_kick); set_trigger_callback(BOTID, neonspam_trigger_callback); -- 2.20.1