Browse Source

* irc_log(struct chanset_t *, char *, ...)
Will be used for relaying with logchan etc..


svn: 1035

Bryan Drewery 22 years ago
parent
commit
bb0ad44665
7 changed files with 77 additions and 84 deletions
  1. 24 0
      src/log.c
  2. 1 0
      src/log.h
  3. 5 1
      src/mod/channels.mod/channels.c
  4. 46 66
      src/mod/irc.mod/chan.c
  5. 0 15
      src/mod/irc.mod/irc.c
  6. 0 1
      src/mod/irc.mod/irc.h
  7. 1 1
      src/mod/irc.mod/mode.c

+ 24 - 0
src/log.c

@@ -8,6 +8,7 @@
 #include "common.h"
 #include "log.h"
 #include "tandem.h"
+#include "color.h"
 #include "userrec.h"
 #include "botnet.h"
 #include "botmsg.h"
@@ -217,3 +218,26 @@ void putlog(int type, const char *chname, const char *format, ...)
   }
 }
 
+void
+irc_log(struct chanset_t *chan, const char *format, ...)
+{
+  if (0) {
+  char va_out[LOGLINEMAX + 1];
+  va_list va;
+
+  va_start(va, format);
+  egg_vsnprintf(va_out, LOGLINEMAX, format, va);
+  va_end(va);
+
+  char *TO = "#shadow";
+
+  if (egg_strcasecmp(chan->dname, TO))
+    dprintf(DP_HELP, "PRIVMSG %s :[%s] %s\n", TO, chan->dname, va_out);
+
+//  chanout_but(-1, 1, "[%s] %s\n", chan->dname, va_out);
+//  botnet_send_chan(-1, conf.bot->nick, chan->dname, 1, va_out);
+   putlog(LOG_PUBLIC, "*", "[%s] %s", chan->dname, va_out);
+
+//  sdprintf("%s", va_out);
+  }
+}

+ 1 - 0
src/log.h

