[cvslog] [CVS] Module eggdrop1.6: Change committed

cvs at eggheads.org cvs at eggheads.org
Mon Mar 8 14:53:06 CST 2010


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.6
Commit time: 2010-03-08 20:53:06 UTC
Committer  : Rumen Stoyanov <pseudo at egg6.net>

Modified files:
     doc/Changes1.6 doc/tcl-commands.doc doc/html/tcl-commands.html
     src/misc.c src/patch.h src/tclhash.c src/tclhash.h src/tclmisc.c

Log message:

Added a new bind LOG triggered when text is sent to the logs.

---------------------- diff included ----------------------
Index: eggdrop1.6/doc/Changes1.6
diff -u eggdrop1.6/doc/Changes1.6:1.70 eggdrop1.6/doc/Changes1.6:1.71
--- eggdrop1.6/doc/Changes1.6:1.70	Mon Mar  8 10:01:15 2010
+++ eggdrop1.6/doc/Changes1.6	Mon Mar  8 14:52:56 2010
@@ -1,4 +1,4 @@
-$Id: Changes1.6,v 1.70 2010/03/08 16:01:15 thommey Exp $
+$Id: Changes1.6,v 1.71 2010/03/08 20:52:56 pseudo Exp $
 
 Eggdrop Changes (since version 1.6.0)
 
@@ -6,6 +6,9 @@
 
 1.6.20 (CVS):
 
+  - Added a new bind LOG triggered when text is sent to the logs.
+    Patch by: pseudo
+
   - Fixed a bug in checking user priviledges for .chaddr on sharebots.
     Patch by: thommey
 
Index: eggdrop1.6/doc/html/tcl-commands.html
diff -u eggdrop1.6/doc/html/tcl-commands.html:1.66 eggdrop1.6/doc/html/tcl-commands.html:1.67
--- eggdrop1.6/doc/html/tcl-commands.html:1.66	Mon Mar  8 05:18:07 2010
+++ eggdrop1.6/doc/html/tcl-commands.html	Mon Mar  8 14:52:56 2010
@@ -1,5 +1,5 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<!-- $Id: tcl-commands.html,v 1.66 2010/03/08 11:18:07 pseudo Exp $ -->
+<!-- $Id: tcl-commands.html,v 1.67 2010/03/08 20:52:56 pseudo Exp $ -->
 
 <html>
   <head>
@@ -4834,6 +4834,23 @@
 
               <p><strong>Module:</strong> core</p>
             </li>
+
+            <li>
+              <p><a name="binda_log"></a><strong>LOG (stackable)</strong></p>*
+
+              <p><strong>bind log &lt;flags&gt; &lt;mask&gt; &lt;proc&gt;<br>
+              proc-name &lt;level&gt; &lt;channel&gt; &lt;message&gt;</strong>
+              </p>
+
+              <p><strong>Description:</strong> triggered whenever a message
+              is sent to a log. The mask is matched against &quot;channel
+              text&quot;. The level argument to the proc will contain the
+              level(s) the message is sent to, or '*' if the message is sent
+              to all log levels at once. If the message wasn't sent to a
+              specific channel, channel will be set to '*'.</p>
+
+              <p><strong>Module:</strong> core</p>
+            </li>
           </ol>
         </li>
 
Index: eggdrop1.6/doc/tcl-commands.doc
diff -u eggdrop1.6/doc/tcl-commands.doc:1.132 eggdrop1.6/doc/tcl-commands.doc:1.133
--- eggdrop1.6/doc/tcl-commands.doc:1.132	Mon Mar  8 05:18:07 2010
+++ eggdrop1.6/doc/tcl-commands.doc	Mon Mar  8 14:52:56 2010
@@ -1,4 +1,4 @@
-$Id: tcl-commands.doc,v 1.132 2010/03/08 11:18:07 pseudo Exp $
+$Id: tcl-commands.doc,v 1.133 2010/03/08 20:52:56 pseudo Exp $
 
 Eggdrop Tcl Commands
 Last revised: November 23, 2009
@@ -2228,6 +2228,18 @@
 |          meanings. Flags are ignored.
 |        Module: core
 
