fix userlist presence tracking; "version" command on all services
authorEntrope <entrope@clan-dk.org>
Fri, 27 Feb 2004 16:31:57 +0000 (16:31 +0000)
committerEntrope <entrope@clan-dk.org>
Fri, 27 Feb 2004 16:31:57 +0000 (16:31 +0000)
* Change scan_handle_presence() to scan_user_presence(), since we always
  have the userData* at the caller site.

* Make handle_auth() respect user suspensions.

* In handle_part(), let scan_user_presence() update "seen" time.

* Make ChanServ adduser command take arguments in the "expected" order
  ("!adduser target level", not "!adduser level target")

* Add the "version" command to all built-in services
git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-7

TODO
src/chanserv.c
src/chanserv.help
src/modcmd.c

diff --git a/TODO b/TODO
index 6c9b1c6cadc310dd5e17af3f400f68d71031e736..8c9bb50d809b0d7f95afb5457eaf10a8117c0859 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,5 +1,3 @@
----------
-
 <myriad> [featreq] something to turn off security override after a set period of time
 <adam> [featreq] an account flag that disallows users from using /ns kill (or some other way to prevent/deter nick holding on an account-level)
 <Byte> [featreq] people cant !invite over a timeban
@@ -8,8 +6,6 @@
 [adam(m@myriad.lackofdiscipline.com)] we're having people grab nicks of other users who don't understand how the system works
 [msg(adam)] yeah, blocking account or nick registrations for an address (or block of addresses) was another featreq on the web page
 
----------
-
 [FEATREQ] Confirmation Of Channel Registration
   <ChanServ> #Rowdy is now registered under handle Rowdy
   <ChanServ> Please note, If you do not actively use this channel for 14 days, it will be deregistered
 [FEATREQ] Suspension durations and/or comments when suspending user access to a channel
 
 [FEATREQ] support "unregistered": ?ctrace print mode +s unregistered
+
+[FEATREQ] runtime construction of nickserv.help, rather than compile time
+  - Can do something like this:
+    "<INDEX>" {
+        "/services/nickserv/disable_nicks:false and /services/nickserv/email_enabled:false" ( "Help content with nick ownership enabled and email disabled" );
+        // etc
+    };
+  - Need a mini-language interpreter for the logic blocks; should skip
+    leading "[0-9A-Za-z]+: " prefix to allow sorting the entries by
+    priority
index 19ece49ba99b118370cfbbf89aa23fc84721ef7d..a481a9e5507e1aaf3ec9fb45b34690f7143ed4e6 100644 (file)
@@ -747,25 +747,20 @@ int check_user_level(struct chanNode *channel, struct userNode *user, enum level
    user is optional, if not null, it skips checking that userNode
    (for the handle_part function) */
 static void
-scan_handle_presence(struct chanNode *channel, struct handle_info *handle, struct userNode *user)
+scan_user_presence(struct userData *uData, struct userNode *user)
 {
-    struct userData *uData;
-
-    if(!channel->channel_info || IsSuspended(channel->channel_info))
-        return;
+    struct modeNode *mn;
 
-    uData = GetTrueChannelAccess(channel->channel_info, handle);
-    if(uData)
+    if(IsSuspended(uData->channel)
+       || IsUserSuspended(uData)
+       || !(mn = find_handle_in_channel(uData->channel->channel, uData->handle, user)))
     {
-        struct modeNode *mn = find_handle_in_channel(channel, handle, user);
-
-       if(mn)
-       {
-           uData->present = 1;
-           uData->seen = now;
-       }
-       else
-           uData->present = 0;
+        uData->present = 0;
+    }
+    else
+    {
+        uData->present = 1;
+        uData->seen = now;
     }
 }
 
@@ -1723,8 +1718,7 @@ static CHANSERV_FUNC(cmd_register)
         channel = AddChannel(argv[1], now, NULL, NULL);
 
     cData = register_channel(channel, user->handle_info->handle);
-    add_channel_user(cData, handle, UL_OWNER, 0, NULL);
-    scan_handle_presence(channel, handle, NULL);
+    scan_user_presence(add_channel_user(cData, handle, UL_OWNER, 0, NULL), NULL);
     cData->modes = chanserv_conf.default_modes;
     change = mod_chanmode_dup(&cData->modes, 1);
     change->args[change->argc].mode = MODE_CHANOP;
@@ -2163,10 +2157,10 @@ static CHANSERV_FUNC(cmd_adduser)
        return 0;
     }
 
