Another year is about to end... So we have to update these damn copyright information :P
[NeonServV5.git] / src / event_neonserv_kick.c
index d1c7c1bae30c8610a75fd7161f9c00cc2c2dfc3d..c9037d97c23352bed6b265e5311412dd5ac84edd 100644 (file)
@@ -1,5 +1,5 @@
-/* event_neonserv_kick.c - NeonServ v5.0
- * Copyright (C) 2011  Philipp Kreil (pk910)
+/* event_neonserv_kick.c - NeonServ v5.3
+ * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -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);