{"NS_NO_ACCESS", "You lack sufficient access to use this command."},
{"NS_USER_PROTECTED", "Sorry, $b%s$b is protected."}, /* {ARGS: "TestUser"} */
{"NS_SERVICE_IMMUNE", "$b%s$b may not be kicked, killed, banned, or deopped."}, /* {ARGS: "TestUser"} */
+ {"NS_YOU_PROTECTED", "You may not kick or ban yourself."},
{"NS_TABLE_NONE", " None"},
{"NS_TABLE_COUNT", "Found $b%d$b matches."}, /* {ARGS: 5} */
{"NS_BAN_ALREADY_ADDED", "$b%s$b is already banned in %s."}, /* {ARGS: "*!*@moeeep.*", "#TestChan"} */
{"NS_INFO_OWNERCHANGE", " from %s to %s on %s"},
{"NS_RENAME_DONE", "Renamed $b%s$b to $b%s$b."},
{"NS_RENAME_FAIL", "Failed renaming $b%s$b."},
+ {"NS_FUN_DISABLED", "Fun commands are disabled in %s."},
{NULL, NULL}
};
#include "event_neonserv_invite.c"
#include "event_neonserv_topic.c"
+
struct ClientSocket *getBotForChannel(struct ChanNode *chan) {
- struct ClientSocket *bot, *use_bot = NULL, *second_bot = NULL, *third_bot = NULL;
- struct ChanUser *chanuser;
- for(bot = getBots(SOCKET_FLAG_READY, NULL); bot; bot = getBots(SOCKET_FLAG_READY, bot)) {
- if(bot->botid != BOTID) continue;
- if((chanuser = getChanUser(bot->user, chan)) != NULL) {
- if((chanuser->flags & CHANUSERFLAG_OPPED)) {
- use_bot = bot;
- if(bot->flags & SOCKET_FLAG_PREFERRED) break;
- } else if(bot->flags & SOCKET_FLAG_PREFERRED)
- second_bot = bot;
- else
- third_bot = bot;
- }
- }
- if(!use_bot) use_bot = second_bot;
- if(!use_bot) use_bot = third_bot;
- return use_bot;
+ return getChannelBot(chan, BOTID);
}
static void neonserv_bot_ready(struct ClientSocket *client) {
}
}
}
-
- //load all timed bans
- printf_mysql_query("SELECT `ban_id`, `ban_timeout` FROM `bans` WHERE `ban_timeout` > 0");
- res = mysql_use();
- char nameBuf[20];
- while ((row = mysql_fetch_row(res)) != NULL) {
- if(atol(row[1]) - time(0) > 0) {
- sprintf(nameBuf, "ban_%s", row[0]);
- timeq_add_name(nameBuf, atol(row[1]) - time(0), channel_ban_timeout, strdup(row[0]));
- } else {
- //timed out
- printf_mysql_query("DELETE FROM `bans` WHERE `ban_id` = '%s'", row[0]);
- }
- }
-}
-
-TIMEQ_CALLBACK(channel_ban_timeout) {
- char *str_banid = data;
- MYSQL_RES *res;
- MYSQL_ROW row;
- printf_mysql_query("SELECT `ban_mask`, `channel_name` FROM `bans` LEFT JOIN `channels` ON `ban_channel` = `channel_id` WHERE `ban_id` = '%s'", str_banid);
- res = mysql_use();
- struct ChanNode *chan;
- if((row = mysql_fetch_row(res)) != NULL && (chan = getChanByName(row[1])) != NULL) {
- struct ClientSocket *use_bot = getBotForChannel(chan);
- if(use_bot) {
- putsock(use_bot, "MODE %s -b %s", chan->name, row[0]);
- }
- printf_mysql_query("DELETE FROM `bans` WHERE `ban_id` = '%s'", str_banid);
- }
- free(str_banid);
}
void init_NeonServ() {
USER_COMMAND("events", neonserv_cmd_events, 0, "1", CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN | CMDFLAG_REQUIRE_AUTH | CMDFLAG_CHECK_AUTH);
USER_COMMAND("command", neonserv_cmd_command, 1, NULL, 0);
USER_COMMAND("info", neonserv_cmd_info, 0, NULL, CMDFLAG_REQUIRE_CHAN | CMDFLAG_REGISTERED_CHAN);
+ USER_COMMAND("extscript", neonserv_cmd_extscript, 0, NULL, CMDFLAG_EMPTY_ARGS | CMDFLAG_CHAN_PARAM);
#undef USER_COMMAND
#define OPER_COMMAND(NAME,FUNCTION,PARAMCOUNT,GACCESS,FLAGS) register_command(BOTID, NAME, FUNCTION, PARAMCOUNT, NULL, GACCESS, FLAGS)