added missing cmd includes
[NeonServV5.git] / modcmd.c
index 469de2e20f5a10ddb08a5d9ed9dbef8045332a46..5c07fb4e4828011040b799d0ec5dd05729ec3a38 100644 (file)
--- a/modcmd.c
+++ b/modcmd.c
@@ -8,6 +8,8 @@
 #include "ChanUser.h"
 #include "WHOHandler.h"
 #include "lang.h"
+#include "mysqlConn.h"
+#include "DBHelper.h"
 
 struct trigger_callback {
     int botid;
@@ -198,6 +200,22 @@ static void handle_command(struct ClientSocket *client, struct UserNode *user, s
                 reply(tmp_text_client, user, "MODCMD_CHAN_REQUIRED");
                 break;
             }
+            if((cbind->func->flags & CMDFLAG_REGISTERED_CHAN)) {
+                loadChannelSettings(chan);
+                if(!(chan->flags & CHANFLAG_CHAN_REGISTERED)) {
+                    reply(tmp_text_client, user, "MODCMD_CHAN_REQUIRED");
+                    break;
+                }
+                check_mysql();
+                MYSQL_RES *res;
+                MYSQL_ROW row;
+                printf_mysql_query("SELECT `botid` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '%d'", chan->channel_id, client->botid);
+                res = mysql_use();
+                if ((row = mysql_fetch_row(res)) == NULL) {
+                    reply(tmp_text_client, user, "MODCMD_CHAN_REQUIRED");
+                    break;
+                }
+            }
             if((cbind->func->flags & CMDFLAG_CHECK_AUTH) && !(user->flags & USERFLAG_ISAUTHED)) {
                 //check auth...
                 struct command_check_user_cache *data = malloc(sizeof(*data));
@@ -336,7 +354,7 @@ int bind_cmd_to_function(int botid, char *cmd, struct cmd_function *func) {
     cbind->cmd = strdup(cmd);
     cbind->func = func;
     cbind->parameters = NULL;
-    cbind->access = 0;
+    cbind->gaccess = 0;
     cbind->flags = 0;
     cbind->next = cmd_binds[bind_index];
     cmd_binds[bind_index] = cbind;
@@ -366,7 +384,7 @@ int bind_cmd_to_command(int botid, char *cmd, char *func) {
     cbind->func = cmdfunc;
     cbind->next = cmd_binds[bind_index];
     cbind->parameters = NULL;
-    cbind->access = 0;
+    cbind->gaccess = 0;
     cbind->flags = 0;
     cmd_binds[bind_index] = cbind;
     return 1;
@@ -435,7 +453,7 @@ void bind_set_parameters(int botid, char *cmd, char *parameters) {
     
 }
 
-void bind_set_gaccess(int botid, char *cmd, int access) {
+void bind_set_gaccess(int botid, char *cmd, int gaccess) {
     
 }