Make !bans searching more flexible
authorMichael Poole <mdpoole@troilus.org>
Tue, 18 Jul 2006 02:48:32 +0000 (02:48 +0000)
committerMichael Poole <mdpoole@troilus.org>
Tue, 18 Jul 2006 02:48:32 +0000 (02:48 +0000)
src/chanserv.c (cmd_bans): Allow specifying a complete hostmask or a
    nickname when searching bans.

src/chanserv.help (BANS): Document the searching functions.
git-archimport-id: srvx@srvx.net--2006/srvx--devo--1.3--patch-19

ChangeLog
src/chanserv.c
src/chanserv.help

index bfeb9059a3d221d88c89ced449d83c58f87f94b7..922686c953d550f14e5cf367e6146b7f3232fe78 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,22 @@
 # arch-tag: automatic-ChangeLog--srvx@srvx.net--2006/srvx--devo--1.3
 #
 
+2006-07-18 02:48:32 GMT        Michael Poole <mdpoole@troilus.org>     patch-19
+
+    Summary:
+      Make !bans searching more flexible
+    Revision:
+      srvx--devo--1.3--patch-19
+
+    src/chanserv.c (cmd_bans): Allow specifying a complete hostmask or a
+        nickname when searching bans.
+    
+    src/chanserv.help (BANS): Document the searching functions.
+
+    modified files:
+     ChangeLog src/chanserv.c src/chanserv.help
+
+
 2006-07-18 01:49:56 GMT        Michael Poole <mdpoole@troilus.org>     patch-18
 
     Summary:
index bf6e3785f56d94c731ffcaa91d71d51aa5c2aa4a..0857d92033d12fcf8fd24cdb86f333efac60165c 100644 (file)
@@ -3592,23 +3592,37 @@ static CHANSERV_FUNC(cmd_plist)
 
 static CHANSERV_FUNC(cmd_bans)
 {
+    struct userNode *search_u = NULL;
     struct helpfile_table tbl;
-    unsigned int matches = 0, timed = 0, ii;
+    unsigned int matches = 0, timed = 0, search_wilds = 0, ii;
     char t_buffer[INTERVALLEN], e_buffer[INTERVALLEN], *search;
     const char *msg_never, *triggered, *expires;
     struct banData *ban, **bans;
 
-    if(argc > 1)
-       search = argv[1];
-    else
+    if(argc < 2)
         search = NULL;
+    else if(strchr(search = argv[1], '!'))
+    {
+       search = argv[1];
+        search_wilds = search[strcspn(search, "?*")];
+    }
+    else if(!(search_u = GetUserH(search)))
+        reply("MSG_NICK_UNKNOWN", search);
 
     bans = alloca(channel->channel_info->banCount * sizeof(struct banData *));
 
     for(ban = channel->channel_info->bans; ban; ban = ban->next)
     {
-       if(search && !match_ircglobs(search, ban->mask))
-           continue;
+        if(search_u)
+        {
+            if(!user_matches_glob(search_u, ban->mask, MATCH_USENICK | MATCH_VISIBLE))
+                continue;
+        }
+       else if(search)
+        {
+            if(search_wilds ? !match_ircglobs(search, ban->mask) : !match_ircglob(search, ban->mask))
+                continue;
+        }
        bans[matches++] = ban;
        if(ban->expires)
             timed = 1;
index 44a7937bfac36c01df5da5323710087e9d033a0f..1ace0a9cf1a2896f46a617ae9c762668367e912e 100644 (file)
@@ -56,7 +56,7 @@
         "  CLIST                coowners of a channel.",
         "  MLIST                masters of a channel.",
         "  OLIST                ops of a channel.",
-        "  PLIST                peons of a channel.",    
+        "  PLIST                peons of a channel.",
         "  BANS        List all the bans for a channel.",
         "  TOPIC       Set the current topic, or reset it to the default topic.",
         "  MODE        Change a channel mode.",
         "$uFor assistance, please join to #support$u",
         "Example: *!*serv@*.gamesurge.net would ban anyone with ident 'serv' and a gamesurge.net hostname from joining the channel.",
         "$uSee Also:$u unban, unbanall, unbanme");
-"BANS" ("/msg $C BANS <#channel>",
+"BANS" ("/msg $C BANS <#channel> [mask|nick]",
         "This command lists all permanent and timed bans in the channel.",
+        "If a nickname is specified, lists any bans that visibly match that user.",
+        "If a hostmask with no wildcards is specified, lists any bans that match that hostmask.",
+        "If a hostmask with wildcards is specified, lists any bans included in that mask.",
         "$uSee Also:$u addban, delban, mdelban");
 "CLIST" ("/msg $C CLIST <#channel> [mask]",
         "This command lists all users of level $bCoowner$b on a channel's userlist. If a mask is supplied, only coowners matching the mask will be shown.",