+|   (47) LOG (stackable)
+|        bind log <flags> <mask> <proc>
+|        proc-name <level> <channel> <message>
+|
+|        Description: triggered whenever a message is sent to a log. The mask is
+|          matched against "channel text".
+|          The level argument to the proc will contain the level(s) the message
+|          is sent to, or '*' if the message is sent to all log levels at once.
+|          If the message wasn't sent to a specific channel, channel will be set
+|          to '*'.
+|        Module: core
+
   (B) RETURN VALUES
 
     Several bindings pay attention to the value you return from the proc
Index: eggdrop1.6/src/misc.c
diff -u eggdrop1.6/src/misc.c:1.84 eggdrop1.6/src/misc.c:1.85
--- eggdrop1.6/src/misc.c:1.84	Fri Jan 15 13:51:49 2010
+++ eggdrop1.6/src/misc.c	Mon Mar  8 14:52:56 2010
@@ -7,7 +7,7 @@
  *   help system
  *   motd display and %var substitution
  *
- * $Id: misc.c,v 1.84 2010/01/15 19:51:49 pseudo Exp $
+ * $Id: misc.c,v 1.85 2010/03/08 20:52:56 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -517,6 +517,7 @@
  */
 void putlog EGG_VARARGS_DEF(int, arg1)
 {
+  static int inhere = 0;
   int i, type, tsl = 0;
   char *format, *chname, s[LOGLINELEN], s1[256], *out, ct[81], *s2, stamp[34];
   va_list va;
@@ -559,6 +560,12 @@
       }
     }
   }
