added NeonHelp bot (without any functions, yet)
authorpk910 <philipp@zoelle1.de>
Mon, 14 Nov 2011 15:02:25 +0000 (16:02 +0100)
committerpk910 <philipp@zoelle1.de>
Mon, 14 Nov 2011 15:11:15 +0000 (16:11 +0100)
Makefile.am
src/bot_NeonHelp.c [new file with mode: 0644]
src/bot_NeonHelp.h [new file with mode: 0644]
src/bots.c
src/cmd_neonhelp.h [new file with mode: 0644]

index ed81800dbb7cef663d11c5bbe54f52798b1f530b..ad6549a51f1f8d781f256ec942682895e14fa9ea 100644 (file)
@@ -34,6 +34,7 @@ neonserv_SOURCES = src/version.c \
       src/bot_NeonServ.c \
       src/bot_NeonSpam.c \
       src/bot_DummyServ.c \
+      src/bot_NeonHelp.c \
       src/cmd_neonserv_access.c \
       src/cmd_neonserv_addban.c \
       src/cmd_neonserv_addtimeban.c \
diff --git a/src/bot_NeonHelp.c b/src/bot_NeonHelp.c
new file mode 100644 (file)
index 0000000..3ced05c
--- /dev/null
@@ -0,0 +1,108 @@
+/* bot_HelpServ.c - NeonServ v5.2
+ * Copyright (C) 2011  Philipp Kreil (pk910)
+ * 
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License 
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. 
+ */
+
+#include "bot_NeonHelp.h"
+#include "modcmd.h"
+#include "cmd_neonhelp.h"
+
+#define BOTID 4
+#define BOTALIAS "NeonHelp"
+
+static void neonhelp_bot_ready(struct ClientSocket *client) {
+    MYSQL_RES *res;
+    MYSQL_ROW row;
+    
+    printf_mysql_query("SELECT `automodes` FROM `bots` WHERE `id` = '%d'", client->clientid);
+    res = mysql_use();
+    if ((row = mysql_fetch_row(res)) != NULL) {
+        putsock(client, "MODE %s +%s", client->user->nick, row[0]);
+    }
+    
+    printf_mysql_query("SELECT `channel_name`, `channel_key` FROM `bot_channels` LEFT JOIN `channels` ON `chanid` = `channel_id` WHERE `botid` = '%d' AND `suspended` = '0'", client->clientid);
+    res = mysql_use();
+    
+    while ((row = mysql_fetch_row(res)) != NULL) {
+        putsock(client, "JOIN %s %s", row[0], row[1]);
+    }
+}
+
+static void neonhelp_trigger_callback(struct ChanNode *chan, char *trigger) {
+    MYSQL_RES *res;
+    MYSQL_ROW row;
+    loadChannelSettings(chan);
+    printf_mysql_query("SELECT `trigger` FROM `bot_channels` LEFT JOIN `bots` ON `botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '%d'", chan->channel_id, BOTID);
+    res = mysql_use();
+    row = mysql_fetch_row(res);
+    strcpy(trigger, (strlen(row[0]) ? row[0] : "!"));
+}
+
+static void start_bots() {
+    struct ClientSocket *client;
+    MYSQL_RES *res, *res2;
+    MYSQL_ROW row;
+    
+    printf_mysql_query("SELECT `nick`, `ident`, `realname`, `server`, `port`, `pass`, `textbot`, `id`, `queue` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1'", BOTID);
+    res = mysql_use();
+    
+    while ((row = mysql_fetch_row(res)) != NULL) {
+        client = create_socket(row[3], atoi(row[4]), row[5], row[0], row[1], row[2]);
+        client->flags |= (strcmp(row[6], "0") ? SOCKET_FLAG_PREFERRED : 0);
+        client->flags |= (strcmp(row[8], "0") ? SOCKET_FLAG_USE_QUEUE : 0);
+        client->botid = BOTID;
+        client->clientid = atoi(row[7]);
+        connect_socket(client);
+    }
+    
+    printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access` FROM `bot_binds` WHERE `botclass` = '%d'", BOTID);
+    res2 = mysql_use();
+    while ((row = mysql_fetch_row(res2)) != NULL) {
+        if(bind_cmd_to_command(BOTID, row[0], row[1])) {
+            if(row[2] && strcmp(row[2], "")) {
+                bind_set_parameters(BOTID, row[0], row[2]);
+            }
+            if(row[3]) {
+                bind_set_global_access(BOTID, row[0], atoi(row[3]));
+            }
+            if(row[4]) {
+                bind_set_channel_access(BOTID, row[0], row[4]);
+            }
+        }
+    }
+    bind_unbound_required_functions(BOTID);
+}
+
+void init_NeonHelp() {
+    
+    set_bot_alias(BOTID, BOTALIAS);
+    start_bots();
+    
+    //register events
+    bind_bot_ready(neonhelp_bot_ready);
+    
+    set_trigger_callback(BOTID, neonhelp_trigger_callback);
+}
+
+void loop_NeonHelp() {
+    
+}
+
+void free_NeonHelp() {
+    
+}
+
+#undef BOTID
+#undef BOTALIAS
diff --git a/src/bot_NeonHelp.h b/src/bot_NeonHelp.h
new file mode 100644 (file)
index 0000000..e56fdc8
--- /dev/null
@@ -0,0 +1,26 @@
+/* bot_NeonHelp.h - NeonServ v5.2
+ * Copyright (C) 2011  Philipp Kreil (pk910)
+ * 
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License 
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. 
+ */
+#ifndef _bot_NeonHelp_h
+#define _bot_NeonHelp_h
+
+#include "main.h"
+
+void init_NeonHelp();
+void loop_NeonHelp();
+void free_NeonHelp();
+
+#endif
\ No newline at end of file
index 6a4ef848f458d086f49bcedc7b6559f74747ff04..b30b5332767396b863d980d973cb302fa5b8b1a6 100644 (file)
@@ -27,6 +27,7 @@
 #include "bot_NeonServ.h"
 #include "bot_NeonSpam.h"
 #include "bot_DummyServ.h"
+#include "bot_NeonHelp.h"
 
 struct cmd_bot_alias {
     int botid;
@@ -40,6 +41,7 @@ void init_bots() {
     init_NeonServ();
     init_NeonSpam();
     init_DummyServ();
+    init_NeonHelp();
     
     MYSQL_RES *res;
     MYSQL_ROW row;
@@ -62,12 +64,14 @@ void loop_bots() {
     loop_NeonServ();
     loop_NeonSpam();
     loop_DummyServ();
+    loop_NeonHelp();
 }
 
 void free_bots() {
     free_NeonServ();
     free_NeonSpam();
     free_DummyServ();
+    free_NeonHelp();
 }
 
 struct ClientSocket *getChannelBot(struct ChanNode *chan, int botid) {
diff --git a/src/cmd_neonhelp.h b/src/cmd_neonhelp.h
new file mode 100644 (file)
index 0000000..e169ef9
--- /dev/null
@@ -0,0 +1,24 @@
+/* cmd_neonhelp.h - NeonServ v5.2
+ * Copyright (C) 2011  Philipp Kreil (pk910)
+ * 
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License 
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. 
+ */
+#ifndef _cmd_neonhelp_h
+#define _cmd_neonhelp_h
+#include "main.h"
+#include "modcmd.h"
+
+
+
+#endif
\ No newline at end of file