-/* bot_NeonHelp.c - NeonServ v5.3
+/* bot_NeonHelp.c - NeonServ v5.4
* Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "../module.h"
+#include "../botid.h"
#include "bot_NeonHelp.h"
-#include "modcmd.h"
+#include "../../modcmd.h"
#include "cmd_neonhelp.h"
-#include "lang.h"
-#include "mysqlConn.h"
-#include "ClientSocket.h"
-#include "UserNode.h"
-#include "ChanNode.h"
-#include "ChanUser.h"
-#include "IRCEvents.h"
-#include "IRCParser.h"
-#include "bots.h"
-#include "DBHelper.h"
-#include "WHOHandler.h"
+#include "../../lang.h"
+#include "../../mysqlConn.h"
+#include "../../ClientSocket.h"
+#include "../../UserNode.h"
+#include "../../ChanNode.h"
+#include "../../ChanUser.h"
+#include "../../IRCEvents.h"
+#include "../../IRCParser.h"
+#include "../../bots.h"
+#include "../../DBHelper.h"
+#include "../../WHOHandler.h"
-#define BOTID 4
+#define BOTID NEONHELP_BOTID
#define BOTALIAS "NeonHelp"
static const struct default_language_entry msgtab[] = {
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]);
}
cache->user = user;
cache->target = target;
cache->message = strdup(message);
- get_userauth(user, neonhelp_event_privmsg_nick_lookup, cache);
+ get_userauth(user, module_id, neonhelp_event_privmsg_nick_lookup, cache);
}
}
if(!timeq_name_exists(nameBuf)) {
int *cidptr = malloc(sizeof(int));
*cidptr = client->clientid;
- timeq_add_name(nameBuf, 300, neonhelp_remind_open_requests, cidptr);
+ timeq_add_name(nameBuf, 300, module_id, neonhelp_remind_open_requests, cidptr);
}
}
printf_mysql_query("INSERT INTO `helpserv_requests` (`botid`, `host`, `hand`, `nick`, `status`, `supporter`, `time`, `text`) VALUES ('%d', '%s@%s', '%s', '%s', '0', '-1', UNIX_TIMESTAMP(), '%s')", client->clientid, escape_string(user->ident), escape_string(user->host), ((user->flags & USERFLAG_ISAUTHED) ? escape_string(user->auth) : "*"), escape_string(user->nick), escape_string(message));
char nameBuf[30];
sprintf(nameBuf, "neonhelp_%d", client->clientid);
if(!timeq_name_exists(nameBuf)) {
- timeq_add_name(nameBuf, 300, neonhelp_remind_open_requests, data);
+ timeq_add_name(nameBuf, 300, module_id, neonhelp_remind_open_requests, data);
}
char replybuf[MAXLEN];
build_language_string(NULL, replybuf, (requests == 1 ? "NH_REMIND_OPEN_REQUESTS_1" : "NH_REMIND_OPEN_REQUESTS_2"), requests);
void init_NeonHelp(int type) {
set_bot_alias(BOTID, BOTALIAS);
- start_bots();
+ start_bots(type);
if(type == MODSTATE_REBIND) return;
//register events
- bind_bot_ready(neonhelp_bot_ready);
- bind_privmsg(neonhelp_event_privmsg);
- bind_chanmsg(neonhelp_event_chanmsg);
- bind_part(neonhelp_event_part);
- bind_kick(neonhelp_event_kick);
- bind_quit(neonhelp_event_quit);
+ bind_bot_ready(neonhelp_bot_ready, module_id);
+ bind_privmsg(neonhelp_event_privmsg, module_id);
+ bind_chanmsg(neonhelp_event_chanmsg, module_id);
+ bind_part(neonhelp_event_part, module_id);
+ bind_kick(neonhelp_event_kick, module_id);
+ bind_quit(neonhelp_event_quit, module_id);
- set_trigger_callback(BOTID, neonhelp_trigger_callback);
+ set_trigger_callback(BOTID, module_id, neonhelp_trigger_callback);
register_default_language_table(msgtab);
}