[eggheads-patches] PATCH1.4: udef_chanflags.patch

Florian Sander gquann at gmx.de
Tue Oct 12 17:02:27 CST 1999


Hi :)

This patch gives users the possibility to define their own chanflags.
A short example:

[...]
[22:45] <|Argo|>      +dynamicinvites           +userinvites
[22:45] <|Argo|>      +protectfriends           -revengebot
[22:45] <|Argo|> flood settings: chan ctcp join kick deop
[22:45] <|Argo|> number:           10    5    5    3    3
[22:45] <|Argo|> time  :           60   30   60   10   10
[22:45] <|Argo|> [22:45] #G`Quann# chaninfo #xwp

[22:47] <G`Quann> .set chan-udef1 blub
[22:47] <|Argo|> [22:47] #G`Quann# set chan-udef1 blub
[22:47] <|Argo|> Ok, set.

[...]
[22:47] <|Argo|>      +dynamicinvites           +userinvites
[22:47] <|Argo|>      +protectfriends           -revengebot
[22:47] <|Argo|> User defined channel modes:
[22:47] <|Argo|>      -blub
[22:47] <|Argo|> flood settings: chan ctcp join kick deop
[22:47] <|Argo|> number:           10    5    5    3    3
[22:47] <|Argo|> time  :           60   30   60   10   10
[22:47] <|Argo|> [22:47] #G`Quann# chaninfo #xwp

[22:49] <G`Quann> .set chan-udefint1 blubber
[22:49] <|Argo|> [22:49] #G`Quann# set chan-udefint1 blubber
[22:49] <|Argo|> Ok, set.

[...]
[22:49] <|Argo|>      +dynamicinvites           +userinvites
[22:49] <|Argo|>      +protectfriends           -revengebot
[22:49] <|Argo|> User defined channel modes:
[22:49] <|Argo|>      -blub
[22:49] <|Argo|> User defined channel settings:
[22:49] <|Argo|>   blubber: 0
[22:49] <|Argo|> flood settings: chan ctcp join kick deop
[22:49] <|Argo|> number:           10    5    5    3    3
[22:49] <|Argo|> time  :           60   30   60   10   10
[22:49] <|Argo|> [22:49] #G`Quann# chaninfo #xwp

And now you can .chanset +blub, or .chanset blubber 3. Just like the
standard channel flags/settings.

A short example on how the setting could look like on a bot that uses
them:
[23:05] <|Argo|> User defined channel modes:
[23:05] <|Argo|>      -dontclose   -cfh   +stats
[23:05] <|Argo|> User defined channel settings:
[23:05] <|Argo|>   maxclones: 4

I wrote this patch in July and it didn't cause any problems on my bot,
yet. So I think it's stable. :)

I hope you like it...

  bye