-    access = user_level_from_name(argv[1], UL_OWNER);
+    access = user_level_from_name(argv[2], UL_OWNER);
     if(!access)
     {
-       reply("CSMSG_INVALID_ACCESS", argv[1]);
+       reply("CSMSG_INVALID_ACCESS", argv[2]);
        return 0;
     }
 
@@ -2177,7 +2171,7 @@ static CHANSERV_FUNC(cmd_adduser)
        return 0;
     }
 
-    if(!(handle = modcmd_get_handle_info(user, argv[2])))
+    if(!(handle = modcmd_get_handle_info(user, argv[1])))
         return 0;
 
     if((actee = GetTrueChannelAccess(channel->channel_info, handle)))
@@ -2187,7 +2181,7 @@ static CHANSERV_FUNC(cmd_adduser)
     }
 
     actee = add_channel_user(channel->channel_info, handle, access, 0, NULL);
-    scan_handle_presence(channel, handle, NULL);
+    scan_user_presence(actee, NULL);
     reply("CSMSG_ADDED_USER", handle->handle, channel->name, access);
     return 1;
 }
@@ -5818,7 +5812,9 @@ handle_auth(struct userNode *user, UNUSED_ARG(struct handle_info *old_handle))
     {
         struct chanNode *cn;
         struct modeNode *mn;
-        if(IsSuspended(channel->channel) || !(cn = channel->channel->channel))
+        if(IsUserSuspended(channel)
+           || IsSuspended(channel->channel)
+           || !(cn = channel->channel->channel))
             continue;
 
         mn = GetUserMode(cn, user);
@@ -5895,10 +5891,10 @@ handle_part(struct userNode *user, struct chanNode *channel, UNUSED_ARG(const ch
 {
     struct chanData *cData;
     struct userData *uData;
-    struct handle_info *handle;
 
     cData = channel->channel_info;
-    if(!cData || IsSuspended(cData) || IsLocal(user)) return;
+    if(!cData || IsSuspended(cData) || IsLocal(user))
+        return;
 
     if((cData->flags & CHANNEL_DYNAMIC_LIMIT) && !channel->join_flooded)
     {
@@ -5911,11 +5907,8 @@ handle_part(struct userNode *user, struct chanNode *channel, UNUSED_ARG(const ch
        }
     }
 
-    if((handle = user->handle_info) && (uData = GetTrueChannelAccess(cData, handle)))
-    {
-       uData->seen = now;
-       scan_handle_presence(channel, handle, user);
-    }
+    if((uData = GetTrueChannelAccess(cData, user->handle_info)))
+       scan_user_presence(uData, user);
 
     if(IsHelping(user) && IsSupportHelper(user))
     {
index ecd9c59d6c697e617d3f0076dafe8f53109fe6c4..1e9ccd030d4f9c3f15e64a87d010c05b14a0708d 100644 (file)
 "ADDBAN" ("/msg $C ADDBAN <#channel> <mask|nick> [Reason]",
         "Adds a ban to the channels permanent ban list, remaining in effect until removed with the DELBAN command. If it exactly matches an existing ban already in the list, the reason will be updated. If the existing ban was a timed ban, it will be extended into a permanent ban.",
         "$uSee Also:$u bans, delban, mdelban");
-"ADDUSER" ("/msg $C ADDUSER <#channel> <level> <nick|*account>",
+"ADDUSER" ("/msg $C ADDUSER <#channel><nick|*account> <level>",
         "This command adds someone to the channel user list with the specified access level.  (You may only add users to levels less than your own.)",
-        "The level may be one of $bpeon$b, $bop$b, $bmaster$b, $bcoowner$b or $bowner$b (only network staff may add owners).",
+        "The level may be one of $bpeon$b, $bop$b, $bmaster$b, $bcoowner$b, $bowner$b, or a number between 1 and 500.  Only network staff may add level 500 users (owners).",
         "$uSee Also:$u deluser, users");
 "ADDTIMEDBAN" ("/msg $C ADDTIMEDBAN <#channel> <mask|nick> <Duration> [Reason]",
         "Adds an automatically expiring ban to the channel ban list. This command behaves in the exact same fashion as ADDBAN with the exception that the bans are automatically removed after the user-supplied duration. If it exactly matches an existing ban already in the list, the reason will be updated. If the existing ban was a timed ban, it will be extended. Timed bans can be removed with the DELBAN command, as with permanent bans.",
index 4dc89289deb292d47907e4b719eb8574660f44ef..01e392ba963c5e882bb5c053485d414ba20b90c5 100644 (file)
@@ -32,7 +32,7 @@ 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 -." },
@@ -1952,7 +1952,7 @@ modcmd_init(void) {
     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, "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);
 }
 
@@ -2146,21 +2146,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);