X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2Fmodcmd.c;h=6e4e59f2a4e93c7100182797e45dbf3fc22caa41;hb=35ffb2ad774fac945c200d06a30174fe676d94bb;hp=301bdfb625d75c664275b4d55b2f7c69891211fc;hpb=222e1b0003536cf7b47858961d4b56d45c6d6606;p=srvx.git diff --git a/src/modcmd.c b/src/modcmd.c index 301bdfb..6e4e59f 100644 --- a/src/modcmd.c +++ b/src/modcmd.c @@ -1,11 +1,12 @@ /* modcmd.c - Generalized module command support * Copyright 2002-2004 srvx Development Team * - * This program is free software; you can redistribute it and/or modify + * This file is part of srvx. + * + * srvx is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. Important limitations are - * listed in the COPYING file that accompanies this software. + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -13,7 +14,8 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, email srvx-maintainers@srvx.net. + * along with srvx; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include "arch-version.h" @@ -32,10 +34,9 @@ static struct dict *modules; static struct dict *services; static struct pending_template *pending_templates; static struct module *modcmd_module; -static struct modcmd *bind_command, *help_command; +static struct modcmd *bind_command, *help_command, *version_command; static const struct message_entry msgtab[] = { - { "MCMSG_VERSION", "$b"PACKAGE_STRING"$b ("CODENAME"), Built: " __DATE__ ", " __TIME__"." }, - { "MCMSG_BARE_FLAG", "Flag %.*s must be preceeded by a + or -." }, + { "MCMSG_BARE_FLAG", "Flag %.*s must be preceded by a + or -." }, { "MCMSG_UNKNOWN_FLAG", "Unknown module flag %.*s." }, { "MCMSG_BAD_OPSERV_LEVEL", "Invalid $O access level %s." }, { "MCMSG_BAD_CHANSERV_LEVEL", "Invalid $C access level %s." }, @@ -114,9 +115,15 @@ static const struct message_entry msgtab[] = { { "MCMSG_DUPLICATE_TRIGGER", "$b%s$b already uses trigger $b%c$b." }, { "MCMSG_CURRENT_TRIGGER", "Trigger for $b%s$b is $b%c$b." }, { "MCMSG_NEW_TRIGGER", "Changed trigger for $b%s$b to $b%c$b." }, + { "MCMSG_SERVICE_PRIVILEGED", "Service $b%s$b privileged: $b%s$b." }, { "MCMSG_SERVICE_REMOVED", "Service $b%s$b has been deleted." }, { "MCMSG_FILE_NOT_OPENED", "Unable to open file $b%s$b for writing." }, { "MCMSG_MESSAGES_DUMPED", "Messages written to $b%s$b." }, + { "MCMSG_MESSAGE_DUMP_FAILED", "Message dump failed: %s." }, + { "MCMSG_COMMAND_FLAGS", "Command flags are %s (inferred: %s)." }, + { "MCMSG_COMMAND_ACCOUNT_FLAGS", "Requires account flags +%s, prohibits account flags +%s." }, + { "MCMSG_COMMAND_ACCESS_LEVEL", "Requires channel access %d and $O access %d." }, + { "MCMSG_COMMAND_USES", "%s has been used %d times." }, { NULL, NULL } }; struct userData *_GetChannelUser(struct chanData *channel, struct handle_info *handle, int override, int allow_suspended); @@ -336,7 +343,7 @@ svccmd_configure(struct svccmd *cmd, struct userNode *user, struct userNode *bot return 1; } else if (!irccasecmp(param, "channel_level") || !irccasecmp(param, "channel_access") || !irccasecmp(param, "access")) { unsigned short ul; - if (!irccasecmp(value, "none")) { + if (!irccasecmp(value, "none") || !irccasecmp(value, "0")) { cmd->min_channel_access = 0; return 1; } else if ((ul = user_level_from_name(value, UL_OWNER)) > 0) { @@ -641,7 +648,8 @@ svccmd_invoke_argv(struct userNode *user, struct service *service, struct chanNo } cmd = dict_find(service->commands, argv[cmd_arg], NULL); if (!cmd) { - send_message(user, service->bot, "MSG_COMMAND_UNKNOWN", argv[cmd_arg]); + if (!channel) + send_message(user, service->bot, "MSG_COMMAND_UNKNOWN", argv[cmd_arg]); return 0; } flags = cmd->effective_flags; @@ -813,11 +821,63 @@ svccmd_invoke(struct userNode *user, struct service *service, struct chanNode *c void modcmd_privmsg(struct userNode *user, struct userNode *bot, char *text, int server_qualified) { struct service *service; + if (!(service = dict_find(services, bot->nick, NULL))) { log_module(MAIN_LOG, LOG_ERROR, "modcmd_privmsg got privmsg for unhandled service %s, unregistering.", bot->nick); reg_privmsg_func(bot, NULL); return; } + + if (text[0] == '\x01') { + char *term, response[MAXLEN]; + + text++; /* Skip leading ^A. */ + /* Chop off final ^A. */ + term = strchr(text, '\x01'); + if (!term) + return; + *term = '\0'; + /* Parse out leading text. */ + term = strchr(text, ' '); + if (term) { + *term++ = '\0'; + if (!*term) + term = NULL; + } + /* No dict lookup since these are so few. */ + if (!irccasecmp(text, "CLIENTINFO")) { + /* Use \001 instead of \x01 because apparently \x01C is + * interpreted as ASCII FS (\034, decimal 28, hex 1C). + */ + irc_notice_user(bot, user, "\001CLIENTINFO CLIENTINFO PING TIME USERINFO VERSION\x01"); + } else if (!irccasecmp(text, "PING")) { + if (term) { + snprintf(response, sizeof(response), "\x01PONG %s\x01", term); + irc_notice_user(bot, user, response); + } else { + irc_notice_user(bot,user, "\x01PONG\x01"); + } + } else if (!irccasecmp(text, "TIME")) { + struct tm tm; + localtime_r(&now, &tm); + strftime(response, sizeof(response), "\x01TIME %a %b %d %H:%M:%S %Y\x01", &tm); + irc_notice_user(bot, user, response); + } else if (!irccasecmp(text, "USERINFO")) { + snprintf(response, sizeof(response), "\x01USERINFO %s\x01", bot->info); + irc_notice_user(bot, user, response); + } else if (!irccasecmp(text, "VERSION")) { + /* This function provides copyright management information + * to end users of srvx. You should not alter, disable or + * remove this command or its accessibility to normal IRC + * users, except to add copyright information pertaining + * to changes you make to srvx. + */ + snprintf(response, sizeof(response), "\x01VERSION %s (%s) %s\x01", PACKAGE_STRING, CODENAME, ARCH_VERSION); + irc_notice_user(bot, user, response); + } + return; + } + if (service->msg_hook && service->msg_hook(user, bot, text, server_qualified)) return; svccmd_invoke(user, service, NULL, text, server_qualified); @@ -831,7 +891,7 @@ modcmd_chanmsg(struct userNode *user, struct chanNode *chan, char *text, struct } struct service * -service_register(struct userNode *bot, char trigger) { +service_register(struct userNode *bot) { struct service *service; if ((service = dict_find(services, bot->nick, NULL))) return service; @@ -839,12 +899,9 @@ service_register(struct userNode *bot, char trigger) { module_list_init(&service->modules); service->commands = dict_new(); service->bot = bot; - service->trigger = trigger; dict_set_free_data(service->commands, free_service_command); dict_insert(services, service->bot->nick, service); reg_privmsg_func(bot, modcmd_privmsg); - if (trigger) - reg_chanmsg_func(trigger, bot, modcmd_chanmsg); return service; } @@ -1296,6 +1353,54 @@ static MODCMD_FUNC(cmd_command) { return 1; } +static void +modcmd_describe_command(struct userNode *user, struct svccmd *cmd, struct svccmd *target) { + char buf1[MAXLEN], buf2[MAXLEN]; + unsigned int ii, len, buf1_used, buf2_used; + + if (target->alias.used) { + unsplit_string((char**)target->alias.list, target->alias.used, buf1); + reply("MCMSG_COMMAND_ALIASES", target->name, buf1); + } else { + snprintf(buf1, sizeof(buf1), "%s.%s", target->command->parent->name, target->command->name); + reply("MCMSG_COMMAND_BINDING", target->name, buf1); + } + for (ii = buf1_used = buf2_used = 0; flags[ii].name; ++ii) { + if (target->flags & flags[ii].flag) { + if (buf1_used) + buf1[buf1_used++] = ','; + len = strlen(flags[ii].name); + memcpy(buf1 + buf1_used, flags[ii].name, len); + buf1_used += len; + } else if (target->effective_flags & flags[ii].flag) { + if (buf2_used) + buf2[buf2_used++] = ','; + len = strlen(flags[ii].name); + memcpy(buf2 + buf2_used, flags[ii].name, len); + buf2_used += len; + } + } + if (buf1_used) + buf1[buf1_used] = '\0'; + else + strcpy(buf1, user_find_message(user, "MSG_NONE")); + if (buf2_used) + buf2[buf2_used] = '\0'; + else + strcpy(buf2, user_find_message(user, "MSG_NONE")); + reply("MCMSG_COMMAND_FLAGS", buf1, buf2); + for (ii = buf1_used = buf2_used = 0; handle_flags[ii]; ++ii) { + if (target->req_account_flags & (1 << ii)) + buf1[buf1_used++] = handle_flags[ii]; + else if (target->deny_account_flags & (1 << ii)) + buf2[buf2_used++] = handle_flags[ii]; + } + buf1[buf1_used] = buf2[buf2_used] = '\0'; + reply("MCMSG_COMMAND_ACCOUNT_FLAGS", buf1, buf2); + reply("MCMSG_COMMAND_ACCESS_LEVEL", target->min_channel_access, target->min_opserv_level); + reply("MCMSG_COMMAND_USES", target->name, target->uses); +} + static MODCMD_FUNC(cmd_modcmd) { struct svccmd *svccmd; unsigned int arg, changed; @@ -1303,7 +1408,7 @@ static MODCMD_FUNC(cmd_modcmd) { assert(argc >= 2); arg = collapse_cmdname(argv+1, argc-1, cmdname) + 1; - if (!arg || (arg+2 < argc)) { + if (!arg) { reply("MSG_MISSING_PARAMS", cmd->name); return 0; } @@ -1311,16 +1416,15 @@ static MODCMD_FUNC(cmd_modcmd) { reply("MCMSG_UNKNOWN_COMMAND_2", cmdname, cmd->parent->bot->nick); return 0; } - changed = 0; - while (arg+1 < argc) { + for (changed = 0; arg+1 < argc; arg += 2) { if (svccmd_configure(svccmd, user, cmd->parent->bot, argv[arg], argv[arg+1])) { reply("MCMSG_COMMAND_MODIFIED", argv[arg], svccmd->name); changed = 1; } - arg += 2; } if (changed) modcmd_set_effective_flags(svccmd); + modcmd_describe_command(user, cmd, svccmd); return changed; } @@ -1360,7 +1464,7 @@ static MODCMD_FUNC(cmd_god) { } static MODCMD_FUNC(cmd_joiner) { - char cmdname[80]; + char cmdname[MAXLEN]; if (argc < 2) { int len = sprintf(cmdname, "%s ", cmd->name); @@ -1519,7 +1623,8 @@ static MODCMD_FUNC(cmd_showcommands) { /* Find the matching commands. */ svccmd_list_init(&commands); - if (cmd->parent->privileged) ignore_flags = MODCMD_REQUIRE_OPER; + if (cmd->parent->privileged) + ignore_flags = MODCMD_REQUIRE_OPER; for (it = dict_first(cmd->parent->commands); it; it = iter_next(it)) { svccmd = iter_data(it); if (strchr(svccmd->name, ' ')) @@ -1610,7 +1715,7 @@ static MODCMD_FUNC(cmd_helpfiles) { } static MODCMD_FUNC(cmd_service_add) { - const char *nick, *desc; + const char *nick, *hostname, *desc; struct userNode *bot; nick = argv[1]; @@ -1618,14 +1723,15 @@ static MODCMD_FUNC(cmd_service_add) { reply("MCMSG_BAD_SERVICE_NICK", nick); return 0; } - desc = unsplit_string(argv+2, argc-2, NULL); + hostname = argv[2]; + desc = unsplit_string(argv+3, argc-3, NULL); bot = GetUserH(nick); if (bot && IsService(bot)) { reply("MCMSG_ALREADY_SERVICE", bot->nick); return 0; } - bot = AddService(nick, desc); - service_register(bot, '\0'); + bot = AddService(nick, NULL, desc, hostname); + service_register(bot); reply("MCMSG_NEW_SERVICE", bot->nick); return 1; } @@ -1673,6 +1779,21 @@ static MODCMD_FUNC(cmd_service_trigger) { return 1; } +static MODCMD_FUNC(cmd_service_privileged) { + struct service *service; + const char *newval; + + if (!(service = service_find(argv[1]))) { + reply("MCMSG_UNKNOWN_SERVICE", argv[1]); + return 0; + } + if (argc >= 3) + service->privileged = true_string(argv[2]) || enabled_string(argv[2]); + newval = user_find_message(user, service->privileged ? "MSG_ON" : "MSG_OFF"); + reply("MCMSG_SERVICE_PRIVILEGED", service->bot->nick, newval); + return 1; +} + static MODCMD_FUNC(cmd_service_remove) { char *name, *reason; struct service *service; @@ -1697,6 +1818,7 @@ static MODCMD_FUNC(cmd_dump_messages) { struct saxdb_context *ctx; dict_iterator_t it; FILE *pf; + int res; if (!(pf = fopen(fname, "w"))) { reply("MCMSG_FILE_NOT_OPENED", fname); @@ -1706,16 +1828,29 @@ static MODCMD_FUNC(cmd_dump_messages) { reply("MSG_INTERNAL_FAILURE"); return 0; } - for (it = dict_first(lang_C->messages); it; it = iter_next(it)) - saxdb_write_string(ctx, iter_key(it), iter_data(it)); - saxdb_close_context(ctx); - fclose(pf); - reply("MCMSG_MESSAGES_DUMPED", fname); - return 1; + if ((res = setjmp(ctx->jbuf)) != 0) { + ctx->complex.used = 0; /* to avoid false assert()s in close */ + saxdb_close_context(ctx); + fclose(pf); + reply("MCMSG_MESSAGE_DUMP_FAILED", strerror(res)); + return 0; + } else { + for (it = dict_first(lang_C->messages); it; it = iter_next(it)) + saxdb_write_string(ctx, iter_key(it), iter_data(it)); + saxdb_close_context(ctx); + fclose(pf); + reply("MCMSG_MESSAGES_DUMPED", fname); + return 1; + } } static MODCMD_FUNC(cmd_version) { - reply("MCMSG_VERSION"); + /* This function provides copyright management information to end + * users of srvx. You should not alter, disable or remove this + * command or its accessibility to normal IRC users, except to add + * copyright information pertaining to changes you make to srvx. + */ + send_message_type(4, user, cmd->parent->bot, "$b"PACKAGE_STRING"$b ("CODENAME"), Built: "__DATE__", "__TIME__".\nCopyright 2000-2004 srvx Development Team.\nThe srvx Development Team includes Paul Chang, Adrian Dewhurst, Miles Peterson, Michael Poole and others.\nThe srvx Development Team can be reached at http://sf.net/projects/srvx/ or in #srvx on irc.gamesurge.net."); if ((argc > 1) && !irccasecmp(argv[1], "arch")) send_message_type(4, user, cmd->parent->bot, "%s", ARCH_VERSION); return 1; @@ -1810,6 +1945,9 @@ modcmd_saxdb_write(struct saxdb_context *ctx) { saxdb_write_string(ctx, "trigger", buff); } saxdb_write_string(ctx, "description", service->bot->info); + saxdb_write_string(ctx, "hostname", service->bot->hostname); + if (service->privileged) + saxdb_write_string(ctx, "privileged", "1"); saxdb_end_record(ctx); } saxdb_end_record(ctx); @@ -1886,14 +2024,13 @@ modcmd_expand(const char *variable) { } static void -modcmd_load_bots(struct dict *db) { +modcmd_load_bots(struct dict *db, int default_nick) { dict_iterator_t it; for (it = dict_first(db); it; it = iter_next(it)) { struct record_data *rd; - struct userNode *bot; - const char *nick, *desc; - char trigger; + struct service *svc; + const char *nick, *desc, *hostname; rd = iter_data(it); if (rd->type != RECDB_OBJECT) { @@ -1901,24 +2038,33 @@ modcmd_load_bots(struct dict *db) { continue; } nick = database_get_data(rd->d.object, "nick", RECDB_QSTRING); - if (!nick) - nick = iter_key(it); - if (service_find(nick)) - continue; - desc = database_get_data(rd->d.object, "trigger", RECDB_QSTRING); - trigger = desc ? desc[0] : '\0'; + if (!nick) { + if (default_nick) + nick = iter_key(it); + else + continue; + } + svc = service_find(nick); desc = database_get_data(rd->d.object, "description", RECDB_QSTRING); - if (desc) - { - bot = AddService(nick, desc); - service_register(bot, trigger); + hostname = database_get_data(rd->d.object, "hostname", RECDB_QSTRING); + if (desc) { + if (!svc) + svc = service_register(AddService(nick, NULL, desc, hostname)); + else if (hostname) + strcpy(svc->bot->hostname, hostname); + desc = database_get_data(rd->d.object, "trigger", RECDB_QSTRING); + if (desc) + svc->trigger = desc[0]; + desc = database_get_data(rd->d.object, "privileged", RECDB_QSTRING); + if (desc && (true_string(desc) || enabled_string(desc))) + svc->privileged = 1; } } } static void modcmd_conf_read(void) { - modcmd_load_bots(conf_get_data("services", RECDB_OBJECT)); + modcmd_load_bots(conf_get_data("services", RECDB_OBJECT), 0); } void @@ -1933,25 +2079,26 @@ modcmd_init(void) { conf_register_reload(modcmd_conf_read); modcmd_module = module_register("modcmd", MAIN_LOG, "modcmd.help", modcmd_expand); - bind_command = modcmd_register(modcmd_module, "bind", cmd_bind, 4, MODCMD_KEEP_BOUND, "level", "800", NULL); + bind_command = modcmd_register(modcmd_module, "bind", cmd_bind, 4, MODCMD_KEEP_BOUND, "oper_level", "800", NULL); help_command = modcmd_register(modcmd_module, "help", cmd_help, 1, 0, "flags", "+nolog", NULL); modcmd_register(modcmd_module, "command", cmd_command, 2, 0, "flags", "+nolog", NULL); - modcmd_register(modcmd_module, "modcmd", cmd_modcmd, 4, MODCMD_KEEP_BOUND, "template", "bind", NULL); + modcmd_register(modcmd_module, "modcmd", cmd_modcmd, 2, MODCMD_KEEP_BOUND, "template", "bind", NULL); modcmd_register(modcmd_module, "god", cmd_god, 0, MODCMD_REQUIRE_AUTHED, "flags", "+oper,+networkhelper", NULL); - modcmd_register(modcmd_module, "readhelp", cmd_readhelp, 2, 0, "level", "650", NULL); - modcmd_register(modcmd_module, "timecmd", cmd_timecmd, 2, 0, "level", "1", NULL); + modcmd_register(modcmd_module, "readhelp", cmd_readhelp, 2, 0, "oper_level", "650", NULL); + modcmd_register(modcmd_module, "timecmd", cmd_timecmd, 2, 0, "oper_level", "1", NULL); modcmd_register(modcmd_module, "unbind", cmd_unbind, 3, 0, "template", "bind", NULL); modcmd_register(modcmd_module, "joiner", cmd_joiner, 1, 0, NULL); - modcmd_register(modcmd_module, "stats modules", cmd_stats_modules, 1, 0, "level", "0", NULL); - modcmd_register(modcmd_module, "stats services", cmd_stats_services, 1, 0, "level", "0", NULL); + modcmd_register(modcmd_module, "stats modules", cmd_stats_modules, 1, 0, "flags", "+oper", NULL); + modcmd_register(modcmd_module, "stats services", cmd_stats_services, 1, 0, "flags", "+oper", NULL); modcmd_register(modcmd_module, "showcommands", cmd_showcommands, 1, 0, "flags", "+acceptchan", NULL); modcmd_register(modcmd_module, "helpfiles", cmd_helpfiles, 2, 0, "template", "bind", NULL); - modcmd_register(modcmd_module, "service add", cmd_service_add, 3, 0, NULL); - modcmd_register(modcmd_module, "service rename", cmd_service_rename, 3, 0, NULL); - modcmd_register(modcmd_module, "service trigger", cmd_service_trigger, 2, 0, NULL); - modcmd_register(modcmd_module, "service remove", cmd_service_remove, 2, 0, NULL); + modcmd_register(modcmd_module, "service add", cmd_service_add, 4, 0, "flags", "+oper", NULL); + modcmd_register(modcmd_module, "service rename", cmd_service_rename, 3, 0, "flags", "+oper", NULL); + modcmd_register(modcmd_module, "service trigger", cmd_service_trigger, 2, 0, "flags", "+oper", NULL); + modcmd_register(modcmd_module, "service privileged", cmd_service_privileged, 2, 0, "flags", "+oper", NULL); + modcmd_register(modcmd_module, "service remove", cmd_service_remove, 2, 0, "flags", "+oper", NULL); modcmd_register(modcmd_module, "dumpmessages", cmd_dump_messages, 1, 0, "oper_level", "1000", NULL); - modcmd_register(modcmd_module, "version", cmd_version, 1, 0, NULL); + version_command = modcmd_register(modcmd_module, "version", cmd_version, 1, 0, NULL); message_register_table(msgtab); } @@ -2061,7 +2208,7 @@ modcmd_saxdb_read(struct dict *db) { struct record_data *rd, *rd2; struct service *service; - modcmd_load_bots(database_get_data(db, "bots", RECDB_OBJECT)); + modcmd_load_bots(database_get_data(db, "bots", RECDB_OBJECT), 1); db2 = database_get_data(db, "services", RECDB_OBJECT); if (!db2) { log_module(MAIN_LOG, LOG_ERROR, "Missing section 'services' in modcmd db."); @@ -2145,21 +2292,25 @@ create_default_binds(void) { continue; if (dict_size(service->commands) > 0) continue; + /* Bind the default modules for this service to it */ for (jj = 0; def_binds[ii].modnames[jj]; ++jj) { if (!(module = module_find(def_binds[ii].modnames[jj]))) continue; service_bind_module(service, module); } - /* Bind the help command to this service */ + + /* Bind the help and version commands to this service */ service_bind_modcmd(service, help_command, help_command->name); + service_bind_modcmd(service, version_command, version_command->name); + /* Now some silly hax.. (aliases that most people want) */ if (!irccasecmp(def_binds[ii].svcname, "ChanServ")) { - service_make_alias(service, "addowner", "*chanserv.adduser", "owner", "$1", NULL); - service_make_alias(service, "addcoowner", "*chanserv.adduser", "coowner", "$1", NULL); - service_make_alias(service, "addmaster", "*chanserv.adduser", "master", "$1", NULL); - service_make_alias(service, "addop", "*chanserv.adduser", "op", "$1", NULL); - service_make_alias(service, "addpeon", "*chanserv.adduser", "peon", "$1", NULL); + service_make_alias(service, "addowner", "*chanserv.adduser", "$1", "owner", NULL); + service_make_alias(service, "addcoowner", "*chanserv.adduser", "$1", "coowner", NULL); + service_make_alias(service, "addmaster", "*chanserv.adduser", "$1", "master", NULL); + service_make_alias(service, "addop", "*chanserv.adduser", "$1", "op", NULL); + service_make_alias(service, "addpeon", "*chanserv.adduser", "$1", "peon", NULL); service_make_alias(service, "delowner", "*chanserv.deluser", "owner", "$1", NULL); service_make_alias(service, "delcoowner", "*chanserv.deluser", "coowner", "$1", NULL); service_make_alias(service, "delmaster", "*chanserv.deluser", "master", "$1", NULL); @@ -2210,12 +2361,21 @@ import_aliases_db() { void modcmd_finalize(void) { + dict_iterator_t it; + /* Check databases. */ saxdb_register("modcmd", modcmd_saxdb_read, modcmd_saxdb_write); create_default_binds(); if (!saxdb_present) import_aliases_db(); + /* Register services for their triggers. */ + for (it = dict_first(services); it; it = iter_next(it)) { + struct service *svc = iter_data(it); + if (svc->trigger) + reg_chanmsg_func(svc->trigger, svc->bot, modcmd_chanmsg); + } + /* Resolve command rule-templates. */ while (pending_templates) { struct pending_template *ptempl = pending_templates;