Fix !resync; helpfile updates; improve ?modcmd
authorEntrope <entrope@clan-dk.org>
Thu, 11 Mar 2004 16:44:35 +0000 (16:44 +0000)
committerEntrope <entrope@clan-dk.org>
Thu, 11 Mar 2004 16:44:35 +0000 (16:44 +0000)
* Make ChanServ.RESYNC op (or voice) users when GiveOps (GiveVoice,
respectively) is 0 and the user is not on the userlist.

* Remove mention of PEONINVITE from chanserv.help.

* Mention the GIVEOWNERSHIP command in HelpServ's help file; remove
mention of the removed VERSION and WRITE commands.

* Make modcmd.MODCMD accept no options, and display the (final)
settings for the command.  Update the help entry for it.
git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-27

src/chanserv.c
src/chanserv.help
src/mod-helpserv.help
src/modcmd.c
src/modcmd.help

index ad857494e59b3df489796278ad4852388542c6fb..5cc98b41aadf9e68933d2a6dbf8e1f2fcf650418 100644 (file)
@@ -4036,19 +4036,22 @@ static CHANSERV_FUNC(cmd_resync)
     {
         struct modeNode *mn = channel->members.list[ii];
         struct userData *uData;
+
         if(IsService(mn->user))
+            continue;
+
+        uData = GetChannelAccess(cData, mn->user->handle_info);
+        if(!cData->lvlOpts[lvlGiveOps]
+           || (uData && uData->access >= cData->lvlOpts[lvlGiveOps]))
         {
-            /* must not change modes for this user */
-        }
-        else if(!(uData = GetChannelAccess(cData, mn->user->handle_info)))
-        {
-            if(mn->modes)
+            if(!(mn->modes & MODE_CHANOP))
             {
-                changes->args[used].mode = MODE_REMOVE | mn->modes;
+                changes->args[used].mode = MODE_CHANOP;
                 changes->args[used++].member = mn;
             }
         }
-        else if(uData->access < cData->lvlOpts[lvlGiveOps])
+        else if(!cData->lvlOpts[lvlGiveVoice]
+                || (uData && uData->access >= cData->lvlOpts[lvlGiveVoice]))
         {
             if(mn->modes & MODE_CHANOP)
             {
@@ -4063,9 +4066,9 @@ static CHANSERV_FUNC(cmd_resync)
         }
         else
         {
-            if(!(mn->modes & MODE_CHANOP))
+            if(mn->modes)
             {
-                changes->args[used].mode = MODE_CHANOP;
+                changes->args[used].mode = MODE_REMOVE | mn->modes;
                 changes->args[used++].member = mn;
             }
         }
index e2b636ba6fe846450fadd4ccfb2be81e8eab7262..7d3229ecc26fdae32741ac5682114c47ded0b1c7 100644 (file)
        "TOYS:         Toggles how $b$C$b will respond to toy commands (!8ball etc).",
         "TOPICREFRESH: Controls if (and how often) $b$C$b will reset the topic.",
         "DYNLIMIT:     Adjusts user limit (+l channel mode) to prevent join floods.",
-        "PEONINVITE:   Indicates whether peons may use the $bINVITEME$b command.",
         "$bIRCOP ONLY$b:",
         "NODELETE:  Prevents channel deletion.",
         "If you wish to reset your channel to the default settings, you can use the $bSET DEFAULTS$b command.",
index edc7dac12ef383502029bf5ad6ac32dedaed628d..a695da14d52ef9017daaf4c78af45d9dfb2f8b2a 100644 (file)
@@ -18,6 +18,7 @@
 "USERS" ("Managing helpers in $S",
         "  USER ACCESS Description of the user access levels",
         "  HELPERS     List current helpers and their access levels",
+        "  GIVEOWNERSHIP Transfer ownership to another user",
         "  ADDMANAGER  Add a new manager to the service",
         "  ADDHELPER   Add a helper to the service",
         "  ADDTRIAL    Add a trial helper to the service",
@@ -38,9 +39,7 @@
         "  UNREGISTER  Unregister a HelpServ bot",
         "  BOTS        List registered HelpServ instances",
         "  EXPIRE      Expire inactive channels",
-        "  VERSION     Show version of HelpServ",
-        "  READHELP    Re-read help file",
-        "  WRITE       Write out database");
+        "  READHELP    Re-read help file");
 "COMMANDS" "${index}";
 
 "ADDTRIAL" ("$bADDTRIAL$b",
@@ -93,7 +92,6 @@
         "/msg $S HELP [command|topic]",
         "HELP will show you usage or other information for the command you give.",
         "All help entries will use the same syntax for usage, with optional parameters listed in [] and meta-parameters listed in <> (a meta-parameter is one that you must provide a value for).",
-        "For example, \"/msg $S VERSION [CVS]\" means that you may send either \"VERSION\" or \"VERSION CVS\" as a command; \"/msg $S HELP [<command>]\" means that you may send \"HELP\" alone, or fill in the name of a command, as in \"HELP VERSION\".",
         "If you do not give a command or topic for HELP, an index is shown.");
 "HELPERS" ("$bHELPERS$b",
         "/msg $S HELPERS",
 "UNREGISTER" ("$bUNREGISTER$b",
         "/msg $S UNREGISTER CONFIRM",
         "Unregisters the channel and removes the service from the channel.");
-"VERSION" ("$bVERSION$b",
-        "/msg $S VERSION [CVS]",
-        "This tells you the version of srvx this bot is part of.",
-        "If you give the \"CVS\" argument, the source-code revision of $S is also shown.");
-"WRITE" ("$bWRITE$b",
-        "/msg $O HELPSERV WRITE",
-        "Saves all HelpServ bot data to the disk database.");
index f8d02055abfe142f01ca49ddd16b801d23209094..a61e097793fe1efffa63b51fbe8c43d7f1fae928 100644 (file)
@@ -120,6 +120,10 @@ static const struct message_entry msgtab[] = {
     { "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_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);
@@ -1300,6 +1304,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;
@@ -1307,7 +1359,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;
     }
@@ -1315,16 +1367,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;
 }
 
@@ -1963,7 +2014,7 @@ modcmd_init(void) {
     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, "oper_level", "650", NULL);
     modcmd_register(modcmd_module, "timecmd", cmd_timecmd, 2, 0, "oper_level", "1", NULL);
index e3da2aa896dc32e225047b72012a393c5f193471..116a3d755b1ef82a3132ed0260fae3133f08d226 100644 (file)
         "Reports how long it takes to run the specified command.");
 "command" ("/msg $S COMMAND <command>", 
         "Shows the restrictions on who can use the named command (and how).");
-"modcmd" ("/msg $S MODCMD <command> <option> <newval> [additional option/value pairs..]",
-        "Changes the named option(s) for the specified command.  The command name may be prefixed with $bServiceNick.$b to specify another service's command (for example, $N.AUTH to refer to the auth command).",
+"modcmd" ("/msg $S MODCMD <command> [<option> <newval> ...]",
+        "Displays options for the specified command, or changes the options and values listed.  The command name may be prefixed with $bServiceNick.$b to specify another service's command (for example, $N.AUTH to refer to the auth command).",
         "Supported options are:",
         "  FLAGS          Comma-separated, +/- prefixed list of flags to add or remove.",
         "  CHANNEL_ACCESS Minimum ChanServ access.",
         "  OPER_ACCESS    Minimum OpServ access.",
-        "  ACCESS         Alias for OPER_ACCESS (if the value starts with a digit) or CHANNEL_ACCESS (if the value does not start with a digit).",
         "  ACCOUNT_FLAGS  Account flags to require or deny (for example, +R-S)",
-        "  TEMPLATE       Command from which to inherit access restrictions",
-        "  WEIGHT         How much the command counts against the anti-flood policer",
-        "See the $bmodcmd flags$b entry for a list of supported flags.");
+        "See the $bmodcmd flags$b help entry for a list of supported flags.");
 "modcmd flags" ("The following flags are supported for commands:",
         "  ACCEPTCHAN     Treat a normal channel name (if specified) as the context for the command",
         "  ACCEPTPLUSCHAN Accept modeless channel names as well as normal channel names",