-/* cmd_global_register.c - NeonServ v5.2
- * Copyright (C) 2011 Philipp Kreil (pk910)
+/* cmd_global_register.c - NeonServ v5.3
+ * Copyright (C) 2011-2012 Philipp Kreil (pk910)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
printf_mysql_query("SELECT `botid`, `botclass` FROM `bot_channels` LEFT JOIN `bots` ON `bot_channels`.`botid` = `bots`.`id` LEFT JOIN `channels` ON `bot_channels`.`chanid` = `channels`.`channel_id` WHERE `channel_name` = '%s'", escape_string(channel));
res = mysql_use();
while ((row = mysql_fetch_row(res)) != NULL) {
- if(atoi(row[1]) == client->botid) {
+ if(atoi(row[1]) == client->botid && (client->botid || client->clientid == atoi(row[0]))) {
reply(getTextBot(), user, "NS_REGISTER_ALREADY", argv[0], client->user->nick);
return;
} else
global_cmd_register_async1(client, getTextBot(), user, chan, event, channel, NULL, multibot, botname);
return;
} else if(argc < 2) {
- reply(getTextBot(), user, "MODCMD_LESS_PARAM_COUNT");
+ global_cmd_register_async1(client, getTextBot(), user, chan, event, channel, user->auth, multibot, botname);
return;
}
//check own access
userid = (int) mysql_insert_id(mysql_conn);
}
}
- printf_mysql_query("SELECT `id`, `max_channels`, `defaulttrigger`, `nick` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1' ORDER BY `register_priority` DESC", client->botid);
+ if(client->botid)
+ printf_mysql_query("SELECT `id`, `max_channels`, `defaulttrigger`, `nick` FROM `bots` WHERE `botclass` = '%d' AND `active` = '1' ORDER BY `register_priority` DESC", client->botid);
+ else
+ printf_mysql_query("SELECT `id`, `max_channels`, `defaulttrigger`, `nick` FROM `bots` WHERE `id` = '%d' AND `active` = '1'", client->clientid);
res = mysql_use();
int botid = 0;
- char *bottrigger;
while ((row = mysql_fetch_row(res)) != NULL) {
//check channel count
printf_mysql_query("SELECT COUNT(*) FROM `bot_channels` WHERE `botid` = '%s'", row[0]);
row2 = mysql_fetch_row(mysql_use());
if(atoi(row2[0]) < atoi(row[1]) && (!botname || !stricmp(botname, row[3]))) {
botid = atoi(row[0]);
- bottrigger = row[2];
break;
}
}
putsock(bot, "JOIN %s", channel);
} else
reply(textclient, user, "NS_REGISTER_DISCONNECTED", channel);
- printf_mysql_query("INSERT INTO `bot_channels` (`botid`, `chanid`, `trigger`) VALUES ('%d', '%d', '%s')", botid, chanid, bottrigger);
+ printf_mysql_query("INSERT INTO `bot_channels` (`botid`, `chanid`, `trigger`) VALUES ('%d', '%d', NULL)", botid, chanid);
if(multibot != 2) {
if(multibot) {
printf_mysql_query("UPDATE `chanusers` SET `chanuser_access` = 499 WHERE `chanuser_cid` = '%d' AND `chanuser_access` = '500'", chanid);