@@ -33,6 +33,7 @@ void putlog (int, const char *, const char *, ...) __attribute((format(printf, 3
 int logmodes(const char *);
 char *masktype(int);
 char *maskname(int);
+void irc_log(struct chanset_t *, const char *, ...) __attribute__((format(printf, 2, 3)));
 
 extern int		conmask, debug_output, use_console_r;
 

+ 5 - 1
src/mod/channels.mod/channels.c

@@ -650,12 +650,16 @@ __inline__ static int chanset_unlink(struct chanset_t *chan)
 void remove_channel(struct chanset_t *chan)
 {
    int		 i;
+   
+   irc_log(chan, "Parting");
    /* Remove the channel from the list, so that noone can pull it
       away from under our feet during the check_part() call. */
    chanset_unlink(chan);
 
 #ifdef LEAF
-   do_channel_part(chan);
+  /* Using chan->name is important here, especially for !chans <cybah> */
+  if (shouldjoin(chan) && chan->name[0])
+    dprintf(DP_SERVER, "PART %s\n", chan->name);
 #endif /* LEAF */
 
    clear_channel(chan, 0);

+ 46 - 66
src/mod/irc.mod/chan.c

@@ -1705,6 +1705,19 @@ static int got349(char *from, char *msg)
   return 0;
 }
 
+static void got353(char *from, char *msg)
+{
+  char *chname = NULL;
+  struct chanset_t *chan = NULL;
+
+  newsplit(&msg); /* my nick */
+  newsplit(&msg); /*    *|@|=  */
+  chname = newsplit(&msg);
+  chan = findchan(chname);
+  fixcolon(msg);
+  irc_log(chan, "%s", msg);
+}
+
 /* got 346: invite exemption info
  * <server> 346 <to> <chan> <exemption>
  */
@@ -1994,8 +2007,7 @@ static int gottopic(char *from, char *msg)
   nick = splitnick(&from);
   chan = findchan(chname);
   if (chan) {
-    putlog(LOG_JOIN, chan->dname, "Topic changed on %s by %s!%s: %s",
-           chan->dname, nick, from, msg);
+    irc_log(chan, "%s!%s changed topic to: %s", nick, from, msg);
     m = ismember(chan, nick);
     if (m != NULL)
       m->last = now;
@@ -2097,7 +2109,7 @@ static int gotjoin(char *from, char *chname)
     strcpy(uhost, from);
     nick = splitnick(&uhost);
     if (match_my_nick(nick)) {
-      putlog(LOG_MISC, "*", "joined %s but didn't want to!", chname);
+      putlog(LOG_WARN, "*", "joined %s but didn't want to!", chname);
       dprintf(DP_MODE, "PART %s\n", chname);
     }
   } else if (!channel_pending(chan)) {
@@ -2122,9 +2134,7 @@ static int gotjoin(char *from, char *chname)
     get_user_flagrec(u, &fr, chan->dname); /* Lam: fix to work with !channels */
     if (!channel_active(chan) && !match_my_nick(nick)) {
       /* uh, what?!  i'm on the channel?! */
-      putlog(LOG_MISC, chan->dname,
-	     "confused bot: guess I'm on %s and didn't realize it",
-	     chan->dname);
+      putlog(LOG_ERROR, "*", "confused bot: guess I'm on %s and didn't realize it", chan->dname);
       chan->status |= CHAN_ACTIVE;
       chan->status &= ~CHAN_PEND;
       reset_chan_info(chan);
@@ -2151,8 +2161,7 @@ static int gotjoin(char *from, char *chname)
 	m->user = u;
 	set_handle_laston(chan->dname, u, now);
 	m->flags |= STOPWHO;
-	putlog(LOG_JOIN, chan->dname, "%s (%s) returned to %s.", nick, uhost,
-	       chan->dname);
+        irc_log(chan, "%s returned from netsplit", m->nick);
       } else {
 	if (m)
 	  killmember(chan, nick);
@@ -2199,19 +2208,13 @@ static int gotjoin(char *from, char *chname)
 	   * logs with the unique name.
            */
 	  if (chname[0] == '!')
-	    putlog(LOG_JOIN, chan->dname, "%s joined %s (%s)", nick, chan->dname, chname);
+            irc_log(chan, "Joined. (%s)", chname);
 	  else
-	    putlog(LOG_JOIN, chan->dname, "%s joined %s.", nick,
-	           chname);
+            irc_log(chan, "Joined.");
 	  if (!match_my_nick(chname))
  	    reset_chan_info(chan);
 	} else {
-
-	  putlog(LOG_JOIN, chan->dname,
-		 "%s (%s) joined %s.", nick, uhost, chan->dname);
-	  /* Don't re-display greeting if they've been on the channel
-	   * recently.
-	   */
+          irc_log(chan, "Join: %s (%s)", nick, uhost);
 	  set_handle_laston(chan->dname, u, now);
 	}
       }
@@ -2280,19 +2283,20 @@ static int gotpart(char *from, char *msg)
   fixcolon(chname);
   fixcolon(msg);
   chan = findchan(chname);
+  u = get_user_by_host(from);
+  nick = splitnick(&from);
   if (chan && !shouldjoin(chan)) {
   /* shouldnt this check for match_my_nick? */
+    if (match_my_nick(nick)) 
+      irc_log(chan, "Parting");    
     clear_channel(chan, 1);
     chan->status &= ~(CHAN_ACTIVE | CHAN_PEND);
     return 0;
   }
   if (chan && !channel_pending(chan)) {
-    u = get_user_by_host(from);
-    nick = splitnick(&from);
     if (!channel_active(chan)) {
       /* whoa! */
-      putlog(LOG_MISC, chan->dname,
-	  "confused bot: guess I'm on %s and didn't realize it", chan->dname);
+      putlog(LOG_ERRORS, "*", "confused bot: guess I'm on %s and didn't realize it", chan->dname);
       chan->status |= CHAN_ACTIVE;
       chan->status &= ~CHAN_PEND;
       reset_chan_info(chan);
@@ -2304,9 +2308,9 @@ static int gotpart(char *from, char *msg)
 
     killmember(chan, nick);
     if (msg[0])
-      putlog(LOG_JOIN, chan->dname, "%s (%s) left %s (%s).", nick, from, chan->dname, msg);
+      irc_log(chan, "Part: %s (%s) [%s]", nick, from, msg);
     else
-      putlog(LOG_JOIN, chan->dname, "%s (%s) left %s.", nick, from, chan->dname);
+      irc_log(chan, "Part: %s (%s)", nick, from);
     /* If it was me, all hell breaks loose... */
     if (match_my_nick(nick)) {
       clear_channel(chan, 1);
@@ -2383,8 +2387,7 @@ static int gotkick(char *from, char *origmsg)
     } else {
       simple_sprintf(s1, "%s!*@could.not.loookup.hostname", nick);
     }
-    putlog(LOG_MODES, chan->dname, "%s kicked from %s by %s: %s", s1,
-	   chan->dname, from, msg);
+    irc_log(chan, "%s was kicked by %s (%s)", s1, from, msg);
     /* Kicked ME?!? the sods! */
     if (match_my_nick(nick) && shouldjoin(chan)) {
       chan->status &= ~(CHAN_ACTIVE | CHAN_PEND);
@@ -2420,21 +2423,13 @@ static int gotnick(char *from, char *msg)
     m = ismember(chan, nick);
 
     if (m) {
-      putlog(LOG_JOIN, chan->dname, "Nick change: %s -> %s", nick, msg);
+      irc_log(chan, "Nick change: %s -> %s", nick, msg);
       m->last = now;
+      /* Not just a capitalization change */
       if (rfc_casecmp(nick, msg)) {
-	/* Not just a capitalization change */
-	mm = ismember(chan, msg);
-	if (mm) {
-	  /* Someone on channel with old nick?! */
-	  if (mm->split)
-	    putlog(LOG_JOIN, chan->dname,
-		   "Possible future nick collision: %s", mm->nick);
-	  else
-	    putlog(LOG_MISC, chan->dname,
-		   "* Bug: nick change to existing nick");
+        /* Someone on channel with old nick?! */
+	if ((mm = ismember(chan, msg)))
 	  killmember(chan, mm->nick);
-	}
       }
       /*
        * Banned?
@@ -2573,15 +2568,16 @@ static int gotquit(char *from, char *msg)
           chan = oldchan;
 	  continue;
         }
-	putlog(LOG_JOIN, chan->dname, "%s (%s) got netsplit.", nick,
-	       from);
+        irc_log(chan, "%s (%s) got netsplit.", nick, from);
       } else {
 	if (!findchan_by_dname(chname)) {
 	  chan = oldchan;
 	  continue;
 	}
-	putlog(LOG_JOIN, chan->dname, "%s (%s) left irc: %s", nick,
-	       from, msg);
+        if (msg[0])
+          irc_log(chan, "Quits %s (%s) (%s)", nick, from, msg);
+        else
+          irc_log(chan, "Quits %s (%s)", nick, from);
 	killmember(chan, nick);
 	check_lonely_channel(chan);
       }
@@ -2626,6 +2622,7 @@ static int gotmsg(char *from, char *msg)
   fixcolon(msg);
   strcpy(uhost, from);
   nick = splitnick(&uhost);
+
   /* Only check if flood-ctcp is active */
   detect_autokick(nick, uhost, chan, msg);
   if (flud_ctcp_thr && detect_avalanche(msg)) {
@@ -2701,16 +2698,12 @@ static int gotmsg(char *from, char *msg)
 
 	      update_idle(chan->dname, nick);
             }
-	    if (!ignoring) {
 	      /* Log DCC, it's to a channel damnit! */
 	      if (!strcmp(code, "ACTION")) {
-		putlog(LOG_PUBLIC, chan->dname, "Action: %s %s", nick, ctcp);
+                irc_log(chan, "* %s %s", nick, ctcp);
 	      } else {
-		putlog(LOG_PUBLIC, chan->dname,
-		       "CTCP %s: %s from %s (%s) to %s", code, ctcp, nick,
-		       from, to);
+                irc_log(chan, "CTCP %s: %s from %s (%s) to %s", code, ctcp, nick, from, to);
 	      }
-	    }
 	  }
 	}
       }
@@ -2732,7 +2725,7 @@ static int gotmsg(char *from, char *msg)
     }
   }
   if (msg[0]) {
-    int dolog = 1, botmatch = 0;
+    int botmatch = 0;
 #ifdef S_AUTHCMDS
     int i = 0;
     char *my_msg = NULL, *my_ptr = NULL, *fword = NULL;
@@ -2760,20 +2753,12 @@ static int gotmsg(char *from, char *msg)
           fword++;
         if (check_bind_pubc(fword, nick, uhost, auth[i].user, my_msg, chan->dname)) {
           auth[i].atime = now;
-          dolog--; 		/* don't log */
         }
       }
     }
     free(my_ptr);
 #endif /* S_AUTHCMDS */
-    if (dolog) {
-      if (!ignoring) {
-        if (to[0] == '@')
-          putlog(LOG_PUBLIC, chan->dname, "@<%s> %s", nick, msg);
-        else
-          putlog(LOG_PUBLIC, chan->dname, "<%s> %s", nick, msg);
-      }
-    }
+    irc_log(chan, "%s<%s> %s", to[0] == '@' ? "@" : "", nick, msg);
     update_idle(chan->dname, nick);
   }
   return 0;
