2 #include "cmd_neonserv.h"
7 CMD_BIND(neonserv_cmd_cunsuspend) {
10 char *channel = argv[0];
11 if(!is_valid_chan(channel)) {
12 reply(getTextBot(), user, "NS_INVALID_CHANNEL_NAME", argv[0]);
16 printf_mysql_query("SELECT `channel_id` FROM `channels` WHERE `channel_name` = '%s'", escape_string(channel));
18 if ((row = mysql_fetch_row(res)) != NULL) {
19 chanid = atoi(row[0]);
21 reply(getTextBot(), user, "NS_UNREGISTER_NOT_REGISTERED", argv[0], client->user->nick);
24 printf_mysql_query("SELECT `botid`, `bot_channels`.`id`, `suspended` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` WHERE `chanid` = '%d' AND `botclass` = '%d'", chanid, client->botid);
26 if ((row = mysql_fetch_row(res)) == NULL) {
27 reply(getTextBot(), user, "NS_UNREGISTER_NOT_REGISTERED", argv[0], client->user->nick);
30 if(!strcmp(row[2], "0")) {
31 reply(getTextBot(), user, "NS_CUNSUSPEND_NOT", channel);
34 int botid = atoi(row[0]);
35 struct ClientSocket *bot;
36 for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
37 if(bot->clientid == botid)
41 putsock(bot, "JOIN %s", channel);
43 printf_mysql_query("UPDATE `bot_channels` SET `suspended` = '0' WHERE `id` = '%s'", row[1]);
44 reply(getTextBot(), user, "NS_CUNSUSPEND_DONE", channel);