1 /* cmd_global_bots.c - NeonServ v5.6
2 * Copyright (C) 2011-2012 Philipp Kreil (pk910)
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "cmd_global.h"
21 * argv[0] (optional) class name
24 CMD_BIND(global_cmd_bots) {
26 MYSQL_RES *res, *res2;
28 printf_mysql_query("SELECT `active`, `nick`, `server`, `port`, `pass`, `botclass`, `textbot`, `queue`, `defaulttrigger`, `max_channels`, `register_priority`, `id`, `secret` FROM `bots`");
30 table = table_init(7, mysql_num_rows(res) + 1, 0);
32 content[0] = get_language_string(user, "NS_BOTS_ID");
33 content[1] = get_language_string(user, "NS_BOTS_NICK");
34 content[2] = get_language_string(user, "NS_BOTS_SERVER");
35 content[3] = get_language_string(user, "NS_BOTS_CLASS");
36 content[4] = get_language_string(user, "NS_BOTS_FLAGS");
37 content[5] = get_language_string(user, "NS_BOTS_CHANNELS");
38 content[6] = get_language_string(user, "NS_BOTS_TRIGGER");
39 table_add(table, content);
40 char botnick[NICKLEN + 3];
41 char botserver[MAXLEN];
45 while ((row = mysql_fetch_row(res)) != NULL) {
47 sprintf(botnick, (strcmp(row[0], "0") ? "%s" : "!%s"), row[1]);
49 sprintf(botserver, (strcmp(row[4], "") ? "%s:%s:*" : "%s:%s"), row[2], row[3]);
50 content[2] = botserver;
51 content[3] = (char *) resolve_botid(atoi(row[5]));
53 if(!strcmp(row[6], "1"))
54 botflags[flagspos++] = 't';
55 if(!strcmp(row[7], "1"))
56 botflags[flagspos++] = 'q';
57 if(!strcmp(row[12], "1"))
58 botflags[flagspos++] = 's';
59 botflags[flagspos] = '\0';
60 content[4] = botflags;
61 printf_mysql_query("SELECT COUNT(*) FROM `bot_channels` WHERE `botid` = '%s'", row[11]);
63 row2 = mysql_fetch_row(res2);
64 sprintf(botchans, "%s/%s", row2[0], row[9]);
65 content[5] = botchans;
67 table_add(table, content);
69 char **table_lines = table_end(table);
71 for(i = 0; i < table->entrys; i++) {
72 reply(textclient, user, table_lines[i]);