X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmodules%2FDummyServ.mod%2Fbot_DummyServ.c;h=259e640bdb8d318404cf74ce15ac57e31fb325a9;hb=c99b8d5951fe6429844c8cb5ff94213bb625ad95;hp=51d8bfb0e153f805e26a1b25209465a871f4d5ff;hpb=8a990d2c87f8f8a6ca26dd2c6afef161dab2eb9e;p=NeonServV5.git diff --git a/src/modules/DummyServ.mod/bot_DummyServ.c b/src/modules/DummyServ.mod/bot_DummyServ.c index 51d8bfb..259e640 100644 --- a/src/modules/DummyServ.mod/bot_DummyServ.c +++ b/src/modules/DummyServ.mod/bot_DummyServ.c @@ -1,4 +1,4 @@ -/* bot_DummyServ.c - NeonServ v5.3 +/* bot_DummyServ.c - NeonServ v5.5 * Copyright (C) 2011-2012 Philipp Kreil (pk910) * * This program is free software: you can redistribute it and/or modify @@ -15,6 +15,7 @@ * along with this program. If not, see . */ #include "../module.h" +#include "../botid.h" #include "bot_DummyServ.h" #include "../../modcmd.h" @@ -37,16 +38,21 @@ #include "../../EventLogger.h" #include "../../bots.h" -#define BOTID 3 +#define BOTID DUMMYSERV_BOTID #define BOTALIAS "DummyServ" static void dummyserv_bot_ready(struct ClientSocket *client) { + if(client->botid != BOTID) + return; MYSQL_RES *res; MYSQL_ROW row; - printf_mysql_query("SELECT `automodes` FROM `bots` WHERE `id` = '%d'", client->clientid); + printf_mysql_query("SELECT `automodes`, `oper_user`, `oper_pass` FROM `bots` WHERE `id` = '%d'", client->clientid); res = mysql_use(); if ((row = mysql_fetch_row(res)) != NULL) { + if(row[1] && row[2]) { + putsock(client, "OPER %s %s", row[1], row[2]); + } putsock(client, "MODE %s +%s", client->user->nick, row[0]); } @@ -104,6 +110,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); @@ -112,14 +145,11 @@ 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); } -void loop_DummyServ() { - -} - void free_DummyServ(int type) { unbind_allcmd(BOTID); if(type == MODSTATE_STARTSTOP) {