Просмотр исходного кода

* Added cmd_matchbot
cmd_match now does users only.
* cmd_whois now shows BOTNICK for bots and HANDLE for users.


svn: 1087

Bryan Drewery 22 лет назад
Родитель
Сommit
c974ef341b
5 измененных файлов с 54 добавлено и 21 удалено
  1. 2 0
      doc/UPDATES
  2. 11 6
      misc/help.txt
  3. 17 5
      src/cmds.c
  4. 23 9
      src/users.c
  5. 1 1
      src/users.h

+ 2 - 0
doc/UPDATES

@@ -35,6 +35,8 @@ This is a summary of ChangeLog basically.
 31.Detected promisc now shows which interface.
 32.Now using daemon(3) to fork into background.
 33.Possibly fixed a bug with bots dying on link.
+34.Bots no longer have userflag +b, they are distinguished in whois by BOTNICK instead of HANDLE.
+35.Added cmd_matchbot for matching bots, cmd_match now only does users.
 
 1.1.7
 

+ 11 - 6
misc/help.txt

@@ -1136,27 +1136,27 @@ See also: unlink, newleaf%{+a}, -bot%{-}
    "attr" is of the form:  <+/-><global>[&/|<channel>[&/|<bot>]]
    Specifying "&" as the separator will cause AND style matching.
    For example:
-      .match p&o
+      %dmatch p&o
    This will match all users with both the "p" global flag and the "o" channel
    flag on your current console channel.
    Specifying "|" as the separator will cause OR style matching.
    For example:
-     .match p|o
+     %dmatch p|o
    This will match all users with either the "p" global flag or the "o" channel
    flag on your current console channel. If you specify a channel, it will be
    used instead of the current console channel.
    For example:
-     .match p|o #eggdrop
+     %dmatch p|o #eggdrop
    This will match all users with either the "p" global flag or the "o" channel
    flag on the channel #eggdrop. You can also match bot flags.
    For example:
-     .match o|o|h
+     %dmatch o|o|h
    This will match all bots with either the "o" global flag, the "o" channel
    flag on the current console channel, or the "h" botflag. You can also limit
    the number of total results returned by specifying a limit at the end of the
    command. A starting point can also be specified.
    For example:
-     .match p&o #eggdrop 16 25
+     %dmatch p&o #eggdrop 16 25
    This would show results 16 through 25 matching any users with the "p" global
    flag or the "o" channel flag on #eggdrop.
 ###  %bmatch%b <wildcard-string> [[start] limit]
@@ -1165,9 +1165,14 @@ See also: unlink, newleaf%{+a}, -bot%{-}
    of total results returned by specifying a limit at the end of the command. A
    starting point can also be specified.
    For example:
-     .match *.edu 16 25
+     %dmatch *.edu 16 25
    This would show results 16 through 25 matching any users with a hostmask
    that ends with ".edu".
+See also: matchbot
+::matchbot
+###  %bmatchbot%b 
+   Matches bots.
+   See: match
 ::md5
 ###  %bmd5%b <string>
    Returns the MD5 hash of the specified string.

+ 17 - 5
src/cmds.c

@@ -920,16 +920,18 @@ static void cmd_whois(struct userrec *u, int idx, char *par)
   tell_user_ident(idx, par, u ? (u->flags & USER_MASTER) : 0);
 }
 
-static void cmd_match(struct userrec *u, int idx, char *par)
+static void match(struct userrec *u, int idx, char *par, int isbot)
 {
   int start = 1, limit = 20;
   char *s = NULL, *s1 = NULL, *chname = NULL;
 
+  putlog(LOG_CMDS, "*", "#%s# match%s %s", dcc[idx].nick, isbot ? "bot" : "", par);
+
   if (!par[0]) {
-    dprintf(idx, "Usage: match <nick/host> [[skip] count]\n");
+    dprintf(idx, "Usage: match%s <%snick/host> [[skip] count]\n", isbot ? "bot" : "", isbot ? "bot" : "");
     return;
   }
-  putlog(LOG_CMDS, "*", "#%s# match %s", dcc[idx].nick, par);
+
   s = newsplit(&par);
   if (strchr(CHANMETA, par[0]) != NULL)
     chname = newsplit(&par);
@@ -943,8 +945,17 @@ static void cmd_match(struct userrec *u, int idx, char *par)
     } else
       limit = atoi(s1);
   }
-  tell_users_match(idx, s, start, limit, u ? (u->flags & USER_MASTER) : 0,
-		   chname);
+  tell_users_match(idx, s, start, limit, u ? (u->flags & USER_MASTER) : 0, chname, isbot);
+}
+
+static void cmd_matchbot(struct userrec *u, int idx, char *par)
+{
+  match(u, idx, par, 1);
+}
+
+static void cmd_match(struct userrec *u, int idx, char *par)
+{
+  match(u, idx, par, 0);
 }
 
 static void cmd_update(struct userrec *u, int idx, char *par)
