added cmd_commands and changed cmd_command to a global command
authorpk910 <philipp@zoelle1.de>
Mon, 31 Oct 2011 19:30:02 +0000 (20:30 +0100)
committerpk910 <philipp@zoelle1.de>
Mon, 31 Oct 2011 20:36:37 +0000 (21:36 +0100)
Makefile.am
src/bot_NeonServ.c
src/cmd_global.h
src/cmd_global_command.c [new file with mode: 0644]
src/cmd_global_commands.c [new file with mode: 0644]
src/cmd_neonserv.h
src/cmd_neonserv_command.c [deleted file]
src/commands.c
src/modcmd.c
src/modcmd.h

index 215c28b11417116ba78ba9fff07935380f831d05..121bb073b2e5ad49f7c6fb839e0b32dfe159a73c 100644 (file)
@@ -43,7 +43,8 @@ neonserv_SOURCES = src/version.c \
       src/cmd_global_bind.c \
       src/cmd_neonserv_chanservsync.c \
       src/cmd_neonserv_clvl.c \
-      src/cmd_neonserv_command.c \
+      src/cmd_global_command.c \
+      src/cmd_global_commands.c \
       src/cmd_neonserv_csuspend.c \
       src/cmd_neonserv_cunsuspend.c \
       src/cmd_neonserv_delban.c \
index 55445e0c56b8fff70b7bb5c17455a11275b44497..81240489a188ec26cb53a2b8881ba11f4b56f5ad 100644 (file)
@@ -314,6 +314,10 @@ static const struct default_language_entry msgtab[] = {
     {"NS_RENAME_FAIL", "Failed renaming $b%s$b."},
     {"NS_FUN_DISABLED", "Fun commands are disabled in %s."},
     {"NS_UNBIND_REQUIRED", "%1$s is a required function and there is no other command bound to %1$s. Bind anothjer command to %1$s first."}, /* {ARGS: bind} */
+    {"NS_COMMANDS_NAME", "Name"},
+    {"NS_COMMANDS_ACCESS", "Access"},
+    {"NS_COMMANDS_GACCESS", "GodAccess"},
+    {"NS_COMMANDS_FUNCTION", "Function"},
     {NULL, NULL}
 };
 
index 95164e232cee933499604eb4d274db1ba5113403..6ef1706347940ba5a5ff652dc0a21d934392349a 100644 (file)
@@ -38,6 +38,8 @@
 #include "bots.h"
 
 CMD_BIND(global_cmd_bind);
+CMD_BIND(global_cmd_command);
+CMD_BIND(global_cmd_commands);
 CMD_BIND(global_cmd_emote);
 CMD_BIND(global_cmd_god);
 CMD_BIND(global_cmd_netinfo);
