use low priority bot if there is no preferred one
authorpk910 <philipp@zoelle1.de>
Sun, 2 Oct 2011 16:31:37 +0000 (18:31 +0200)
committerpk910 <philipp@zoelle1.de>
Sun, 2 Oct 2011 16:31:37 +0000 (18:31 +0200)
src/modcmd.c

index 5476d5e00a9798fff30610f4f01c2f5f70a4465c..4b1d2cc1eeeb767b7fb9663874980c5e00f4cec9 100644 (file)
@@ -53,12 +53,16 @@ static int get_binds_index(char first_char) {
 }
 
 struct ClientSocket* get_prefered_bot(int botid) {
-    struct ClientSocket *client;
+    struct ClientSocket *client, *lowbot = NULL;
     for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
-        if(client->botid == botid && (client->flags & SOCKET_FLAG_PREFERRED))
-            return client;
+        if(client->botid == botid) {
+            if((client->flags & SOCKET_FLAG_PREFERRED))
+                return client;
+            else
+                lowbot = client;
+        }
     }
-    return NULL;
+    return lowbot;
 }
 
 static char* get_channel_trigger(int botid, struct ChanNode *chan) {