@@ -4272,6 +4283,7 @@ cmd_t C_dcc[] =
   {"link",		"n",	(Function) cmd_link,		NULL},
 #endif /* HUB */
   {"match",		"m|m",	(Function) cmd_match,		NULL},
+  {"matchbot",		"m|m",	(Function) cmd_matchbot,	NULL},
   {"me",		"",	(Function) cmd_me,		NULL},
   {"motd",		"",	(Function) cmd_motd,		NULL},
 #ifdef HUB

+ 23 - 9
src/users.c

@@ -477,9 +477,13 @@ void tell_user(int idx, struct userrec *u, int master)
       egg_strftime(s1, 6, "%H:%M", localtime(&li->laston));
 #endif /* S_UTCTIME */
   }
-  egg_snprintf(format, sizeof format, "%%-%us %%-5s%%5d %%-15s %%s (%%-10.10s)", HANDLEN);
-  dprintf(idx, format, u->handle, get_user(&USERENTRY_PASS, u) ? "yes" : "no", n, s, s1, (li && li->lastonplace) ? li->lastonplace : "nowhere");
-  dprintf(idx, "\n");
+  if (!u->bot) {
+    egg_snprintf(format, sizeof format, "%%-%us %%-5s%%5d %%-15s %%s (%%-10.10s)\n", HANDLEN);
+    dprintf(idx, format, u->handle, get_user(&USERENTRY_PASS, u) ? "yes" : "no", n, s, s1, (li && li->lastonplace) ? li->lastonplace : "nowhere");
+  } else {	/* BOT */
+    egg_snprintf(format, sizeof format, "%%-%us %%-8s %%s (%%-10.10s)\n", HANDLEN);
+    dprintf(idx, format, u->handle, s, s1, (li && li->lastonplace) ? li->lastonplace : "nowhere");
+  }  
   /* channel flags? */
   for (ch = u->chanrec; ch; ch = ch->next) {
     fr.match = FR_CHAN | FR_GLOBAL;
@@ -537,15 +541,20 @@ void tell_user_ident(int idx, char *id, int master)
     dprintf(idx, "%s.\n", USERF_NOMATCH);
     return;
   }
-  egg_snprintf(format, sizeof format, "%%-%us PASS NOTES FLAGS           LAST\n", HANDLEN);
-  dprintf(idx, format, "HANDLE");
+  if (u->bot) {
+    egg_snprintf(format, sizeof format, "%%-%us FLAGS    LAST\n", HANDLEN);
+    dprintf(idx, format, "BOTNICK");
+  } else {
+    egg_snprintf(format, sizeof format, "%%-%us PASS NOTES FLAGS           LAST\n", HANDLEN);
+    dprintf(idx, format, "HANDLE");
+  }
   tell_user(idx, u, master);
 }
 
 /* match string:
  * wildcard to match nickname or hostmasks
  * +attr to find all with attr */
-void tell_users_match(int idx, char *mtch, int start, int limit, int master, char *chname)
+void tell_users_match(int idx, char *mtch, int start, int limit, int master, char *chname, int isbot)
 {
   char format[81] = "";
   struct userrec *u = NULL;
@@ -555,8 +564,13 @@ void tell_users_match(int idx, char *mtch, int start, int limit, int master, cha
 
   dprintf(idx, "*** %s '%s':\n", MISC_MATCHING, mtch);
   cnt = 0;
-  egg_snprintf(format, sizeof format, "%%-%us PASS NOTES FLAGS           LAST\n", HANDLEN);
-  dprintf(idx, format, "HANDLE");
+  if (isbot) {
+    egg_snprintf(format, sizeof format, "%%-%us FLAGS    LAST\n", HANDLEN);
+    dprintf(idx, format, "BOTNICK");
+  } else {
+    egg_snprintf(format, sizeof format, "%%-%us PASS NOTES FLAGS           LAST\n", HANDLEN);
+    dprintf(idx, format, "HANDLE");
+  }
   if (start > 1)
     dprintf(idx, "(%s %d)\n", MISC_SKIPPING, start - 1);
   if (strchr("+-&|", *mtch)) {
@@ -576,7 +590,7 @@ void tell_users_match(int idx, char *mtch, int start, int limit, int master, cha
     flags = 1;
   }
   for (u = userlist; u; u = u->next) {
-    if (!whois_access(dcc[idx].user, u)) {
+    if (!whois_access(dcc[idx].user, u) || (isbot && !u->bot) || (!isbot && u->bot)) {
       continue;
     } else if (flags) {
       get_user_flagrec(u, &user, chname);

+ 1 - 1
src/users.h

@@ -174,7 +174,7 @@ void check_expired_ignores();
 void autolink_cycle(char *);
 void tell_file_stats(int, char *);
 void tell_user_ident(int, char *, int);
-void tell_users_match(int, char *, int, int, int, char *);
+void tell_users_match(int, char *, int, int, int, char *, int);
 int readuserfile(const char *, struct userrec **);
 void check_pmode();
 void link_pref_val(struct userrec *u, char *lval);