diff --git a/src/cmd_global_command.c b/src/cmd_global_command.c
new file mode 100644 (file)
index 0000000..1382296
--- /dev/null
@@ -0,0 +1,175 @@
+/* cmd_global_command.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 "cmd_global.h"
+
+/*
+* argv[0-1]     command
+*/
+static int global_cmd_command_chanaccess(struct cmd_binding *cbind, struct ChanNode *chan);
+static int global_cmd_command_operaccess(struct cmd_binding *cbind);
+
+CMD_BIND(global_cmd_command) {
+    char *ident;
+    MYSQL_RES *res;
+    MYSQL_ROW row;
+    struct cmd_binding *cbind = find_cmd_binding(client->botid, argv[0]);
+    if (!cbind) {
+        reply(getTextBot(), user, "NS_UNBIND_NOT_FOUND", argv[0]);
+        return;
+    }
+    ident = argv[0];
+    char parameters[MAXLEN];
+    if(cbind->paramcount) {
+        int i, parampos = 0;
+        for(i = 0; i < cbind->paramcount; i++) {
+            parampos += sprintf(parameters + parampos, (i ? " %s" : "%s"), cbind->parameters[i]);
+        }
+    } else
+        parameters[0] = '\0';
+    reply(getTextBot(), user, "NS_COMMAND_BINDING", cbind->cmd, cbind->func->name, parameters);
+    if(chan)
+        reply(getTextBot(), user, "NS_COMMAND_ACCESS", global_cmd_command_chanaccess(cbind, chan), global_cmd_command_operaccess(cbind));
+    printf_mysql_query("SELECT `user_lang` FROM `users` WHERE `user_user` = '%s'", escape_string(user->auth));
+    res = mysql_use();
+    char *lang;
+    if ((row = mysql_fetch_row(res)) != NULL)
+        lang = row[0];
+    else
+        lang = "en";
+    printf_mysql_query("SELECT `text` FROM `help` WHERE `lang` = '%s' AND `ident` = '%s'", escape_string(lang), escape_string(ident));
+    res = mysql_use();
+    if ((row = mysql_fetch_row(res)) == NULL) {
+        if(stricmp(lang, "en")) {
+            printf_mysql_query("SELECT `text` FROM `help` WHERE `lang` = 'en' AND `ident` = '%s'", escape_string(ident));
+            res = mysql_use();
+        }
+        if ((row = mysql_fetch_row(res)) == NULL) {
+            printf_mysql_query("SELECT `text` FROM `help` WHERE `lang` = '%s' AND `ident` = '%s'", escape_string(lang), escape_string(cbind->func->name));
+            res = mysql_use();
+            if ((row = mysql_fetch_row(res)) == NULL) {
+                if(stricmp(lang, "en")) {
+                    printf_mysql_query("SELECT `text` FROM `help` WHERE `lang` = 'en' AND `ident` = '%s'", escape_string(cbind->func->name));
+                    res = mysql_use();
+                }
+                if ((row = mysql_fetch_row(res)) == NULL) {
+                    return;
+                }
+            }
+        }
+    }
+    char sendBuf[MAXLEN];
+    int sendBufPos = 0;
+    int i;
+    for(i = 0; i < strlen(row[0]); i++) {
+        switch(row[0][i]) {
+            case '\n':
+                if(sendBufPos) {
+                    sendBuf[sendBufPos] = '\0';
+                    reply(getTextBot(), user, "%s", sendBuf);
+                    sendBufPos = 0;
+                }
+                break;
+            case '$':
+                switch(row[0][i+1]) {
+                    case 'b':
+                        sendBuf[sendBufPos++] = '\002';
+                        i++;
+                        break;
+                    case 'k':
+                        sendBuf[sendBufPos++] = '\003';
+                        i++;
+                        break;
+                    case 'u':
+                        sendBuf[sendBufPos++] = '\031';
+                        i++;
+                        break;
+                    case 'C':
+                    case 'S':
+                        sendBufPos += sprintf(sendBuf + sendBufPos, "%s", client->user->nick);
+                        i++;
+                        break;
+                    default:
+                        sendBuf[sendBufPos++] = '$';
+                        break;
+                }
+                break;
+            default:
+                sendBuf[sendBufPos++] = row[0][i];
+                break;
+        }
+    }
+    if(sendBufPos) {
+        sendBuf[sendBufPos] = '\0';
+        reply(getTextBot(), user, "%s", sendBuf);
+        sendBufPos = 0;
+    }
+}
+
+static int global_cmd_command_chanaccess(struct cmd_binding *cbind, struct ChanNode *chan) {
+    char access_list[256];
+    int access_pos = 0;
+    int access_count = 0;
+    int minaccess = 0;
+    char *str_a, *str_b = cbind->func->channel_access, *str_c;
+    if(cbind->flags & CMDFLAG_OVERRIDE_CHANNEL_ACCESS)
+        str_b = cbind->channel_access;
+    access_list[0] = '\0';
+    if(str_b) {
+        str_c = strdup(str_b);
+        str_b = str_c;
+        while((str_a = str_b)) {
+            str_b = strstr(str_a, ",");
+            if(str_b) {
+                *str_b = '\0';
+                str_b++;
+            }
+            if(*str_a == '#') {
+                str_a++;
+                access_pos += sprintf(access_list+access_pos, (access_pos ? ", `%s`" : "`%s`"), str_a);
+                access_count++;
+            } else {
+               if(atoi(str_a) > minaccess)
+                     minaccess = atoi(str_a);
+            }
+        }
+        free(str_c);
+    }
+    if(access_count) {
+        MYSQL_RES *res;
+        MYSQL_ROW row, defaults = NULL;
+        printf_mysql_query("SELECT %s FROM `channels` WHERE `channel_name` = '%s'", access_list, escape_string(chan->name));
+        res = mysql_use();
+        if ((row = mysql_fetch_row(res)) != NULL) {
+            int i, caccess;
+            for(i = 0; i < access_count; i++) {
+                if(!row[i] && !defaults) {
+                    printf_mysql_query("SELECT %s FROM `channels` WHERE `channel_name` = 'defaults'", access_list);
+                    defaults = mysql_fetch_row(mysql_use());
+                }
+                caccess = (row[i] ? atoi(row[i]) : atoi(defaults[i]));
+                if(caccess > minaccess)
+                     minaccess = caccess;
+            }
+        }
+    }
+    return minaccess;
+}
+
+static int global_cmd_command_operaccess(struct cmd_binding *cbind) {
+    return ((cbind->flags & CMDFLAG_OVERRIDE_GLOBAL_ACCESS) ? cbind->global_access : cbind->func->global_access);
+}
diff --git a/src/cmd_global_commands.c b/src/cmd_global_commands.c
new file mode 100644 (file)
index 0000000..53f90bd
--- /dev/null
@@ -0,0 +1,136 @@
+/* cmd_global_commands.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 "cmd_global.h"
+
+/*
+* argv[0]    mask
+*/
+
+static int global_cmd_commands_sort(const void *a, const void *b);
+static int global_cmd_commands_chanaccess(struct cmd_binding *cbind, struct ChanNode *chan);
+static int global_cmd_commands_operaccess(struct cmd_binding *cbind);
+
+CMD_BIND(global_cmd_commands) {
+    struct cmd_binding *cbind;
+    int bindcount = 0;
+    for(cbind = getAllBinds(NULL); cbind; cbind = getAllBinds(cbind)) {
+        if(cbind->botid == client->botid)
+            bindcount++;
+    }
+    struct cmd_binding *binds[bindcount];
+    bindcount = 0;
+    for(cbind = getAllBinds(NULL); cbind; cbind = getAllBinds(cbind)) {
+        if(cbind->botid == client->botid)
+            binds[bindcount++] = cbind;
+    }
+    qsort(binds, bindcount, sizeof(struct cmd_binding *), global_cmd_commands_sort);
+    int i;
+    struct Table *table;
+    table = table_init(4, bindcount + 1, 0);
+    char *content[4];
+    content[0] = get_language_string(user, "NS_COMMANDS_NAME");
+    content[1] = get_language_string(user, "NS_COMMANDS_ACCESS");
+    content[2] = get_language_string(user, "NS_COMMANDS_GACCESS");
+    content[3] = get_language_string(user, "NS_COMMANDS_FUNCTION");
+    table_add(table, content);
+    char caccess[5];
+    char gaccess[5];
+    for(i = 0; i < bindcount; i++) {
+        cbind = binds[i];
+        content[0] = cbind->cmd;
+        sprintf(caccess, "%d", global_cmd_commands_chanaccess(cbind, chan));
+        content[1] = caccess;
+        sprintf(gaccess, "%d", global_cmd_commands_operaccess(cbind));
+        content[2] = gaccess;
+        content[3] = cbind->func->name;
+        table_add(table, content);
+    }
+    //send the table
+    char **table_lines = table_end(table);
+    for(i = 0; i < table->entrys; i++) {
+        reply(getTextBot(), user, table_lines[i]);
+    }
+    
+}
+
+static int global_cmd_commands_sort(const void *a, const void *b) {
+    const struct cmd_binding *bind_a = *((struct cmd_binding * const *) a);
+    const struct cmd_binding *bind_b = *((struct cmd_binding * const *) b); 
+    int i = stricmp(bind_a->func->name, bind_b->func->name);
+    if(i == 0) {
+        return stricmp(bind_a->cmd, bind_b->cmd);
+    } else
+        return i;
+}
+
+static int global_cmd_commands_chanaccess(struct cmd_binding *cbind, struct ChanNode *chan) {
+    char access_list[256];
+    int access_pos = 0;
+    int access_count = 0;
+    int minaccess = 0;
+    char *str_a, *str_b = cbind->func->channel_access, *str_c;
+    if(cbind->flags & CMDFLAG_OVERRIDE_CHANNEL_ACCESS)
+        str_b = cbind->channel_access;
+    access_list[0] = '\0';
+    if(str_b) {
+        str_c = strdup(str_b);
+        str_b = str_c;
+        while((str_a = str_b)) {
+            str_b = strstr(str_a, ",");
+            if(str_b) {
+                *str_b = '\0';
+                str_b++;
+            }
+            if(*str_a == '#') {
+                str_a++;
+                access_pos += sprintf(access_list+access_pos, (access_pos ? ", `%s`" : "`%s`"), str_a);
+                access_count++;
+            } else {
+               if(atoi(str_a) > minaccess)
+                     minaccess = atoi(str_a);
+            }
+        }
+        free(str_c);
+    }
+    if(access_count) {
+        if(!chan) {
+            return -1;
+        }
+        MYSQL_RES *res;
+        MYSQL_ROW row, defaults = NULL;
+        printf_mysql_query("SELECT %s FROM `channels` WHERE `channel_name` = '%s'", access_list, escape_string(chan->name));
+        res = mysql_use();
+        if ((row = mysql_fetch_row(res)) != NULL) {
+            int i, caccess;
+            for(i = 0; i < access_count; i++) {
+                if(!row[i] && !defaults) {
+                    printf_mysql_query("SELECT %s FROM `channels` WHERE `channel_name` = 'defaults'", access_list);
+                    defaults = mysql_fetch_row(mysql_use());
+                }
+                caccess = (row[i] ? atoi(row[i]) : atoi(defaults[i]));
+                if(caccess > minaccess)
+                     minaccess = caccess;
+            }
+        }
+    }
+    return minaccess;
+}
+
+static int global_cmd_commands_operaccess(struct cmd_binding *cbind) {
+    return ((cbind->flags & CMDFLAG_OVERRIDE_GLOBAL_ACCESS) ? cbind->global_access : cbind->func->global_access);
+}
index dcdf8142bc7af20194543ef0cd69350b8cecb641..c6eb9dce8744a7ceec6fa3028d6830fab6c70657 100644 (file)
@@ -48,7 +48,6 @@ CMD_BIND(neonserv_cmd_ban);
 CMD_BIND(neonserv_cmd_bans);
 CMD_BIND(neonserv_cmd_chanservsync);
 CMD_BIND(neonserv_cmd_clvl);