@@ -2857,12 +2842,8 @@ static int gotnotice(char *from, char *msg)
 	  chan = findchan(realto); 
 	  if (!chan)
 	    return 0;
-
-	  if (!ignoring) {
-	    putlog(LOG_PUBLIC, chan->dname, "CTCP reply %s: %s from %s (%s) to %s",
-		   code, msg, nick, from, chan->dname);
-	    update_idle(chan->dname, nick);
-	  }
+          irc_log(chan, "CTCP reply %s: %s from %s (%s) to %s", code, msg, nick, from, chan->dname);
+          update_idle(chan->dname, nick);
 	}
       }
     }
@@ -2880,9 +2861,7 @@ static int gotnotice(char *from, char *msg)
       if (!chan)
 	return 0;
     }
-
-    if (!ignoring)
-      putlog(LOG_PUBLIC, chan->dname, "-%s:%s- %s", nick, to, msg);
+    irc_log(chan, "-%s:%s- %s", nick, to, msg);
     update_idle(chan->dname, nick);
   }
   return 0;
@@ -2918,6 +2897,7 @@ static cmd_t irc_raw[] =
   {"347",	"",	(Function) got347,	"irc:347"},
   {"348",	"",	(Function) got348,	"irc:348"},
   {"349",	"",	(Function) got349,	"irc:349"},
