X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fcmd_global_setbot.c;h=9118a0d520a8e695cd2226c45590d7e674e6379c;hb=0b17bccd2d7fbef5652168d11d4f0af1f41252d3;hp=c285ffd1b034411af071f3bb92e2980459c1dea0;hpb=b95bd20e8b27975dcdf3da156ed12a59efa62638;p=NeonServV5.git diff --git a/src/cmd_global_setbot.c b/src/cmd_global_setbot.c index c285ffd..9118a0d 100644 --- a/src/cmd_global_setbot.c +++ b/src/cmd_global_setbot.c @@ -1,4 +1,4 @@ -/* cmd_global_setbot.c - NeonServ v5.2 +/* cmd_global_setbot.c - NeonServ v5.3 * Copyright (C) 2011 Philipp Kreil (pk910) * * This program is free software: you can redistribute it and/or modify @@ -70,7 +70,7 @@ CMD_BIND(global_cmd_setbot) { else if(!stricmp(argv[1], "prefered")) log_event = global_cmd_setbot_prefered(user, row, value); else if(!stricmp(argv[1], "maxchan")) log_event = global_cmd_setbot_maxchan(user, row, value); else if(!stricmp(argv[1], "priority")) log_event = global_cmd_setbot_priority(user, row, value); - else if(!stricmp(argv[1], "trigger")) log_event = global_cmd_setbot_nick(user, row, value); + else if(!stricmp(argv[1], "trigger")) log_event = global_cmd_setbot_trigger(user, row, value); else { reply(getTextBot(), user, "NS_SETBOT_SETTING", argv[1]); } @@ -120,11 +120,32 @@ static int global_cmd_setbot_active(struct UserNode *user, MYSQL_ROW bot, char * client->botid = atoi(bot[5]); client->clientid = atoi(bot[15]); connect_socket(client); + if(client->botid == 0) { + MYSQL_RES *res; + MYSQL_ROW row; + printf_mysql_query("SELECT `command`, `function`, `parameters`, `global_access`, `chan_access` FROM `bot_binds` WHERE `botclass` = '0' AND `botid` = '%d'", client->clientid); + res = mysql_use(); + while ((row = mysql_fetch_row(res)) != NULL) { + if(bind_botwise_cmd_to_command(0, client->clientid, row[0], row[1])) { + if(row[2] && strcmp(row[2], "")) { + bind_botwise_set_parameters(0, client->clientid, row[0], row[2]); + } + if(row[3]) { + bind_botwise_set_global_access(0, client->clientid, row[0], atoi(row[3])); + } + if(row[4]) { + bind_botwise_set_channel_access(0, client->clientid, row[0], row[4]); + } + } + } + bind_botwise_unbound_required_functions(0, client->clientid); + } } else { //remove the bot struct ClientSocket *client; for(client = getBots(0, NULL); client; client = getBots(0, client)) { if(client->clientid == atoi(bot[15])) { + unbind_botwise_allcmd(client->clientid); close_socket(client); break; } @@ -456,7 +477,7 @@ static int global_cmd_setbot_maxchan(struct UserNode *user, MYSQL_ROW bot, char reply(getTextBot(), user, "NS_SETBOT_MAXCHAN_INVALID", value); return 0; } - printf_mysql_query("UPDATE `bots` SET `maxchan` = '%d' WHERE `id` = '%s'", val, bot[15]); + printf_mysql_query("UPDATE `bots` SET `max_channels` = '%d' WHERE `id` = '%s'", val, bot[15]); ret = 1; } reply(getTextBot(), user, "\002MAXCHAN \002 %d", val); @@ -488,6 +509,7 @@ static int global_cmd_setbot_trigger(struct UserNode *user, MYSQL_ROW bot, char return 0; } printf_mysql_query("UPDATE `bots` SET `defaulttrigger` = '%s' WHERE `id` = '%s'", escape_string(value), bot[15]); + flush_trigger_cache(atoi(bot[5]), atoi(bot[15])); reply(getTextBot(), user, "NS_SETBOT_TRIGGER_NOTE"); val = value; ret = 1;