fixed path of mysql/errmsg.h (OSX compilation fix)
[NeonServV5.git] / src / bots.c
index 4875b5a5c987e97036c6084b704c2ddb58a58362..693901df990f4cca627a325c77f5cc425254e8fb 100644 (file)
@@ -1,4 +1,4 @@
-/* bots.c - NeonServ v5.5
+/* bots.c - NeonServ v5.6
  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
@@ -151,8 +151,8 @@ struct ClientSocket *getChannelBot(struct ChanNode *chan, int botid) {
     struct ChanUser *chanuser;
     for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
         if(botid && bot->botid != botid) continue;
-        if((chanuser = getChanUser(bot->user, chan)) != NULL) {
-            if((chanuser->flags & CHANUSERFLAG_OPPED)) {
+        if(!chan || (chanuser = getChanUser(bot->user, chan)) != NULL) {
+            if(chan && (chanuser->flags & CHANUSERFLAG_OPPED)) {
                 use_bot = bot;
                 if(bot->flags & SOCKET_FLAG_PREFERRED) break;
             } else if(bot->flags & SOCKET_FLAG_PREFERRED)
@@ -190,7 +190,7 @@ void requestOp(struct UserNode *user, struct ChanNode *chan) {
 }
 
 void requestInvite(struct UserNode *user, struct ChanNode *chan) {
-    struct ClientSocket *bot, *userbot = NULL;
+    struct ClientSocket *bot;
     struct ChanUser *chanuser = getChanUser(user, chan);
     char invited = 0;
     if(chanuser) return;
@@ -199,9 +199,6 @@ void requestInvite(struct UserNode *user, struct ChanNode *chan) {
             invited = 1;
             putsock(bot, "INVITE %s %s", user->nick, chan->name);
         }
-        if(bot->user == user) {
-            userbot = bot;
-        }
     }
 }