فهرست منبع

* Fix bot forgetting its own userip due to irc.mod not being active during restart

Bryan Drewery 16 سال پیش
والد
کامیت
8d225357fc
2فایلهای تغییر یافته به همراه36 افزوده شده و 11 حذف شده
  1. 3 11
      src/mod/irc.mod/chan.c
  2. 33 0
      src/mod/server.mod/servmsg.c

+ 3 - 11
src/mod/irc.mod/chan.c

@@ -1483,6 +1483,7 @@ void recheck_channel(struct chanset_t *chan, int dobans)
   --stacking;
 }
 
+#ifdef CACHE
 /* got 302: userhost
  * <server> 302 <to> :<nick??user@host>
  */
@@ -1490,10 +1491,8 @@ static int got302(char *from, char *msg)
 {
   char *p = NULL, *nick = NULL, *uhost = NULL;
 
-#ifdef CACHE
   cache_t *cache = NULL;
   cache_chan_t *cchan = NULL;
-#endif
 
   newsplit(&msg);
   fixcolon(msg);
@@ -1511,13 +1510,6 @@ static int got302(char *from, char *msg)
   if ((p = strchr(uhost, ' ')))
     *p = 0;
 
-  if (match_my_nick(nick)) {
-    strlcpy(botuserip, uhost, UHOSTLEN);
-    sdprintf("botuserip: %s", botuserip);
-    return 0;
-  }
-
-#ifdef CACHE
   if ((cache = cache_find(nick))) {
     if (!cache->uhost[0])
     strlcpy(cache->uhost, uhost, sizeof(cache->uhost));
@@ -1545,9 +1537,9 @@ static int got302(char *from, char *msg)
       }
     }
   }
-#endif
   return 0;
 }
+#endif
 
 #ifdef CACHE
 /* got341 invited
@@ -3358,8 +3350,8 @@ static int gotnotice(char *from, char *msg)
 
 static cmd_t irc_raw[] =
 {
-  {"302",       "",     (Function) got302,      "irc:302", LEAF},
 #ifdef CACHE
+  {"302",       "",     (Function) got302,      "irc:302", LEAF},
   {"341",       "",     (Function) got341,      "irc:341", LEAF},
 #endif /* CACHE */
   {"324",	"",	(Function) got324,	"irc:324", LEAF},

+ 33 - 0
src/mod/server.mod/servmsg.c

@@ -1579,6 +1579,38 @@ static int got301(char *from, char *msg)
   return 0;
 }
 
+/* got 302: userhost
+ * <server> 302 <to> :<nick??user@host>
+ */
+static int got302(char *from, char *msg)
+{
+  char *p = NULL, *nick = NULL, *uhost = NULL;
+
+  newsplit(&msg);
+  fixcolon(msg);
+
+  p = strchr(msg, '=');
+  if (!p)
+    p = strchr(msg, '*');
+  if (!p)
+    return 0;
+  *p = 0;
+  nick = msg;
+  p += 2;		/* skip =|* plus the next char */
+  uhost = p;
+
+  if ((p = strchr(uhost, ' ')))
+    *p = 0;
+
+  if (match_my_nick(nick)) {
+    strlcpy(botuserip, uhost, UHOSTLEN);
+    sdprintf("botuserip: %s", botuserip);
+    return 0;
+  }
+
+  return 0;
+}
+
 /* 313 $me nick :server text */
 static int got313(char *from, char *msg)
 {
@@ -1755,6 +1787,7 @@ static cmd_t my_raw_binds[] =
   {"001",	"",	(Function) got001,		NULL, LEAF},
   {"004",	"",	(Function) got004,		NULL, LEAF},
   {"005",	"",	(Function) got005,		NULL, LEAF},
+  {"302",       "",     (Function) got302,		NULL, LEAF},
   {"303",	"",	(Function) got303,		NULL, LEAF},
   {"432",	"",	(Function) got432,		NULL, LEAF},
   {"433",	"",	(Function) got433,		NULL, LEAF},