1 /* cmd_global_bots.c - NeonServ v5.2
2 * Copyright (C) 2011 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` FROM `bots`");
30 table = table_init(6, mysql_num_rows(res) + 1, 0);
32 content[0] = get_language_string(user, "NS_BOTS_NICK");
33 content[1] = get_language_string(user, "NS_BOTS_SERVER");
34 content[2] = get_language_string(user, "NS_BOTS_CLASS");
35 content[3] = get_language_string(user, "NS_BOTS_FLAGS");
36 content[4] = get_language_string(user, "NS_BOTS_CHANNELS");
37 content[5] = get_language_string(user, "NS_BOTS_TRIGGER");
38 table_add(table, content);
39 char botnick[NICKLEN + 3];
40 char botserver[MAXLEN];
44 while ((row = mysql_fetch_row(res)) != NULL) {
45 sprintf(botnick, (strcmp(row[0], "0") ? "%s" : "!%s"), row[1]);
47 sprintf(botserver, (strcmp(row[4], "") ? "%s:%s:*" : "%s:%s"), row[2], row[3]);
48 content[1] = botserver;
49 content[2] = (char *) resolve_botid(atoi(row[5]));
51 if(!strcmp(row[6], "1"))
52 botflags[flagspos++] = 't';
53 if(!strcmp(row[7], "1"))
54 botflags[flagspos++] = 'q';
55 botflags[flagspos] = '\0';
56 content[3] = botflags;
57 printf_mysql_query("SELECT COUNT(*) FROM `bot_channels` WHERE `botid` = '%s'", row[11]);
59 row2 = mysql_fetch_row(res2);
60 sprintf(botchans, "%s/%s", row2[0], row[9]);
61 content[4] = botchans;
63 table_add(table, content);
65 char **table_lines = table_end(table);
67 for(i = 0; i < table->entrys; i++) {
68 reply(getTextBot(), user, table_lines[i]);