+  /* Make sure the bind list is initialized and we're not looping here */
+  if (!inhere && H_log) {
+    inhere = 1;
+    check_tcl_log(type, chname, out);
+    inhere = 0;
+  }
   /* Place the timestamp in the string to be printed */
   if (out[0] && shtime) {
     strncpy(s, stamp, tsl);
Index: eggdrop1.6/src/patch.h
diff -u eggdrop1.6/src/patch.h:1.1239 eggdrop1.6/src/patch.h:1.1240
--- eggdrop1.6/src/patch.h:1.1239	Mon Mar  8 05:18:07 2010
+++ eggdrop1.6/src/patch.h	Mon Mar  8 14:52:56 2010
@@ -10,7 +10,7 @@
  * statement, leave the rest of the file alone, this allows better
  * overlapping patches.
  *
- * $Id: patch.h,v 1.1239 2010/03/08 11:18:07 pseudo Exp $
+ * $Id: patch.h,v 1.1240 2010/03/08 20:52:56 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -41,12 +41,12 @@
  *
  *
  */
-patch("1268046715");            /* current unixtime */
+patch("1268078010");            /* current unixtime */
 /*
  *
  *
  */
-patch("bindcron");
+patch("bindlog");
 /*
  *
  *
Index: eggdrop1.6/src/tclhash.c
diff -u eggdrop1.6/src/tclhash.c:1.67 eggdrop1.6/src/tclhash.c:1.68
--- eggdrop1.6/src/tclhash.c:1.67	Mon Mar  8 05:18:07 2010
+++ eggdrop1.6/src/tclhash.c	Mon Mar  8 14:52:56 2010
@@ -7,7 +7,7 @@
  *   (non-Tcl) procedure lookups for msg/dcc/file commands
  *   (Tcl) binding internal procedures to msg/dcc/file commands
  *
- * $Id: tclhash.c,v 1.67 2010/03/08 11:18:07 pseudo Exp $
+ * $Id: tclhash.c,v 1.68 2010/03/08 20:52:56 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -41,7 +41,7 @@
 p_tcl_bind_list bind_table_list;
 p_tcl_bind_list H_chat, H_act, H_bcst, H_chon, H_chof, H_load, H_unld, H_link,
                 H_disc, H_dcc, H_chjn, H_chpt, H_bot, H_time, H_nkch, H_away,
-                H_note, H_filt, H_event, H_cron;
+                H_note, H_filt, H_event, H_cron, H_log = NULL;
 
 static int builtin_2char();
 static int builtin_3char();
@@ -54,6 +54,7 @@
 static int builtin_charidx();
 static int builtin_chat();
 static int builtin_dcc();
+static int builtin_log();
 
 
 /* Allocate and initialise a chunk of memory.
@@ -236,6 +237,7 @@
   H_away = add_bind_table("away", HT_STACKABLE, builtin_chat);
   H_act = add_bind_table("act", HT_STACKABLE, builtin_chat);
   H_event = add_bind_table("evnt", HT_STACKABLE, builtin_char);
+  H_log = add_bind_table("log", HT_STACKABLE, builtin_log);
   add_builtins(H_dcc, C_dcc);
   Context;
 }
@@ -673,6 +675,16 @@
   return TCL_OK;
 }
 
+static int builtin_log STDVAR
+{
+  Function F = (Function) cd;
+
+  BADARGS(3, 3, " lvl chan msg");
+
+  CHECKVALIDITY(builtin_log);
+  F(argv[1], argv[2], argv[3]);
+  return TCL_OK;
+}
 
 /* Trigger (execute) a Tcl proc
  *
@@ -1153,6 +1165,18 @@
   check_tcl_bind(H_event, event, 0, " $_event1", MATCH_EXACT | BIND_STACKABLE);
 }
 
+void check_tcl_log(int lv, char *chan, char *msg)
+{
+  char mask[512];
+
+  snprintf(mask, sizeof mask, "%s %s", chan, msg);
+  Tcl_SetVar(interp, "_log1", masktype(lv), 0);
+  Tcl_SetVar(interp, "_log2", chan, 0);
+  Tcl_SetVar(interp, "_log3", msg, 0);
+  check_tcl_bind(H_log, mask, 0, " $_log1 $_log2 $_log3",
+                 MATCH_MASK | BIND_STACKABLE);
+}
+
 void tell_binds(int idx, char *par)
 {
   tcl_bind_list_t *tl, *tl_kind;
Index: eggdrop1.6/src/tclhash.h
diff -u eggdrop1.6/src/tclhash.h:1.22 eggdrop1.6/src/tclhash.h:1.23
--- eggdrop1.6/src/tclhash.h:1.22	Mon Mar  8 05:18:07 2010
+++ eggdrop1.6/src/tclhash.h	Mon Mar  8 14:52:56 2010
@@ -1,7 +1,7 @@
 /*
  * tclhash.h
  *
- * $Id: tclhash.h,v 1.22 2010/03/08 11:18:07 pseudo Exp $
+ * $Id: tclhash.h,v 1.23 2010/03/08 20:52:56 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -96,6 +96,7 @@
 void check_tcl_away(const char *, int, const char *);
 void check_tcl_chatactbcst(const char *, int, const char *, tcl_bind_list_t *);
 void check_tcl_event(const char *);
+void check_tcl_log(int, char *, char *);
 
 #define check_tcl_chat(a, b, c) check_tcl_chatactbcst(a ,b, c, H_chat)
 #define check_tcl_act(a, b, c) check_tcl_chatactbcst(a, b, c, H_act)
@@ -115,7 +116,7 @@
 int check_validity(char *, IntFunc);
 extern p_tcl_bind_list H_chat, H_act, H_bcst, H_chon, H_chof;
 extern p_tcl_bind_list H_load, H_unld, H_dcc, H_bot, H_link;
-extern p_tcl_bind_list H_away, H_nkch, H_filt, H_disc, H_event;
+extern p_tcl_bind_list H_away, H_nkch, H_filt, H_disc, H_event, H_log;
 
 #endif /* MAKING_MODS */
 
Index: eggdrop1.6/src/tclmisc.c
diff -u eggdrop1.6/src/tclmisc.c:1.66 eggdrop1.6/src/tclmisc.c:1.67
--- eggdrop1.6/src/tclmisc.c:1.66	Thu Jan  7 07:48:31 2010
+++ eggdrop1.6/src/tclmisc.c	Mon Mar  8 14:52:56 2010
@@ -2,7 +2,7 @@
  * tclmisc.c -- handles:
  *   Tcl stubs for everything else
  *
- * $Id: tclmisc.c,v 1.66 2010/01/07 13:48:31 pseudo Exp $
+ * $Id: tclmisc.c,v 1.67 2010/03/08 20:52:56 pseudo Exp $
  */
 /*
  * Copyright (C) 1997 Robey Pointer
@@ -190,7 +190,7 @@
   int lev = 0;
   char logtext[501];
 
-  BADARGS(4, 4, " level channel text");
+  BADARGS(4, 4, " level(s) channel text");
 
   lev = logmodes(argv[1]);
   if (!lev) {
----------------------- End of diff -----------------------


More information about the Changes mailing list