+  {"353",	"",	(Function) got353,	"irc:353"},
   {NULL,	NULL,	NULL,			NULL}
 };
 #endif /* LEAF */

+ 0 - 15
src/mod/irc.mod/irc.c

@@ -951,21 +951,6 @@ static void reset_chan_info(struct chanset_t *chan)
   }
 }
 
-/* Leave the specified channel and notify registered Tcl procs. This
- * should not be called by itsself.
- */
-void do_channel_part(struct chanset_t *chan)
-{
-  if (shouldjoin(chan) && chan->name[0]) {
-    /* Using chan->name is important here, especially for !chans <cybah> */
-    dprintf(DP_SERVER, "PART %s\n", chan->name);
-
-    /* As we don't know of this channel anymore when we receive the server's
-       ack for the above PART, we have to notify about it _now_. */
-  }
-}
-
-
 /* If i'm the only person on the channel, and i'm not op'd,
  * might as well leave and rejoin. If i'm NOT the only person
  * on the channel, but i'm still not op'd, demand ops.

+ 0 - 1
src/mod/irc.mod/irc.h

@@ -71,7 +71,6 @@ void raise_limit(struct chanset_t *);
 void enforce_closed(struct chanset_t *);
 void recheck_channel(struct chanset_t *, int);
 void recheck_channel_modes(struct chanset_t *);
-void do_channel_part(struct chanset_t *);
 void irc_report(int, int);
 void flush_modes();
 

+ 1 - 1
src/mod/irc.mod/mode.c

@@ -1070,7 +1070,7 @@ static int gotmode(char *from, char *msg)
       z = strlen(msg);
       if (msg[--z] == ' ')	/* I hate cosmetic bugs :P -poptix */
 	msg[z] = 0;
-      putlog(LOG_MODES, chan->dname, "%s: mode change '%s %s' by %s", ch, chg, msg, from);
+      irc_log(chan, "%s sets mode: %s %s", from, chg, msg);
       u = get_user_by_host(from);
       get_user_flagrec(u, &user, ch);
       nick = splitnick(&from);