-CMD_BIND(neonserv_cmd_command);
 CMD_BIND(neonserv_cmd_csuspend);
 CMD_BIND(neonserv_cmd_cunsuspend);
 CMD_BIND(neonserv_cmd_delban);
diff --git a/src/cmd_neonserv_command.c b/src/cmd_neonserv_command.c
deleted file mode 100644 (file)
index 1f5b172..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-/* cmd_neonserv_command.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 "cmd_neonserv.h"
-
-/*
-* argv[0-1]     command
-*/
-static int neonserv_cmd_command_chanaccess(struct cmd_binding *cbind, struct ChanNode *chan);
-static int neonserv_cmd_command_operaccess(struct cmd_binding *cbind);
-
-CMD_BIND(neonserv_cmd_command) {
-    char *ident;
-    MYSQL_RES *res;
-    MYSQL_ROW row;
-    struct cmd_binding *cbind = find_cmd_binding(client->botid, argv[0]);
-    if (!cbind) {
-        reply(getTextBot(), user, "NS_UNBIND_NOT_FOUND", argv[0]);
-        return;
-    }
-    ident = argv[0];
-    char parameters[MAXLEN];
-    if(cbind->paramcount) {
-        int i, parampos = 0;
-        for(i = 0; i < cbind->paramcount; i++) {
-            parampos += sprintf(parameters + parampos, (i ? " %s" : "%s"), cbind->parameters[i]);
-        }
-    } else
-        parameters[0] = '\0';
-    reply(getTextBot(), user, "NS_COMMAND_BINDING", cbind->cmd, cbind->func->name, parameters);
-    if(chan)
-        reply(getTextBot(), user, "NS_COMMAND_ACCESS", neonserv_cmd_command_chanaccess(cbind, chan), neonserv_cmd_command_operaccess(cbind));
-    printf_mysql_query("SELECT `user_lang` FROM `users` WHERE `user_user` = '%s'", escape_string(user->auth));
-    res = mysql_use();
-    char *lang;
-    if ((row = mysql_fetch_row(res)) != NULL)
-        lang = row[0];
-    else
-        lang = "en";
-    printf_mysql_query("SELECT `text` FROM `help` WHERE `lang` = '%s' AND `ident` = '%s'", escape_string(lang), escape_string(ident));
-    res = mysql_use();
-    if ((row = mysql_fetch_row(res)) == NULL) {
-        if(stricmp(lang, "en")) {
-            printf_mysql_query("SELECT `text` FROM `help` WHERE `lang` = 'en' AND `ident` = '%s'", escape_string(ident));
-            res = mysql_use();
-        }
-        if ((row = mysql_fetch_row(res)) == NULL) {
-            printf_mysql_query("SELECT `text` FROM `help` WHERE `lang` = '%s' AND `ident` = '%s'", escape_string(lang), escape_string(cbind->func->name));
-            res = mysql_use();
-            if ((row = mysql_fetch_row(res)) == NULL) {
-                if(stricmp(lang, "en")) {
-                    printf_mysql_query("SELECT `text` FROM `help` WHERE `lang` = 'en' AND `ident` = '%s'", escape_string(cbind->func->name));
-                    res = mysql_use();
-                }
-                if ((row = mysql_fetch_row(res)) == NULL) {
-                    return;
-                }
-            }
-        }
-    }
-    char sendBuf[MAXLEN];
-    int sendBufPos = 0;
-    int i;
-    for(i = 0; i < strlen(row[0]); i++) {
-        switch(row[0][i]) {
-            case '\n':
-                if(sendBufPos) {
-                    sendBuf[sendBufPos] = '\0';
-                    reply(getTextBot(), user, "%s", sendBuf);
-                    sendBufPos = 0;
-                }
-                break;
-            case '$':
-                switch(row[0][i+1]) {
-                    case 'b':
-                        sendBuf[sendBufPos++] = '\002';
-                        i++;
-                        break;
-                    case 'k':
-                        sendBuf[sendBufPos++] = '\003';
-                        i++;
-                        break;
-                    case 'u':
-                        sendBuf[sendBufPos++] = '\031';
-                        i++;
-                        break;
-                    case 'C':
-                    case 'S':
-                        sendBufPos += sprintf(sendBuf + sendBufPos, "%s", client->user->nick);
-                        i++;
-                        break;
-                    default:
-                        sendBuf[sendBufPos++] = '$';
-                        break;
-                }
-                break;
-            default:
-                sendBuf[sendBufPos++] = row[0][i];
-                break;
-        }
-    }
-    if(sendBufPos) {
-        sendBuf[sendBufPos] = '\0';
-        reply(getTextBot(), user, "%s", sendBuf);
-        sendBufPos = 0;
-    }
-}
-
-static int neonserv_cmd_command_chanaccess(struct cmd_binding *cbind, struct ChanNode *chan) {
-    char access_list[256];
-    int access_pos = 0;
-    int access_count = 0;
-    int minaccess = 0;
-    char *str_a, *str_b = cbind->func->channel_access, *str_c;
-    if(cbind->flags & CMDFLAG_OVERRIDE_CHANNEL_ACCESS)
-        str_b = cbind->channel_access;
-    access_list[0] = '\0';
-    if(str_b) {
-        str_c = strdup(str_b);
-        str_b = str_c;
-        while((str_a = str_b)) {
-            str_b = strstr(str_a, ",");
-            if(str_b) {
-                *str_b = '\0';
-                str_b++;
-            }
-            if(*str_a == '#') {
-                str_a++;
-                access_pos += sprintf(access_list+access_pos, (access_pos ? ", `%s`" : "`%s`"), str_a);
-                access_count++;
-            } else {
-               if(atoi(str_a) > minaccess)
-                     minaccess = atoi(str_a);
-            }
-        }
-        free(str_c);
-    }
-    if(access_count) {
-        MYSQL_RES *res;
-        MYSQL_ROW row, defaults = NULL;
-        printf_mysql_query("SELECT %s FROM `channels` WHERE `channel_name` = '%s'", access_list, escape_string(chan->name));
-        res = mysql_use();
-        if ((row = mysql_fetch_row(res)) != NULL) {
-            int i, caccess;
-            for(i = 0; i < access_count; i++) {
-                if(!row[i] && !defaults) {
-                    printf_mysql_query("SELECT %s FROM `channels` WHERE `channel_name` = 'defaults'", access_list);
-                    defaults = mysql_fetch_row(mysql_use());
-                }
-                caccess = (row[i] ? atoi(row[i]) : atoi(defaults[i]));
-                if(caccess > minaccess)
-                     minaccess = caccess;
-            }
-        }
-    }
-    return minaccess;
-}
-
-static int neonserv_cmd_command_operaccess(struct cmd_binding *cbind) {
-    return ((cbind->flags & CMDFLAG_OVERRIDE_GLOBAL_ACCESS) ? cbind->global_access : cbind->func->global_access);
-}
index f8da0363bef88871cc3bba3ffe70cb54947fbfa7..87e7305c609a1267c45f946a95bb0b2fa773ff82 100644 (file)
@@ -27,6 +27,8 @@ void register_commands() {
     //               NAME            FUNCTION        PARAMS     PRIVS                FLAGS
     USER_COMMAND("version",      global_cmd_version,   0, NULL,                   0);
     USER_COMMAND("netinfo",      global_cmd_netinfo,   0, NULL,                   0);
+    USER_COMMAND("commands",     global_cmd_commands,  0, NULL,                   0);
+    USER_COMMAND("command",      global_cmd_command,   1, NULL,                   0);
     #undef USER_COMMAND
     
     #define OPER_COMMAND(NAME,FUNCTION,PARAMCOUNT,GACCESS,FLAGS) register_command(0, NAME, FUNCTION, PARAMCOUNT, NULL, GACCESS, FLAGS)
@@ -95,7 +97,6 @@ void register_commands() {
     USER_COMMAND("inviteme",     neonserv_cmd_inviteme,  0, "#channel_getinvite",   CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN | CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH | CMDFLAG_LOG);
     USER_COMMAND("help",         neonserv_cmd_help,      0, NULL,                   0);
     USER_COMMAND("events",       neonserv_cmd_events,    0, "1",                    CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN | CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH);
-    USER_COMMAND("command",      neonserv_cmd_command,   1, NULL,                   0);
     USER_COMMAND("info",         neonserv_cmd_info,      0, NULL,                   CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN);
     USER_COMMAND("extscript",    neonserv_cmd_extscript, 0, NULL,                   CMDFLAG_EMPTY_ARGS | CMDFLAG_CHAN_PARAM);
     #undef USER_COMMAND
index 6b769eac56c6b2017cac2268cd3854d1e907148c..bfefb4bdca33f4c82a320dfc029806c3fb32fb54 100644 (file)
@@ -785,3 +785,20 @@ void register_bot_alias(int botid, char *alias) {
     bot_aliases = botalias;
 }
 
+struct cmd_binding *getAllBinds(struct cmd_binding *last) {
+    int bind_index;
+    if(last) {
+        if(last->next)
+            return last->next;
+        bind_index = get_binds_index(last->cmd[0]) + 1;
+        if(bind_index > 26)
+            return NULL;
+    } else
+        bind_index = 0;
+    do {
+        if(cmd_binds[bind_index])
+            return cmd_binds[bind_index];
+        bind_index++;
+    } while(bind_index < 27);
+    return NULL;
+}
index 400976825fb21ce3a54f6f662b447a7ac3b20644..40ad373ea3a403691ec341e43d9fb627e269f9da 100644 (file)
@@ -93,5 +93,6 @@ struct cmd_binding *find_cmd_binding(int botid, char *cmd);
 void bind_unbound_required_functions(int botid);
 
 void register_bot_alias(int botid, char *alias);
+struct cmd_binding *getAllBinds(struct cmd_binding *last);
 
 #endif
\ No newline at end of file