Răsfoiți Sursa

* Added hub cmd 'checkchannels' which displays in loglevel misc (+o) which chans leaf bots aren't on. (#149)

svn: 2387
Bryan Drewery 21 ani în urmă
părinte
comite
7b107f9bba
4 a modificat fișierele cu 36 adăugiri și 1 ștergeri
  1. 1 0
      doc/UPDATES
  2. 8 1
      misc/help.txt
  3. 16 0
      src/mod/channels.mod/channels.c
  4. 11 0
      src/mod/channels.mod/cmdschan.c

+ 1 - 0
doc/UPDATES

@@ -21,6 +21,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Fixed hubs not correctly installing/checking crontab on startup. (#156)
 * Fixed hub segfaults (on Linux) with bot links. (#155)
 * Removing an ignore by number now displays which ignore was removed. (#126)
+* Added hub cmd 'checkchannels' which displays in loglevel misc (+o) which chans leaf bots aren't on. (#149)
 
 1.2.7
 * Forgot 'log_bad = 0;' to fix the '!' showing up for aliases.

+ 8 - 1
misc/help.txt

@@ -253,7 +253,7 @@ See also: -ban, +ban, console%{+m|m}, chanset, chaninfo%{-}, stick, unstick
    Just using '&' for 'bot' will do the cmd on all localhub bots. (first bot in config).
  
    This cmd cannot be chained over the botnet, ie, no: .botcmd [bot] botcmd [bot2] ...
-
+ 
    There are two default aliases added for this cmd:
      bc -> botcmd
      bl -> botcmd ?
@@ -616,6 +616,13 @@ See also: console
           You must remove the permanent owner in the binary.
  
 See also: whois
+:hub:checkchannels
+###  $bcheckchannels$b
+   This will make all leaf bots display which channels they are currently
+   not in but *should* be in.  This command will not show channels which
+   the bot is not active in due to '$bbotpart$b'.
+ 
+See also: botcmd, channels, channel, status
 :hub:chhandle
 ###  $bchhandle$b <oldhandle> <newhandle>
    Changes the handle of a user. For example, to change the handle of user

+ 16 - 0
src/mod/channels.mod/channels.c

@@ -183,6 +183,21 @@ static void got_cpart(char *botnick, char *code, char *par)
     write_userfile(-1);
 }
 
+static void got_chans(char *botnick, char *code, char *par)
+{
+  struct chanset_t *chan = NULL;
+  char buf[1024] = "";
+
+  for (chan = chanset; chan; chan = chan->next) {
+    if (shouldjoin(chan) && !channel_active(chan)) {
+      simple_snprintf(buf, sizeof(buf), "%s%s%s", buf[0] ? buf : "", buf[0] ? " " : "", chan->dname);
+    }
+  }
+
+  if (buf[0])
+    putlog(LOG_MISC, "*", "I am not in: %s", buf);
+}
+
 static void got_cjoin(char *botnick, char *code, char *par)
 {
   if (!par[0])
@@ -865,6 +880,7 @@ void channels_report(int idx, int details)
 }
 
 cmd_t channels_bot[] = {
+  {"chans",	"",	(Function) got_chans,	NULL, LEAF},
   {"cjoin",	"", 	(Function) got_cjoin, 	NULL, 0},
   {"cpart",	"", 	(Function) got_cpart, 	NULL, 0},
   {"cset",	"", 	(Function) got_cset,  	NULL, 0},

+ 11 - 0
src/mod/channels.mod/cmdschan.c

@@ -492,6 +492,16 @@ static void cmd_chinfo(int idx, char *par)
   }
 }
 
+static void cmd_checkchannels(int idx, char *par)
+{
+  char buf[6] = "";
+
+  putlog(LOG_CMDS, "*", "#%s# checkchannels", dcc[idx].nick);
+
+  simple_snprintf(buf, sizeof(buf), "chans");
+  putallbots(buf);
+}
+
 static void cmd_slowjoin(int idx, char *par)
 {
   int intvl = 0, delay = 0, count = 1;
@@ -1352,6 +1362,7 @@ static cmd_t C_dcc_channels[] =
   {"cycle", 	"n|n",	(Function) cmd_cycle,		NULL, 0},
   {"down",	"n|n",	(Function) cmd_down,		NULL, 0},
   {"info",	"",	(Function) cmd_info,		NULL, 0},
+  {"checkchannels", "n",    (Function) cmd_checkchannels,	NULL, HUB},
   {"slowjoin",  "n",    (Function) cmd_slowjoin,	NULL, 0},
   {"slowpart",  "n|n",  (Function) cmd_slowpart,  	NULL, 0},
   {"stick",	"o|o",	(Function) cmd_stick,		NULL, AUTH},