X-Git-Url: http://git.pk910.de/?p=NeonServV5.git;a=blobdiff_plain;f=src%2Fmodules%2FDummyServ.mod%2Fbot_DummyServ.c;h=1b078ec00d073569cb224cd1158fa6e68454415f;hp=2911b23f7e399f55cb4507dc340ecef1604a2376;hb=ee3a72eb4a412a0a504d070db1b41c6907f7604d;hpb=939c6051a3ee85e3b3877fde35bdbf36ecb94fbc diff --git a/src/modules/DummyServ.mod/bot_DummyServ.c b/src/modules/DummyServ.mod/bot_DummyServ.c index 2911b23..1b078ec 100644 --- a/src/modules/DummyServ.mod/bot_DummyServ.c +++ b/src/modules/DummyServ.mod/bot_DummyServ.c @@ -108,6 +108,33 @@ static void start_bots(int type) { bind_unbound_required_functions(BOTID); } +static void dummyserv_event_invite(struct ClientSocket *client, struct UserNode *user, char *channel) { + if(client->botid != BOTID) + return; + MYSQL_RES *res; + MYSQL_ROW row; + printf_mysql_query("SELECT `botid`, `bot_channels`.`id`, `suspended` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` LEFT JOIN `channels` ON `chanid` = `channel_id` WHERE `channel_name` = '%s' AND `botclass` = '%d'", escape_string(channel), client->botid); + res = mysql_use(); + if ((row = mysql_fetch_row(res)) == NULL) { + reply(client, user, "NS_INVITE_FAIL", channel, client->user->nick); + return; + } + if(!strcmp(row[2], "1")) { + return; + } + int botid = atoi(row[0]); + struct ClientSocket *bot; + for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) { + if(bot->clientid == botid) + break; + } + if(bot) { + struct ChanNode *chan = getChanByName(channel); + if(!(chan && isUserOnChan(bot->user, chan))) + putsock(bot, "JOIN %s", channel); + } +} + void init_DummyServ(int type) { set_bot_alias(BOTID, BOTALIAS); start_bots(type); @@ -116,6 +143,7 @@ void init_DummyServ(int type) { //register events bind_bot_ready(dummyserv_bot_ready, module_id); + bind_invite(dummyserv_event_invite, module_id); set_trigger_callback(BOTID, module_id, dummyserv_trigger_callback); }