Browse Source

Add cmd_roles

Bryan Drewery 12 years ago
parent
commit
0f27316fdb
3 changed files with 52 additions and 4 deletions
  1. 2 0
      doc/UPDATES
  2. 26 4
      doc/help.txt
  3. 24 0
      src/mod/irc.mod/cmdsirc.c

+ 2 - 0
doc/UPDATES

@@ -1,3 +1,5 @@
+* Add cmd_roles (leaf only) to display roles for a channel.
+
 maint
 maint
   * Read in /etc/hosts on startup
   * Read in /etc/hosts on startup
   * Fix 'bl %group cmd' giving incorrect message when group/bots not found.
   * Fix 'bl %group cmd' giving incorrect message when group/bots not found.

+ 26 - 4
doc/help.txt

@@ -1089,7 +1089,7 @@ See also: console, channels%{+m}, status%{-}
 :hub:groups
 :hub:groups
 ###  $bgroups$b [bot]
 ###  $bgroups$b [bot]
    Shows the list of groups and which bots are in them.
    Shows the list of groups and which bots are in them.
-
+ 
    Specify a bot to only show which groups it is in.
    Specify a bot to only show which groups it is in.
  
  
 See also: bots, downbots%{+n}, bottree%{-}
 See also: bots, downbots%{+n}, bottree%{-}
@@ -1608,6 +1608,28 @@ See also: resetbans, resetinvites
    Makes the bot restart, but keeps its connection to IRC active.
    Makes the bot restart, but keeps its connection to IRC active.
  
  
 See also: rehash, reload, save
 See also: rehash, reload, save
+:leaf:roles
+###  $broles$b [channel]
+   Displays which bots are fullfilling which roles for a channel.
+ 
+   Some roles replace older botflags. See '%dhelp whois' for more
+   information.
+ 
+   $bRole$b         $bFlag$b     $bDescription$b
+   voice        y        Voice any +v users and handle +voice.
+   flood        f        Handle channel flood controls.
+   op           y        Auto-op +O users and handle autoop.
+   deop                  Deop clients on +bitch or +revenge needs.
+   kick                  Kick clients on +bitch, +revenge or +k needs.
+   ban                   Kick clients on +bitch, +revenge or +k needs.
+   topic                 Set the topic as needed for topic protect.
+   limit        l        Handle automatically raising limit as needed.
+   resolv       r        DNS all clients to look for ban/op matching.
+   revenge               React to +revenge needs.
+   chanmode              Set channel protect modes as needed.
+   protect               Handle +protect needs.
+ 
+See also: whois%{+m|m}, chanset, chaninfo%{-}
 :hub:save
 :hub:save
 ###  $bsave$b
 ###  $bsave$b
    This makes the bot write its entire userfile to disk. This is useful if you
    This makes the bot write its entire userfile to disk. This is useful if you
@@ -1718,10 +1740,10 @@ See also: reload, backup
                          known users. Note that this will break msg-ident.
                          known users. Note that this will break msg-ident.
 [B]  $bfish-auto-keyx$b      Whether to automatically do a DH1010 FiSH Key exchange when
 [B]  $bfish-auto-keyx$b      Whether to automatically do a DH1010 FiSH Key exchange when
                          accepting users. This is only supported if using callerid.
                          accepting users. This is only supported if using callerid.
-
+ 
 [B]  $bfish-paranoid$b       Whether to automatically re-keyexchange after every message. This
 [B]  $bfish-paranoid$b       Whether to automatically re-keyexchange after every message. This
                          mitigates replay attacks.
                          mitigates replay attacks.
-
+ 
 [S]  $baltchars$b            Define string of characters to cycle when generating alternative
 [S]  $baltchars$b            Define string of characters to cycle when generating alternative
                          nicks when nick is taken. Ie: _-`[].
                          nicks when nick is taken. Ie: _-`[].
 [S]  $bjupenick$b            The bot will attempt to jupe this nick. It will never use a variation
 [S]  $bjupenick$b            The bot will attempt to jupe this nick. It will never use a variation
@@ -1909,7 +1931,7 @@ See also: find
 ###  $btopic$b [channel] [new topic]
 ###  $btopic$b [channel] [new topic]
    Changes the channel's topic, assuming the bot is a chanop or the
    Changes the channel's topic, assuming the bot is a chanop or the
    channel is not +t (uses your current console channel).
    channel is not +t (uses your current console channel).
-
+ 
    If no chanel is specified, the console channel is used.
    If no chanel is specified, the console channel is used.
    If no new topic is specified, the current topic of the channel will be displayed.
    If no new topic is specified, the current topic of the channel will be displayed.
  
  

+ 24 - 0
src/mod/irc.mod/cmdsirc.c

@@ -1421,6 +1421,29 @@ static void cmd_authed(int idx, char *par)
   Auth::TellAuthed(idx);
   Auth::TellAuthed(idx);
 }
 }
 
 
+static void cmd_roles(int idx, char *par)
+{
+  struct chanset_t* chan = NULL;
+  size_t roleidx;
+  int role;
+
+  chan = get_channel(idx, par);
+  if (!chan) {
+    return;
+  }
+
+  putlog(LOG_CMDS, "*", "#%s# (%s) roles", dcc[idx].nick, chan->dname);
+
+  dprintf(idx, "Roles for %s:\n", chan->dname);
+
+  /* Advertise roles */
+  for (roleidx = 0; role_counts[roleidx].name; roleidx++) {
+    role = role_counts[roleidx].role;
+    dprintf(idx, "  %-8s: %s\n", role_counts[roleidx].name,
+        static_cast<bd::String>((*chan->role_bots)[role].join(" ")).c_str());
+  }
+}
+
 static void cmd_channel(int idx, char *par)
 static void cmd_channel(int idx, char *par)
 {
 {
   struct chanset_t *chan = NULL;
   struct chanset_t *chan = NULL;
@@ -1972,6 +1995,7 @@ static cmd_t irc_dcc[] =
   {"resetbans",		"o|o",	 (Function) cmd_resetbans,	NULL, LEAF|AUTH},
   {"resetbans",		"o|o",	 (Function) cmd_resetbans,	NULL, LEAF|AUTH},
   {"resetexempts",	"o|o",	 (Function) cmd_resetexempts,	NULL, LEAF|AUTH},
   {"resetexempts",	"o|o",	 (Function) cmd_resetexempts,	NULL, LEAF|AUTH},
   {"resetinvites",	"o|o",	 (Function) cmd_resetinvites,	NULL, LEAF|AUTH},
   {"resetinvites",	"o|o",	 (Function) cmd_resetinvites,	NULL, LEAF|AUTH},
+  {"roles",		"o|o",	 (Function) cmd_roles,		NULL, LEAF},
   {"say",		"o|o",	 (Function) cmd_say,		NULL, LEAF},
   {"say",		"o|o",	 (Function) cmd_say,		NULL, LEAF},
   {"swhois",		"",	 (Function) cmd_swhois,		NULL, LEAF|AUTH},
   {"swhois",		"",	 (Function) cmd_swhois,		NULL, LEAF|AUTH},
   {"topic",		"o|o",	 (Function) cmd_topic,		NULL, LEAF|AUTH},
   {"topic",		"o|o",	 (Function) cmd_topic,		NULL, LEAF|AUTH},