added NeonBackup recover command
[NeonServV5.git] / src / modules / NeonBackup.mod / bot_NeonBackup.c
index 19cffbde99cd6caafcbe9e4e2c6c05f9bcd44939..a886da3697cef4e5d35f722088d6aff480286235 100644 (file)
@@ -1,4 +1,4 @@
-/* bot_NeonBackup.c - NeonServ v5.4
+/* bot_NeonBackup.c - NeonServ v5.6
  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
@@ -88,7 +88,7 @@ static void start_bots(int type) {
     MYSQL_ROW row;
     
     if(type == MODSTATE_STARTSTOP) {
-        printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID);
+        printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue`, `ssl`, `bind`, `secret` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID);
         res = mysql_use();
         
         while ((row = mysql_fetch_row(res)) != NULL) {
@@ -96,6 +96,7 @@ static void start_bots(int type) {
             client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0);
             client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0);
             client->flags |= (strcmp(row[9], "0") ? SOCKET_FLAG_SSL : 0);
+            client->flags |= (strcmp(row[11], "0") ? SOCKET_FLAG_SECRET_BOT : 0);
             client->flags |= SOCKET_FLAG_REQUEST_INVITE | SOCKET_FLAG_REQUEST_OP;
             client->botid = BOTID;
             client->clientid = atoi(row[7]);
@@ -136,11 +137,14 @@ void neonbackup_recover_chan(struct ChanNode *chan) {
     if(!bot) //no opped bots present... channel can't be recovered
         return;
     struct ClientSocket *target;
+    struct ModeBuffer *modeBuf;
+    modeBuf = initModeBuffer(bot, chan);
     for(target = getBots(SOCKET_FLAG_READY, NULL); target; target = getBots(SOCKET_FLAG_READY, target)) {
         if((target->flags & SOCKET_FLAG_REQUEST_OP) && (chanuser = getChanUser(target->user, chan)) && !(chanuser->flags & CHANUSERFLAG_OPPED)) {
-            putsock(bot, "MODE %s +o %s", chan->name, target->user->nick);
+            modeBufferOp(modeBuf, target->user->nick);
         }
     }
+    freeModeBuffer(modeBuf);
 }
 
 static void neonbackup_event_join(struct ChanUser *chanuser) {
@@ -198,10 +202,6 @@ void init_NeonBackup(int type) {
     register_default_language_table(msgtab);
 }
 
-void loop_NeonBackup() {
-    
-}
-
 void free_NeonBackup(int type) {
     unbind_allcmd(BOTID);
     if(type == MODSTATE_STARTSTOP) {