[srvx-commits] CVS: services/src modcmd.c,1.67,1.68 modcmd.help,1.10,1.11
Brought to you by:
entrope
From: Entrope <en...@us...> - 2003-09-26 15:27:21
|
Update of /cvsroot/srvx/services/src In directory sc8-pr-cvs1:/tmp/cvs-serv3749/src Modified Files: modcmd.c modcmd.help Log Message: formatting changes to make profiling more accurate display current trigger when no trigger is given document "service <subcommand>" commands Index: modcmd.c =================================================================== RCS file: /cvsroot/srvx/services/src/modcmd.c,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -r1.67 -r1.68 *** modcmd.c 9 Sep 2003 01:58:30 -0000 1.67 --- modcmd.c 26 Sep 2003 15:27:16 -0000 1.68 *************** *** 96,99 **** --- 96,100 ---- #define MCMSG_SERVICE_RENAMED "Service renamed to $b%s$b." #define MCMSG_REMOVED_TRIGGER "Removed trigger from $b%s$b." + #define MCMSG_CURRENT_TRIGGER "Trigger for $b%s$b is $b%c$b." #define MCMSG_NEW_TRIGGER "Changed trigger for $b%s$b to $b%c$b." #define MCMSG_SERVICE_REMOVED "Service $b%s$b has been deleted." *************** *** 295,300 **** for (set_flags = rem_flags = 0; 1; value += end) { end = strcspn(value, ","); ! if (*value == '+') opt = 1; ! else if (*value == '-') opt = 0; else { if (user) { --- 296,303 ---- for (set_flags = rem_flags = 0; 1; value += end) { end = strcspn(value, ","); ! if (*value == '+') ! opt = 1; ! else if (*value == '-') ! opt = 0; else { if (user) { *************** *** 315,321 **** return 0; } ! if (opt) set_flags |= flag->flag, rem_flags &= ~flag->flag; ! else rem_flags |= flag->flag, set_flags &= ~flag->flag; ! if (!value[end-1]) break; } cmd->flags = (cmd->flags | set_flags) & ~rem_flags; --- 318,327 ---- return 0; } ! if (opt) ! set_flags |= flag->flag, rem_flags &= ~flag->flag; ! else ! rem_flags |= flag->flag, set_flags &= ~flag->flag; ! if (!value[end-1]) ! break; } cmd->flags = (cmd->flags | set_flags) & ~rem_flags; *************** *** 438,455 **** if (flags & MODCMD_DISABLED) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MSG_COMMAND_DISABLED, cmd->name); return 0; } if ((flags & MODCMD_REQUIRE_QUALIFIED) && !(options & SVCCMD_QUALIFIED)) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_MUST_QUALIFY, bot->nick, cmd->name, bot->nick); return 0; } if (flags & MODCMD_REQUIRE_AUTHED) { if (!user->handle_info) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MSG_AUTHENTICATE); return 0; } if (HANDLE_FLAGGED(user->handle_info, SUSPENDED)) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_ACCOUNT_SUSPENDED); return 0; } --- 444,465 ---- if (flags & MODCMD_DISABLED) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MSG_COMMAND_DISABLED, cmd->name); return 0; } if ((flags & MODCMD_REQUIRE_QUALIFIED) && !(options & SVCCMD_QUALIFIED)) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MCMSG_MUST_QUALIFY, bot->nick, cmd->name, bot->nick); return 0; } if (flags & MODCMD_REQUIRE_AUTHED) { if (!user->handle_info) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MSG_AUTHENTICATE); return 0; } if (HANDLE_FLAGGED(user->handle_info, SUSPENDED)) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MCMSG_ACCOUNT_SUSPENDED); return 0; } *************** *** 457,471 **** if (channel || (options & SVCCMD_NOISY)) { if ((flags & MODCMD_REQUIRE_CHANNEL) && !channel) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MSG_INVALID_CHANNEL); return 0; } if (flags & MODCMD_REQUIRE_REGCHAN) { if (!channel->channel_info) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_CHAN_NOT_REGISTERED, channel->name); return 0; } else if (IsSuspended(channel->channel_info) && !(flags & MODCMD_IGNORE_CSUSPEND)) { /* allow security-override users to always ignore channel suspensions, but flag it as a staff command */ if (!user->handle_info || !HANDLE_FLAGGED(user->handle_info, HELPING)) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_CHAN_SUSPENDED, channel->name, channel->channel_info->suspended->reason); return 0; } --- 467,484 ---- if (channel || (options & SVCCMD_NOISY)) { if ((flags & MODCMD_REQUIRE_CHANNEL) && !channel) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MSG_INVALID_CHANNEL); return 0; } if (flags & MODCMD_REQUIRE_REGCHAN) { if (!channel->channel_info) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MCMSG_CHAN_NOT_REGISTERED, channel->name); return 0; } else if (IsSuspended(channel->channel_info) && !(flags & MODCMD_IGNORE_CSUSPEND)) { /* allow security-override users to always ignore channel suspensions, but flag it as a staff command */ if (!user->handle_info || !HANDLE_FLAGGED(user->handle_info, HELPING)) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MCMSG_CHAN_SUSPENDED, channel->name, channel->channel_info->suspended->reason); return 0; } *************** *** 474,493 **** } if (flags & MODCMD_REQUIRE_CHANUSER) { ! if (!uData_checked) uData = _GetChannelUser(channel->channel_info, user->handle_info, 1, 0), uData_checked = 1; if (!uData) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_NO_CHANNEL_ACCESS, channel->name); return 0; } else if (uData->access < cmd->min_channel_access) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_LOW_CHANNEL_ACCESS, channel->name); return 0; } } if ((flags & MODCMD_REQUIRE_JOINABLE) && channel) { ! if (!uData_checked) uData = _GetChannelUser(channel->channel_info, user->handle_info, 1, 0), uData_checked = 1; if ((channel->modes & (MODE_INVITEONLY|MODE_KEY|MODE_SECRET)) && !uData && !IsService(user) && !GetUserMode(channel, user)) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_REQUIRES_JOINABLE, channel->name); return 0; } --- 487,511 ---- } if (flags & MODCMD_REQUIRE_CHANUSER) { ! if (!uData_checked) ! uData = _GetChannelUser(channel->channel_info, user->handle_info, 1, 0), uData_checked = 1; if (!uData) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MCMSG_NO_CHANNEL_ACCESS, channel->name); return 0; } else if (uData->access < cmd->min_channel_access) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MCMSG_LOW_CHANNEL_ACCESS, channel->name); return 0; } } if ((flags & MODCMD_REQUIRE_JOINABLE) && channel) { ! if (!uData_checked) ! uData = _GetChannelUser(channel->channel_info, user->handle_info, 1, 0), uData_checked = 1; if ((channel->modes & (MODE_INVITEONLY|MODE_KEY|MODE_SECRET)) && !uData && !IsService(user) && !GetUserMode(channel, user)) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MCMSG_REQUIRES_JOINABLE, channel->name); return 0; } *************** *** 497,501 **** switch (opt) { case 'd': ! if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_TOYS_DISABLED, channel->name); return 0; case 'n': --- 515,520 ---- switch (opt) { case 'd': ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MCMSG_TOYS_DISABLED, channel->name); return 0; case 'n': *************** *** 513,518 **** char pubcmd = channel->channel_info->options[optPubCmd]; int prohibit = 0; ! if (!uData_checked) uData = _GetChannelUser(channel->channel_info, user->handle_info, 1, 0), uData_checked = 1; ! if (uData) { switch (pubcmd) { case 'p': prohibit = uData->access < ulPeon; break; --- 532,538 ---- char pubcmd = channel->channel_info->options[optPubCmd]; int prohibit = 0; ! if (!uData_checked) ! uData = _GetChannelUser(channel->channel_info, user->handle_info, 1, 0), uData_checked = 1; ! if (uData) switch (pubcmd) { case 'p': prohibit = uData->access < ulPeon; break; *************** *** 523,529 **** case 'n': prohibit = uData->access < ulHelper; break; } ! } else prohibit = 1; if (prohibit) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_PUBLIC_DENY, channel->name); return 0; } --- 543,551 ---- case 'n': prohibit = uData->access < ulHelper; break; } ! else ! prohibit = 1; if (prohibit) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MCMSG_PUBLIC_DENY, channel->name); return 0; } *************** *** 536,545 **** rflags |= ACTION_STAFF; } else { ! if (options & SVCCMD_NOISY) send_message(user, bot, MSG_COMMAND_PRIVILEGED, cmd->name); return 0; } } if ((flags & MODCMD_REQUIRE_HELPING) && !HANDLE_FLAGGED(user->handle_info, HELPING)) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MCMSG_MUST_BE_HELPING); return 0; } --- 558,569 ---- rflags |= ACTION_STAFF; } else { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MSG_COMMAND_PRIVILEGED, cmd->name); return 0; } } if ((flags & MODCMD_REQUIRE_HELPING) && !HANDLE_FLAGGED(user->handle_info, HELPING)) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MCMSG_MUST_BE_HELPING); return 0; } *************** *** 550,554 **** if (cmd->req_account_flags || cmd->deny_account_flags) { if (!user->handle_info) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MSG_AUTHENTICATE); return 0; } --- 574,579 ---- if (cmd->req_account_flags || cmd->deny_account_flags) { if (!user->handle_info) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MSG_AUTHENTICATE); return 0; } *************** *** 556,565 **** if ((cmd->req_account_flags & ~user->handle_info->flags) || (cmd->deny_account_flags & user->handle_info->flags)) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MSG_COMMAND_PRIVILEGED, cmd->name); return 0; } } if ((options & SVCCMD_DEBIT) && !policer_conforms(&user->command_policer, now, cmd->weight)) { ! if (options & SVCCMD_NOISY) send_message(user, bot, MSG_COMMAND_FLOOD); return 0; } --- 581,592 ---- if ((cmd->req_account_flags & ~user->handle_info->flags) || (cmd->deny_account_flags & user->handle_info->flags)) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MSG_COMMAND_PRIVILEGED, cmd->name); return 0; } } if ((options & SVCCMD_DEBIT) && !policer_conforms(&user->command_policer, now, cmd->weight)) { ! if (options & SVCCMD_NOISY) ! send_message(user, bot, MSG_COMMAND_FLOOD); return 0; } *************** *** 610,621 **** return 0; } ! if(ubound >= old_argc) { ubound = old_argc - 1; ! } ! if(lbound < old_argc) { ! for (jj = lbound; jj <= ubound; ) { new_argv[new_argc++] = old_argv[jj++]; - } - } } else { log_module(MAIN_LOG, LOG_ERROR, "Alias expansion: I do not know how to handle %s (%s.%s arg %d).", arg, cmd->parent->bot->nick, cmd->name, ii); --- 637,645 ---- return 0; } ! if (ubound >= old_argc) ubound = old_argc - 1; ! if (lbound < old_argc) ! for (jj = lbound; jj <= ubound; ) new_argv[new_argc++] = old_argv[jj++]; } else { log_module(MAIN_LOG, LOG_ERROR, "Alias expansion: I do not know how to handle %s (%s.%s arg %d).", arg, cmd->parent->bot->nick, cmd->name, ii); *************** *** 767,777 **** unsigned int ii; struct module *module; ! if (!topic) topic = "<index>"; for (ii = 0; ii < service->modules.used; ++ii) { module = service->modules.list[ii]; ! if (!module->helpfile) continue; ! if (dict_find(module->helpfile->db, topic, NULL)) { return send_help(user, service->bot, module->helpfile, topic); - } } send_message(user, service->bot, MSG_TOPIC_UNKNOWN); --- 791,802 ---- unsigned int ii; struct module *module; ! if (!topic) ! topic = "<index>"; for (ii = 0; ii < service->modules.used; ++ii) { module = service->modules.list[ii]; ! if (!module->helpfile) ! continue; ! if (dict_find(module->helpfile->db, topic, NULL)) return send_help(user, service->bot, module->helpfile, topic); } send_message(user, service->bot, MSG_TOPIC_UNKNOWN); *************** *** 785,791 **** unsigned char *argv[MAXNUMPARAMS]; ! if (!*text) { return 0; - } if (service->privileged) { if (!IsOper(user)) { --- 810,815 ---- unsigned char *argv[MAXNUMPARAMS]; ! if (!*text) return 0; if (service->privileged) { if (!IsOper(user)) { *************** *** 907,918 **** strtoul(argv[arg]+1, &end_num, 10); switch (end_num[0]) { ! case 0: continue; case '-': ! if (end_num[1] == 0) continue; ! else if (isdigit(end_num[1])) continue; /* else fall through to default case */ ! default: return arg; } ! } else return arg; } return arg; --- 931,947 ---- strtoul(argv[arg]+1, &end_num, 10); switch (end_num[0]) { ! case 0: ! continue; case '-': ! if (end_num[1] == 0) ! continue; ! else if (isdigit(end_num[1])) ! continue; /* else fall through to default case */ ! default: ! return arg; } ! } else ! return arg; } return arg; *************** *** 1644,1655 **** return 0; } - if (service->trigger) reg_chanmsg_func(service->trigger, NULL, NULL); if (argc < 3) { ! reply(MCMSG_REMOVED_TRIGGER, service->bot->nick); ! return 1; } - service->trigger = argv[2][0]; - reg_chanmsg_func(service->trigger, service->bot, modcmd_chanmsg); - reply(MCMSG_NEW_TRIGGER, service->bot->nick, service->trigger); return 1; } --- 1673,1689 ---- return 0; } if (argc < 3) { ! reply(MCMSG_CURRENT_TRIGGER, service->bot->nick, service->trigger); ! } else { ! if (service->trigger) ! reg_chanmsg_func(service->trigger, NULL, NULL); ! if (!irccasecmp(argv[2], "none") || !irccasecmp(argv[2], "remove")) { ! reply(MCMSG_REMOVED_TRIGGER, service->bot->nick); ! } else { ! service->trigger = argv[2][0]; ! reg_chanmsg_func(service->trigger, service->bot, modcmd_chanmsg); ! reply(MCMSG_NEW_TRIGGER, service->bot->nick, service->trigger); ! } } return 1; } *************** *** 2023,2032 **** for (ii = 0; def_binds[ii].svcname; ++ii) { sprintf(buf, "services/%s/nick", def_binds[ii].svcname); ! if (!(nick = conf_get_data(buf, RECDB_QSTRING))) continue; ! if (!(service = service_find(nick))) 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); } --- 2057,2070 ---- for (ii = 0; def_binds[ii].svcname; ++ii) { sprintf(buf, "services/%s/nick", def_binds[ii].svcname); ! if (!(nick = conf_get_data(buf, RECDB_QSTRING))) ! continue; ! if (!(service = service_find(nick))) ! 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); } *************** *** 2066,2082 **** struct module *module; ! if (!(db = parse_database("aliases.db"))) return; for (it = dict_first(db); it; it = iter_next(it)) { service = service_find(iter_key(it)); ! if (!service) continue; module = module_find(service->bot->nick); rd = iter_data(it); ! if (rd->type != RECDB_OBJECT) continue; for (it2 = dict_first(rd->d.object); it2; it2 = iter_next(it2)) { struct modcmd *command; rd2 = iter_data(it2); ! if (rd2->type != RECDB_QSTRING) continue; command = dict_find(module->commands, rd2->d.qstring, NULL); ! if (!command) continue; service_bind_modcmd(service, command, iter_key(it2)); } --- 2104,2125 ---- struct module *module; ! if (!(db = parse_database("aliases.db"))) ! return; for (it = dict_first(db); it; it = iter_next(it)) { service = service_find(iter_key(it)); ! if (!service) ! continue; module = module_find(service->bot->nick); rd = iter_data(it); ! if (rd->type != RECDB_OBJECT) ! continue; for (it2 = dict_first(rd->d.object); it2; it2 = iter_next(it2)) { struct modcmd *command; rd2 = iter_data(it2); ! if (rd2->type != RECDB_QSTRING) ! continue; command = dict_find(module->commands, rd2->d.qstring, NULL); ! if (!command) ! continue; service_bind_modcmd(service, command, iter_key(it2)); } Index: modcmd.help =================================================================== RCS file: /cvsroot/srvx/services/src/modcmd.help,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -r1.10 -r1.11 *** modcmd.help 12 Jul 2003 03:48:37 -0000 1.10 --- modcmd.help 26 Sep 2003 15:27:17 -0000 1.11 *************** *** 73,74 **** --- 73,88 ---- "With a list of modules, sets the order that the service will look up non-command help entries.", "$uSee Also:$u bind, unbind"); + "service add" ("/msg $S SERVICE ADD <nick> <description>", + "Creates a new service bot.", + "$uSee Also:$u service rename, service trigger, service remove"); + "service rename" ("/msg $S SERVICE RENAME <oldnick> <newnick>", + "Renames a service bot. Currently does not support the default services.", + "$uSee Also:$u service add, service trigger, service remove"); + "service trigger" ("/msg $S SERVICE TRIGGER <nick> [remove|<trigger>]", + "Sets or clears the trigger character that the named service uses to identify in-channel messages directed at it.", + "To remove a trigger, use the word $bremove$b (or $bnone$b) as the argument. Otherwise, the first letter of the argument will be used as the new trigger.", + "If no argument is given, shows the current trigger for the service.", + "$uSee Also:$u service add, service rename, service remove"); + "service remove" ("/msg $S SERVICE REMOVE <nick> [<quit reason>]", + "Destroys a service. If a default service is named, it will be recreated when srvx restarts.", + "$uSee Also:$u service add, service rename, service trigger"); |