{ "OSMSG_RAW_PARSE_ERROR", "Error parsing raw line (not dumping to uplink)." },
{ "OSMSG_COLLIDED_NICK", "Now temporarily holding nick $b%s$b." },
{ "OSMSG_RESERVED_NICK", "Now reserving nick $b%s$b." },
+ { "OSMSG_NICK_UNRESERVED", "Nick $b%s$b is no longer reserved." },
{ "OSMSG_NOT_RESERVED", "Nick $b%s$b is not reserved." },
{ "OSMSG_ILLEGAL_REASON", "This channel is illegal." },
{ "OSMSG_ILLEGAL_KILL_REASON", "Joined an illegal modeless channel - do not repeat." },
{ "OSMSG_CHANINFO_TOPIC_UNKNOWN", "Topic: (none / not gathered)" },
{ "OSMSG_CHANINFO_BAN_COUNT", "Bans (%d):" },
{ "OSMSG_CHANINFO_BAN", "%%s by %%s (%a %b %d %H:%M:%S %Y)" },
- { "OSMSG_CHANINFO_MANY_USERS", "%d users (\"/msg $s %s %s users\" for the list)" },
+ { "OSMSG_CHANINFO_MANY_USERS", "%d users (\"/msg $S %s %s users\" for the list)" },
{ "OSMSG_CHANINFO_USER_COUNT", "Users (%d):" },
{ "OSMSG_CSEARCH_CHANNEL_INFO", "%s [%d users] %s %s" },
{ NULL, NULL }
static dict_t opserv_nick_based_alerts; /* data is struct opserv_user_alert* */
static dict_t opserv_channel_alerts; /* data is struct opserv_user_alert* */
static struct module *opserv_module;
-static struct service *opserv_service;
static struct log_type *OS_LOG;
static unsigned int new_user_flood;
static char *level_strings[1001];
free(alert);
}
-static struct svccmd *
-opserv_get_command(const char *name) {
- return dict_find(opserv_service->commands, name, NULL);
-}
-
#define opserv_debug(format...) do { if (opserv_conf.debug_channel) send_channel_notice(opserv_conf.debug_channel , opserv , ## format); } while (0)
#define opserv_alert(format...) do { if (opserv_conf.alert_channel) send_channel_notice(opserv_conf.alert_channel , opserv , ## format); } while (0)
if (channel->topic_time) {
fmt = user_find_message(user, "OSMSG_CHANINFO_TOPIC");
strftime(buffer, sizeof(buffer), fmt, gmtime(&channel->topic_time));
- reply(buffer, channel->topic_nick, channel->topic);
+ send_message_type(4, user, cmd->parent->bot, buffer, channel->topic_nick, channel->topic);
} else {
irc_fetchtopic(cmd->parent->bot, channel->name);
reply("OSMSG_CHANINFO_TOPIC_UNKNOWN");
for (n = 0; n < channel->banlist.used; n++) {
ban = channel->banlist.list[n];
strftime(buffer, sizeof(buffer), fmt, localtime(&ban->set));
- reply(buffer, ban->ban, ban->who);
+ send_message_type(4, user, cmd->parent->bot, buffer, ban->ban, ban->who);
}
}
if ((argc < 2) && (channel->members.used >= 50)) {
change->args[1].mode = MODE_BAN;
change->args[1].hostmask = "*!*@*";
} else {
- change = mod_chanmode_alloc(2);
+ change = mod_chanmode_alloc(1);
change->args[0].mode = MODE_BAN;
change->args[0].hostmask = "*!*@*";
}
continue;
if (!(mn = GetUserMode(channel, victim)))
continue;
- if (!(mn->modes & MODE_CHANOP))
+ if (mn->modes & MODE_CHANOP)
continue;
change->args[count].mode = MODE_CHANOP;
change->args[count++].member = mn;
struct modeNode *mNode = channel->members.list[--nn];
if (IsService(mNode->user))
continue;
- KickChannelUser(mNode->user, channel, opserv, reason);
+ KickChannelUser(mNode->user, channel, opserv, user_find_message(mNode->user, reason));
}
timeq_add(now + opserv_conf.purge_lock_delay, opserv_part_channel, channel);
}
newchan->bad_channel = opserv_bad_channel(newchan->name);
}
+static void
+opserv_channel_delete(struct chanNode *chan)
+{
+ timeq_del(0, opserv_part_channel, chan, TIMEQ_IGNORE_WHEN);
+}
+
static int
opserv_join_check(struct modeNode *mNode)
{
if (channel->name[0] != '#')
DelUser(user, opserv, 1, "OSMSG_ILLEGAL_KILL_REASON");
else if (!GetUserMode(channel, opserv))
- opserv_shutdown_channel(channel, user_find_message(user, "OSMSG_ILLEGAL_REASON"));
+ opserv_shutdown_channel(channel, "OSMSG_ILLEGAL_REASON");
else {
send_message(user, opserv, "OSMSG_ILLEGAL_CHANNEL", channel->name);
msg = user_find_message(user, "OSMSG_ILLEGAL_REASON");
change.modes_set |= MODE_MODERATED;
if (change.modes_set || change.argc)
mod_chanmode_announce(opserv, channel, &change);
- send_channel_notice(channel, opserv, "OSMSG_FLOOD_MODERATE");
+ send_target_message(0, channel->name, opserv, "OSMSG_FLOOD_MODERATE");
opserv_alert("Warning: Possible join flood in %s (currently %d users; channel moderated).", channel->name, channel->members.used);
} else {
opserv_alert("Warning: Possible join flood in %s (currently %d users).", channel->name, channel->members.used);
static struct helpfile_expansion
opserv_help_expand(const char *variable)
{
+ extern struct userNode *message_source;
struct helpfile_expansion exp;
+ struct service *service;
struct svccmd *cmd;
dict_iterator_t it;
int row;
unsigned int level;
- if (!irccasecmp(variable, "index")) {
+ if (!(service = service_find(message_source->nick))) {
+ exp.type = HF_STRING;
+ exp.value.str = NULL;
+ } else if (!irccasecmp(variable, "index")) {
exp.type = HF_TABLE;
exp.value.table.length = 1;
exp.value.table.width = 2;
exp.value.table.flags = TABLE_REPEAT_HEADERS | TABLE_REPEAT_ROWS;
- exp.value.table.contents = calloc(dict_size(opserv_service->commands)+1, sizeof(char**));
+ exp.value.table.contents = calloc(dict_size(service->commands)+1, sizeof(char**));
exp.value.table.contents[0] = calloc(exp.value.table.width, sizeof(char*));
exp.value.table.contents[0][0] = "Command";
exp.value.table.contents[0][1] = "Level";
- for (it=dict_first(opserv_service->commands); it; it=iter_next(it)) {
+ for (it=dict_first(service->commands); it; it=iter_next(it)) {
cmd = iter_data(it);
row = exp.value.table.length++;
exp.value.table.contents[row] = calloc(exp.value.table.width, sizeof(char*));
exp.value.table.contents[row][1] = level_strings[level];
}
} else if (!strncasecmp(variable, "level", 5)) {
- cmd = opserv_get_command(variable+6);
+ cmd = dict_find(service->commands, variable+6, NULL);
exp.type = HF_STRING;
if (cmd) {
level = cmd->min_opserv_level;
case 2: iflags = MODCMD_REQUIRE_CHANNEL; break;
}
if (flags) {
- return modcmd_register(opserv_module, name, func, min_argc, iflags, "level", buf, "flags", flags, NULL);
+ return modcmd_register(opserv_module, name, func, min_argc, iflags, "level", buf, "flags", flags, "flags", "+oper", NULL);
} else {
- return modcmd_register(opserv_module, name, func, min_argc, iflags, "level", buf, NULL);
+ return modcmd_register(opserv_module, name, func, min_argc, iflags, "level", buf, "flags", "+oper", NULL);
}
}
char buf[MAXLEN];
sprintf(buf, "trace %s", argv[1]);
- if (!(subcmd = opserv_get_command(buf))) {
+ if (!(subcmd = dict_find(cmd->parent->commands, buf, NULL))) {
reply("OSMSG_BAD_ACTION", argv[1]);
return 0;
}
}
sprintf(buf, "%s %s", argv[0], argv[0]);
- if ((subcmd = opserv_get_command(buf))
+ if ((subcmd = dict_find(cmd->parent->commands, buf, NULL))
&& !svccmd_can_invoke(user, cmd->parent->bot, subcmd, channel, SVCCMD_NOISY)) {
return 0;
}
return 0;
}
sprintf(buf, "%s %s", argv[0], argv[0]);
- if ((subcmd = opserv_get_command(buf))
+ if ((subcmd = dict_find(cmd->parent->commands, buf, NULL))
&& !svccmd_can_invoke(user, cmd->parent->bot, subcmd, channel, SVCCMD_NOISY)) {
return 0;
}
name = argv[1];
sprintf(buf, "addalert %s", argv[2]);
- if (!(subcmd = opserv_get_command(buf))) {
+ if (!(subcmd = dict_find(cmd->parent->commands, buf, NULL))) {
reply("OSMSG_UNKNOWN_REACTION", argv[2]);
return 0;
}
}
conf_node = rd->d.object;
str = database_get_data(conf_node, KEY_DEBUG_CHANNEL, RECDB_QSTRING);
- if (str) {
+ if (opserv && str) {
str2 = database_get_data(conf_node, KEY_DEBUG_CHANNEL_MODES, RECDB_QSTRING);
if (!str2)
str2 = "+tinms";
opserv_conf.debug_channel = NULL;
}
str = database_get_data(conf_node, KEY_ALERT_CHANNEL, RECDB_QSTRING);
- if (str) {
+ if (opserv && str) {
str2 = database_get_data(conf_node, KEY_ALERT_CHANNEL_MODES, RECDB_QSTRING);
if (!str2)
str2 = "+tns";
opserv_conf.alert_channel = NULL;
}
str = database_get_data(conf_node, KEY_STAFF_AUTH_CHANNEL, RECDB_QSTRING);
- if (str) {
+ if (opserv && str) {
str2 = database_get_data(conf_node, KEY_STAFF_AUTH_CHANNEL_MODES, RECDB_QSTRING);
if (!str2)
str2 = "+timns";
str = database_get_data(conf_node, KEY_JOIN_FLOOD_MODERATE_THRESH, RECDB_QSTRING);
opserv_conf.join_flood_moderate_threshold = str ? strtoul(str, NULL, 0) : 50;
str = database_get_data(conf_node, KEY_NICK, RECDB_QSTRING);
- if (str)
+ if (opserv && str)
NickChange(opserv, str, 0);
str = database_get_data(conf_node, KEY_CLONE_GLINE_DURATION, RECDB_QSTRING);
opserv_conf.clone_gline_duration = str ? ParseInterval(str) : 3600;
void
init_opserv(const char *nick)
{
- opserv = AddService(nick, "Oper Services");
OS_LOG = log_register_type("OpServ", "file:opserv.log");
+ if (nick)
+ opserv = AddService(nick, "Oper Services");
conf_register_reload(opserv_conf_read);
memset(level_strings, 0, sizeof(level_strings));
reg_nick_change_func(opserv_alert_check_nick);
reg_del_user_func(opserv_user_cleanup);
reg_new_channel_func(opserv_channel_check);
+ reg_del_channel_func(opserv_channel_delete);
reg_join_func(opserv_join_check);
reg_auth_func(opserv_staff_alert);
opserv_db_init();
saxdb_register("OpServ", opserv_saxdb_read, opserv_saxdb_write);
- opserv_service = service_find(opserv->nick);
+ if (nick)
+ service_register(opserv, '?');
reg_exit_func(opserv_db_cleanup);
message_register_table(msgtab);