PS: I'm sorry that the email became so long. :)
-- 
G`Quann at IRCNet
http://www.visions-of-fantasy.de
-------------- next part --------------
diff -rc eggdrop1.4/src/chan.h patched1.4/src/chan.h
*** eggdrop1.4/src/chan.h	Sat Oct  9 17:46:34 1999
--- patched1.4/src/chan.h	Sun Oct 10 01:01:13 1999
***************
*** 121,126 ****
--- 121,130 ----
    int status;
    int ircnet_status;
    int idle_kick;
+   int udef_int1;
+   int udef_int2;
+   int udef_int3;
+   int udef_int4;
    /* temporary channel bans, exempts and invites */
    maskrec *bans,
            *exempts,
***************
*** 172,180 ****
  #define CHAN_SHARED         0x40000	/* channel is being shared */
  #define CHAN_SEEN           0x80000
  #define CHAN_REVENGEBOT     0x100000	/* revenge on actions against the bot */
! /*			    0x200000 */
! /*			    0x400000 */
! /*			    0x800000 */
  #define CHAN_ACTIVE         0x1000000	/* like i'm actually on the channel
  					 * and stuff */
  #define CHAN_PEND           0x2000000	/* just joined; waiting for end of
--- 176,184 ----
  #define CHAN_SHARED         0x40000	/* channel is being shared */
  #define CHAN_SEEN           0x80000
  #define CHAN_REVENGEBOT     0x100000	/* revenge on actions against the bot */
! #define CHAN_UDEF1          0x200000
! #define CHAN_UDEF2          0x400000
! #define CHAN_UDEF3          0x800000
  #define CHAN_ACTIVE         0x1000000	/* like i'm actually on the channel
  					 * and stuff */
  #define CHAN_PEND           0x2000000	/* just joined; waiting for end of
***************
*** 183,188 ****
--- 187,193 ----
  #define CHAN_STATIC         0x8000000	/* channels that are NOT dynamic */
  #define CHAN_ASKEDBANS      0x10000000
  #define CHAN_ASKEDMODES     0x20000000  /* find out key-info on IRCu */
+ #define CHAN_UDEF4          0x40000000
  
  #define CHAN_ASKED_EXEMPTS  0x0001
  #define CHAN_ASKED_INVITED  0x0002
***************
*** 228,233 ****
--- 233,242 ----
  #define channel_nouserexempts(chan) (chan->ircnet_status & CHAN_NOUSEREXEMPTS)
  #define channel_dynamicinvites(chan) (chan->ircnet_status & CHAN_DYNAMICINVITES)
  #define channel_nouserinvites(chan) (chan->ircnet_status & CHAN_NOUSERINVITES)
+ #define channel_udef1(chan) (chan->status & CHAN_UDEF1)
+ #define channel_udef2(chan) (chan->status & CHAN_UDEF2)
+ #define channel_udef3(chan) (chan->status & CHAN_UDEF3)
+ #define channel_udef4(chan) (chan->status & CHAN_UDEF4)
  
  struct server_list {
    struct server_list *next;
diff -rc eggdrop1.4/src/mod/channels.mod/channels.c patched1.4/src/mod/channels.mod/channels.c
*** eggdrop1.4/src/mod/channels.mod/channels.c	Sat Oct  9 17:46:36 1999
--- patched1.4/src/mod/channels.mod/channels.c	Sun Oct 10 01:01:49 1999
***************
*** 37,42 ****
--- 37,52 ----
  /* default chanmode (drummer,990731) */
  static char glob_chanmode[64] = "nt";
  
+ /* user defined channel modes */
+ static char chan_udef1[256] = "";
+ static char chan_udef2[256] = "";
+ static char chan_udef3[256] = "";
+ static char chan_udef4[256] = "";
+ static char chan_udefint1[256] = "";
+ static char chan_udefint2[256] = "";
+ static char chan_udefint3[256] = "";
+ static char chan_udefint4[256] = "";
+ 
  /* global flood settings */
  static int gfld_chan_thr;
  static int gfld_chan_time;
***************
*** 334,339 ****
--- 344,353 ----
  	chan->flood_join_thr, chan->flood_join_time,
  	chan->flood_kick_thr, chan->flood_kick_time,
  	chan->flood_deop_thr, chan->flood_deop_time);
+     fprintf(f, "udef-int1 %d ", chan->udef_int1);
+     fprintf(f, "udef-int2 %d ", chan->udef_int2);
+     fprintf(f, "udef-int3 %d ", chan->udef_int3);
+     fprintf(f, "udef-int4 %d ", chan->udef_int4);
      fprintf(f, "%cclearbans ",
  	    channel_clearbans(chan) ? '+' : '-');
      fprintf(f, "%cenforcebans ",
***************
*** 376,381 ****
--- 390,403 ----
  	    channel_seen(chan) ? '+' : '-');
      fprintf(f, "%cinactive ",
  	    channel_inactive(chan) ? '+' : '-');
+     fprintf(f, "%cudef1 ",
+        channel_udef1(chan) ? '+' : '-');
+     fprintf(f, "%cudef2 ",
+        channel_udef2(chan) ? '+' : '-');
+     fprintf(f, "%cudef3 ",
+        channel_udef3(chan) ? '+' : '-');
+     fprintf(f, "%cudef4 ",
+        channel_udef4(chan) ? '+' : '-');
      fprintf(f, "%cdynamicexempts ", 
              channel_dynamicexempts(chan) ? '+' : '-');
      fprintf(f, "%cuserexempts ", 
***************
*** 711,716 ****
--- 733,746 ----
  {
    {"chanfile", chanfile, 120, STR_PROTECT},
    {"global-chanmode", glob_chanmode, 64, 0},
+   {"chan-udef1", chan_udef1, 255, 0},
+   {"chan-udef2", chan_udef2, 255, 0},
+   {"chan-udef3", chan_udef3, 255, 0},
+   {"chan-udef4", chan_udef4, 255, 0},
+   {"chan-udefint1", chan_udefint1, 255, 0},
+   {"chan-udefint2", chan_udefint2, 255, 0},
+   {"chan-udefint3", chan_udefint3, 255, 0},
+   {"chan-udefint4", chan_udefint4, 255, 0},  
    {0, 0, 0, 0}
  };
  
diff -rc eggdrop1.4/src/mod/channels.mod/cmdschan.c patched1.4/src/mod/channels.mod/cmdschan.c
*** eggdrop1.4/src/mod/channels.mod/cmdschan.c	Sat Oct  9 17:46:36 1999
--- patched1.4/src/mod/channels.mod/cmdschan.c	Sun Oct 10 01:01:44 1999
***************
*** 1241,1246 ****
--- 1241,1271 ----
      dprintf(idx, "     %cprotectfriends           %crevengebot\n",
              (chan->status & CHAN_PROTECTFRIENDS) ? '+' : '-',
  	    (chan->status & CHAN_REVENGEBOT) ? '+' : '-');
+     /* User defined chanmodes */
+     if ((strlen(chan_udef1) > 0) || (strlen(chan_udef2) > 0) || (strlen(chan_udef3) > 0) || (strlen(chan_udef4) > 0)) {
+        dprintf(idx, "User defined channel modes:\n");
+        dprintf(idx, "  ");
+        if (strlen(chan_udef1) > 0)
+          dprintf(idx, "   %c%s", (chan->status & CHAN_UDEF1) ? '+' : '-', chan_udef1);
+        if (strlen(chan_udef2) > 0)
+          dprintf(idx, "   %c%s", (chan->status & CHAN_UDEF2) ? '+' : '-', chan_udef2);
+        if (strlen(chan_udef3) > 0)
+          dprintf(idx, "   %c%s", (chan->status & CHAN_UDEF3) ? '+' : '-', chan_udef3);
+        if (strlen(chan_udef4) > 0)
+          dprintf(idx, "   %c%s", (chan->status & CHAN_UDEF4) ? '+' : '-', chan_udef4);
+        dprintf(idx, "\n");
+     }
+     if ((strlen(chan_udefint1) > 0) || (strlen(chan_udefint2) > 0) || (strlen(chan_udefint3) > 0) || (strlen(chan_udefint4) > 0)) {
+       dprintf(idx, "User defined channel settings:\n");
+       if (strlen(chan_udefint1) > 0)
+         dprintf(idx, "  %s: %d\n", chan_udefint1, chan->udef_int1);
+       if (strlen(chan_udefint2) > 0)
+         dprintf(idx, "  %s: %d\n", chan_udefint2, chan->udef_int2);
+       if (strlen(chan_udefint3) > 0)
+         dprintf(idx, "  %s: %d\n", chan_udefint3, chan->udef_int3);
+       if (strlen(chan_udefint4) > 0)
+         dprintf(idx, "  %s: %d\n", chan_udefint4, chan->udef_int4);
+     }
      dprintf(idx, "flood settings: chan ctcp join kick deop\n");
      dprintf(idx, "number:          %3d  %3d  %3d  %3d  %3d\n",
  	    chan->flood_pub_thr, chan->flood_ctcp_thr,
diff -rc eggdrop1.4/src/mod/channels.mod/tclchan.c patched1.4/src/mod/channels.mod/tclchan.c
*** eggdrop1.4/src/mod/channels.mod/tclchan.c	Sat Oct  9 17:46:36 1999
--- patched1.4/src/mod/channels.mod/tclchan.c	Sun Oct 10 01:01:37 1999
***************
*** 700,706 ****
--- 700,722 ----
  static int tcl_channel_info(Tcl_Interp * irp, struct chanset_t *chan)
  {
    char s[121];
+   char udef1_on[256];
+   char udef1_off[256];
+   char udef2_on[256];
+   char udef2_off[256];
+   char udef3_on[256];
+   char udef3_off[256];
+   char udef4_on[256];
+   char udef4_off[256];
  
+   simple_sprintf(udef1_on, "%c%s", '+', chan_udef1);
+   simple_sprintf(udef1_off, "%c%s", '-', chan_udef1);
+   simple_sprintf(udef2_on, "%c%s", '+', chan_udef2);
+   simple_sprintf(udef2_off, "%c%s", '-', chan_udef2);
+   simple_sprintf(udef3_on, "%c%s", '+', chan_udef3);
+   simple_sprintf(udef3_off, "%c%s", '-', chan_udef3);
+   simple_sprintf(udef4_on, "%c%s", '+', chan_udef4);
+   simple_sprintf(udef4_off, "%c%s", '-', chan_udef4);
    get_mode_protect(chan, s);
    Tcl_AppendElement(irp, s);
    simple_sprintf(s, "%d", chan->idle_kick);
***************
*** 720,725 ****
--- 736,749 ----
    Tcl_AppendElement(irp, s);
    simple_sprintf(s, "%d:%d", chan->flood_deop_thr, chan->flood_deop_time);
    Tcl_AppendElement(irp, s);
+   simple_sprintf(s, "%d", chan->udef_int1);
+   Tcl_AppendElement(irp, s);
+   simple_sprintf(s, "%d", chan->udef_int2);
+   Tcl_AppendElement(irp, s);
+   simple_sprintf(s, "%d", chan->udef_int3);
+   Tcl_AppendElement(irp, s);
+   simple_sprintf(s, "%d", chan->udef_int4);
+   Tcl_AppendElement(irp, s);
    if (chan->status & CHAN_CLEARBANS)
      Tcl_AppendElement(irp, "+clearbans");
    else
***************
*** 820,825 ****
--- 844,873 ----
      Tcl_AppendElement(irp, "-userinvites");
    else
      Tcl_AppendElement(irp, "+userinvites");
+   if (strlen(chan_udef1) > 0) {
+      if (chan->status & CHAN_UDEF1)
+        Tcl_AppendElement(irp, udef1_on);
+      else
+        Tcl_AppendElement(irp, udef1_off);
+   }
+   if (strlen(chan_udef2) > 0) {
+      if (chan->status & CHAN_UDEF2)
+        Tcl_AppendElement(irp, udef2_on);
+      else
+        Tcl_AppendElement(irp, udef2_off);
+   }
+   if (strlen(chan_udef3) > 0) {
+      if (chan->status & CHAN_UDEF3)
+        Tcl_AppendElement(irp, udef3_on);
+      else
+        Tcl_AppendElement(irp, udef3_off);
+   }
+   if (strlen(chan_udef4) > 0) {
+      if (chan->status & CHAN_UDEF4)
+        Tcl_AppendElement(irp, udef4_on);
+      else
+        Tcl_AppendElement(irp, udef4_off);
+   }
    return TCL_OK;
  }
  
***************
*** 885,891 ****
--- 933,955 ----
    int oldstatus;
    int x=0;
    module_entry *me;
+   char udef1_on[256];
+   char udef1_off[256];
+   char udef2_on[256];
+   char udef2_off[256];
+   char udef3_on[256];
+   char udef3_off[256];
+   char udef4_on[256];
+   char udef4_off[256];
  
+   simple_sprintf(udef1_on, "%c%s", '+', chan_udef1);
+   simple_sprintf(udef1_off, "%c%s", '-', chan_udef1);
+   simple_sprintf(udef2_on, "%c%s", '+', chan_udef2);
+   simple_sprintf(udef2_off, "%c%s", '-', chan_udef2);
+   simple_sprintf(udef3_on, "%c%s", '+', chan_udef3);
+   simple_sprintf(udef3_off, "%c%s", '-', chan_udef3);
+   simple_sprintf(udef4_on, "%c%s", '+', chan_udef4);
+   simple_sprintf(udef4_off, "%c%s", '-', chan_udef4);
    oldstatus = chan->status;
    for (i = 0; i < items; i++) {
      if (!strcmp(item[i], "need-op")) {
***************
*** 953,959 ****
        chan->idle_kick = atoi(item[i]);
      } else if (!strcmp(item[i], "dont-idle-kick"))
        chan->idle_kick = 0;
!     else if (!strcmp(item[i], "+clearbans"))
        chan->status |= CHAN_CLEARBANS;
      else if (!strcmp(item[i], "-clearbans"))
        chan->status &= ~CHAN_CLEARBANS;
--- 1017,1055 ----
        chan->idle_kick = atoi(item[i]);
      } else if (!strcmp(item[i], "dont-idle-kick"))
        chan->idle_kick = 0;
!     else if (!strcmp(item[i], chan_udefint1) || !strcmp(item[i], "udef-int1")) {
!       i++;
!       if (i >= items) {
!   if (irp)
!     Tcl_AppendResult(irp, "channel udef-int1 needs argument", NULL);
!   return TCL_ERROR;
!       }
!       chan->udef_int1 = atoi(item[i]);
!     } else if (!strcmp(item[i], chan_udefint2) || !strcmp(item[i], "udef-int2")) {
!       i++;
!       if (i >= items) {
!   if (irp)
!     Tcl_AppendResult(irp, "channel udef-int2 needs argument", NULL);
!   return TCL_ERROR;
!       }
!       chan->udef_int2 = atoi(item[i]);
!     } else if (!strcmp(item[i], chan_udefint3) || !strcmp(item[i], "udef-int3")) {
!       i++;
!       if (i >= items) {
!   if (irp)
!     Tcl_AppendResult(irp, "channel udef-int2 needs argument", NULL);
!   return TCL_ERROR;
!       }
!       chan->udef_int3 = atoi(item[i]);
!     } else if (!strcmp(item[i], chan_udefint4) || !strcmp(item[i], "udef-int4")) {
!       i++;
!       if (i >= items) {
!   if (irp)
!     Tcl_AppendResult(irp, "channel udef-int4 needs argument", NULL);
!   return TCL_ERROR;
!       }
!       chan->udef_int4 = atoi(item[i]);
!     } else if (!strcmp(item[i], "+clearbans"))
        chan->status |= CHAN_CLEARBANS;
      else if (!strcmp(item[i], "-clearbans"))
        chan->status &= ~CHAN_CLEARBANS;
***************
*** 1053,1058 ****
--- 1149,1170 ----
        chan->ircnet_status|= CHAN_NOUSERINVITES;
      else if (!strcmp(item[i], "+userinvites"))
        chan->ircnet_status&= ~CHAN_NOUSERINVITES;
+     else if ((!strcmp(item[i], udef1_on) && strlen(chan_udef1) > 0) || !strcmp(item[i], "+udef1"))
+       chan->status |= CHAN_UDEF1;
+     else if ((!strcmp(item[i], udef1_off) && strlen(chan_udef1) > 0) || !strcmp(item[i], "-udef1"))
+       chan->status &= ~CHAN_UDEF1;
+     else if ((!strcmp(item[i], udef2_on) && strlen(chan_udef2) > 0) || !strcmp(item[i], "+udef2"))
+       chan->status |= CHAN_UDEF2;
+     else if ((!strcmp(item[i], udef2_off) && strlen(chan_udef2) > 0) || !strcmp(item[i], "-udef2"))
+       chan->status &= ~CHAN_UDEF2;
+     else if ((!strcmp(item[i], udef3_on) && strlen(chan_udef3) > 0) || !strcmp(item[i], "+udef3"))
+       chan->status |= CHAN_UDEF3;
+     else if ((!strcmp(item[i], udef3_off) && strlen(chan_udef3) > 0) || !strcmp(item[i], "-udef3"))
+       chan->status &= ~CHAN_UDEF3;
+     else if ((!strcmp(item[i], udef4_on) && strlen(chan_udef4) > 0) || !strcmp(item[i], "+udef4"))
+       chan->status |= CHAN_UDEF4;
+     else if ((!strcmp(item[i], udef4_off) && strlen(chan_udef4) > 0) || !strcmp(item[i], "-udef4"))
+       chan->status &= ~CHAN_UDEF4;
      else if (!strncmp(item[i], "flood-", 6)) {
        int *pthr = 0, *ptime;
        char *p;


More information about the Patches mailing list