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

* cmd_find now optional takes a username instead of a nick!user@host to search for.

svn: 1996
Bryan Drewery 21 лет назад
Родитель
Сommit
6de1d2110b
3 измененных файлов с 23 добавлено и 12 удалено
  1. 1 0
      doc/UPDATES
  2. 3 1
      misc/help.txt
  3. 19 11
      src/mod/irc.mod/cmdsirc.c

+ 1 - 0
doc/UPDATES

@@ -70,6 +70,7 @@ Lines prefixxed with '-' were disabled before release and are not finishsed, or
 * Fixed a bunch of lame bugs in the getop system
 * Now using ANSI color code *0* to close bold (as opposed to new standard: 22)
 * Fixed some excess newlines when a user is booted for losing hub/leaf access.
+* cmd_find now optional takes a username instead of a nick!user@host to search for.
 
 1.2.2
 * Don't sanity check flags for users on DCC CHAT if they are on the bot via .botcmd.

+ 3 - 1
misc/help.txt

@@ -969,10 +969,12 @@ See also: decrypt, randstring, md5, sha1
  
 See also: -exempt, +exempt, console%{+m|m}, chanset, chaninfo%{-}, stick, unstick
 :leaf:find:
-###  $bfind$b  <nick!ident@host.com>
+###  $bfind$b  <nick!ident@host.com>|<user>
    The bot will search through all of it's channel records and look
    for the specified hostmask.  Wildcards are accepted; '*' for 1 or more
    characters, or '?' for exactly 1 character.
+   If a username is specified, then the user is searched for in all the channel
+   lists.
 ::fixcodes
 ### $bfixcodes$b
      This is for use in situations where the bot gets mixed up about the type

+ 19 - 11
src/mod/irc.mod/cmdsirc.c

@@ -1094,7 +1094,7 @@ static void cmd_mop(int idx, char *par)
 static void cmd_find(int idx, char *par)
 {
   if (!par[0]) {
-    dprintf(idx, "Usage: find <nick!ident@host.com> (wildcard * allowed)\n");
+    dprintf(idx, "Usage: find <nick!ident@host.com>|<user> (wildcard * allowed)\n");
     return;
   }
 
@@ -1102,10 +1102,18 @@ static void cmd_find(int idx, char *par)
 
   struct chanset_t *chan = NULL, **cfound = NULL;
   memberlist *m = NULL, **found = NULL;
-  struct userrec *u2 = NULL;
   int fcount = 0;
-  bool tr = 0;
+  bool tr = 0, lookup_user = 0;
+  struct userrec *u = NULL;
 
+  if (!strchr(par, '!')) {
+    lookup_user = 1;
+    u = get_user_by_handle(userlist, par);
+    if (!u) {
+      dprintf(idx, "No such user: %s\n", par);
+      return;
+    }
+  }    
   /* make a list of members in found[] */
   for (chan = chanset; chan; chan = chan->next) {
 
@@ -1114,10 +1122,14 @@ static void cmd_find(int idx, char *par)
     if (!privchan(user, chan, PRIV_OP)) {
 
       for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
-        char tmp[256] = "";
+        char s[UHOSTLEN] = "";
 
-        sprintf(tmp, "%s!%s", m->nick, m->userhost ? m->userhost : "(null)");
-        if (wild_match(par, tmp)) {
+        sprintf(s, "%s!%s", m->nick, m->userhost);
+        if (!m->user && !m->tried_getuser) {
+          m->user = get_user_by_host(s);
+          m->tried_getuser = 1;
+        }
+        if ((!lookup_user && wild_match(par, s)) || (lookup_user && m->user == u)) {
           fcount++;
           if (!found) {
             found = (memberlist **) my_calloc(1, sizeof(memberlist *) * 100);
@@ -1143,13 +1155,9 @@ static void cmd_find(int idx, char *par)
     int findex, i;
 
     for (findex = 0; findex < fcount; findex++) {
-      char check[500] = "";
-
       if (found[findex]) {
-        sprintf(check, "%s!%s", found[findex]->nick, found[findex]->userhost);
-        u2 = get_user_by_host(check);
         sprintf(tmp, "%s!%s %s%s%s on %s", found[findex]->nick, found[findex]->userhost, 
-                                           u2 ? "(user:" : "", u2 ? u2->handle : "", u2 ? ")" : "", 
+         found[findex]->user ? "(user:" : "", found[findex]->user ? found[findex]->user->handle : "", found[findex]->user ? ")" : "", 
                                            cfound[findex]->name);
         for (i = findex + 1; i < fcount; i++) {
           if (found[i] && (!strcmp(found[i]->nick, found[findex]->nick))) {