automatically try to rejoin channel when get kicked
authorpk910 <philipp@zoelle1.de>
Tue, 29 Nov 2011 23:05:46 +0000 (00:05 +0100)
committerpk910 <philipp@zoelle1.de>
Tue, 29 Nov 2011 23:20:22 +0000 (00:20 +0100)
src/event_neonserv_kick.c

index bbe001a94a28a18b168ee447938ecfcc99ed123a..cfbb6bcdd934efd8e808ae8a4a033e6c3c1ea297 100644 (file)
@@ -28,7 +28,29 @@ static void neonserv_event_kick_async2(struct ClientSocket *client, struct UserN
 
 static void neonserv_event_kick(struct UserNode *user, struct ChanUser *target, char *reason) {
     struct ChanNode *chan = target->chan;
-    struct ClientSocket *client = getBotForChannel(chan);
+    struct ClientSocket *client;
+    if(isBot(target->user)) {
+        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;
+    }
+    client = getBotForChannel(chan);
     if(!client) return; //we can't "see" this event
     if(isNetworkService(user)) return; 
     loadChannelSettings(chan);