added automatic multi-bot rejoin for opless channels
[NeonServV5.git] / src / bots.c
index b30b5332767396b863d980d973cb302fa5b8b1a6..aece825925436b39f296e18c6ecf9f539c9601b8 100644 (file)
@@ -94,6 +94,24 @@ struct ClientSocket *getChannelBot(struct ChanNode *chan, int botid) {
     return use_bot;
 }
 
+void requestOp(struct UserNode *user, struct ChanNode *chan) {
+    struct ClientSocket *bot;
+    struct ChanUser *chanuser = getChanUser(user, chan);
+    char opped = 0;
+    if(!chanuser) return;
+    if((chanuser->flags & CHANUSERFLAG_OPPED)) return;
+    for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
+        if((chanuser = getChanUser(bot->user, chan)) != NULL && (chanuser->flags & CHANUSERFLAG_OPPED)) {
+            opped = 1;
+            putsock(bot, "MODE %s +o %s", chan->name, user->nick);
+            break;
+        }
+    }
+    if(!opped) {
+        //self op?
+    }
+}
+
 TIMEQ_CALLBACK(channel_ban_timeout) {
     char *str_banid = data;
     MYSQL_RES *res;