moved cmds to extra files and loading binds from the database
[NeonServV5.git] / bot_NeonServ.c
index 1621d3c5a8497663f9f7fdc573482c623e222f74..7237bcf10652e885d1354affd78534f1f0dc4d68 100644 (file)
@@ -16,19 +16,11 @@ static const struct default_language_entry msgtab[] = {
     {NULL, NULL}
 };
 
-static CMD_BIND(neonserv_cmd_users) {
-    struct ChanUser *chanuser;
-    putsock(client, "PRIVMSG %s :[BOT JOIN] Users on this Channel:", chan->name);
-    for(chanuser = getChannelUsers(chan, NULL); chanuser; chanuser = getChannelUsers(chan, chanuser)) {
-        putsock(client, "PRIVMSG %s :  %s!%s@%s [%s]  rights: %d", chan->name, chanuser->user->nick, chanuser->user->ident, chanuser->user->host, ((chanuser->user->flags & USERFLAG_ISAUTHED) ? chanuser->user->auth : "*"), chanuser->flags);
-    }
-}
-
-static CMD_BIND(neonserv_cmd_modes) {
-    char modeBuf[MAXLEN];
-    getModeString(chan, modeBuf);
-    putsock(client, "PRIVMSG %s :Modes: %s", chan->name, modeBuf);
-}
+/*
+INCLUDE ALL CMD's HERE
+*/
+#include "cmd_neonserv_users.c"
+#include "cmd_neonserv_modes.c"
 
 static void neonserv_bot_ready(struct ClientSocket *client) {
     MYSQL_RES *res;
@@ -70,7 +62,14 @@ static void start_bots() {
         printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access` FROM `bot_binds` WHERE `botid` = '%d'", client->clientid);
         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(atoi(row[3]) > 0) {
+                    bind_set_gaccess(BOTID, row[0], atoi(row[3]));
+                }
+            }
         }
     }
 }
@@ -84,8 +83,6 @@ void init_NeonServ() {
     start_bots();
     bind_bot_ready(neonserv_bot_ready);
     set_trigger_callback(BOTID, neonserv_trigger_callback);
-    bind_cmd_to_command(BOTID, "users", "users");
-    bind_cmd_to_command(BOTID, "modes", "modes");
     
     register_default_language_table(msgtab);
 }