}
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) {