added OPER support (let the bots try to op themselves)
[NeonServV5.git] / src / modules / DummyServ.mod / bot_DummyServ.c
index 9d9d7207ad24d64a4bc81865a16cd307ca71236b..2911b23f7e399f55cb4507dc340ecef1604a2376 100644 (file)
@@ -1,4 +1,4 @@
-/* bot_DummyServ.c - NeonServ v5.3
+/* bot_DummyServ.c - NeonServ v5.4
  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
  */
 #include "../module.h"
+#include "../botid.h"
 
 #include "bot_DummyServ.h"
-#include "modcmd.h"
-#include "IRCParser.h"
-#include "IRCEvents.h"
-#include "UserNode.h"
-#include "ChanNode.h"
-#include "ChanUser.h"
-#include "ModeNode.h"
-#include "BanNode.h"
-#include "ClientSocket.h"
-#include "mysqlConn.h"
-#include "lang.h"
-#include "HandleInfoHandler.h"
-#include "WHOHandler.h"
-#include "DBHelper.h"
-#include "tools.h"
-#include "timeq.h"
-#include "version.h"
-#include "EventLogger.h"
-#include "bots.h"
-#include "cmd_neonserv.h"
-#include "cmd_neonspam.h"
+#include "../../modcmd.h"
+#include "../../IRCParser.h"
+#include "../../IRCEvents.h"
+#include "../../UserNode.h"
+#include "../../ChanNode.h"
+#include "../../ChanUser.h"
+#include "../../ModeNode.h"
+#include "../../BanNode.h"
+#include "../../ClientSocket.h"
+#include "../../mysqlConn.h"
+#include "../../lang.h"
+#include "../../HandleInfoHandler.h"
+#include "../../WHOHandler.h"
+#include "../../DBHelper.h"
+#include "../../tools.h"
+#include "../../timeq.h"
+#include "../../version.h"
+#include "../../EventLogger.h"
+#include "../../bots.h"
 
-#define BOTID 3
+#define BOTID DUMMYSERV_BOTID
 #define BOTALIAS "DummyServ"
 
 static void dummyserv_bot_ready(struct ClientSocket *client) {
     MYSQL_RES *res;
     MYSQL_ROW row;
     
-    printf_mysql_query("SELECT `automodes` FROM `bots` WHERE `id` = '%d'", client->clientid);
+    printf_mysql_query("SELECT `automodes`, `oper_user`, `oper_pass` FROM `bots` WHERE `id` = '%d'", client->clientid);
     res = mysql_use();
     if ((row = mysql_fetch_row(res)) != NULL) {
+        if(row[1] && row[2]) {
+            putsock(client, "OPER %s %s", row[1], row[2]);
+        }
         putsock(client, "MODE %s +%s", client->user->nick, row[0]);
     }
     
@@ -113,9 +115,9 @@ void init_DummyServ(int type) {
     if(type == MODSTATE_REBIND) return;
     
     //register events
-    bind_bot_ready(dummyserv_bot_ready);
+    bind_bot_ready(dummyserv_bot_ready, module_id);
     
-    set_trigger_callback(BOTID, dummyserv_trigger_callback);
+    set_trigger_callback(BOTID, module_id, dummyserv_trigger_callback);
 }
 
 void loop_DummyServ() {