[eggheads-patches] -ban/exempt/invite stuff

Sven Trenkel Sven.Trenkel at tu-clausthal.de
Sat Mar 8 22:24:42 CST 2003


There are two minor problems with the -ban/exempt/invite partyline
command (eggdrop v1.6.14+statuscleanups):
1. -ban <number> only works with global bans, not with channel or
dynamic bans
2. -ban/exempt/invite <number> deletes the entry in the bot but does not
remove the ban/whatever from the channel, because the number instead of
the mask is sent to the server

There's one more thing, but I'm not sure, if it's supposed to be that
way or not: The bot never bounces channelmodes set by an owner, but it
does sometimes bounce modes set by a script (eg +o in a +bitch channel).
Is that okay?


CU
   Sven
-- 
Today's experiment ..... failed!
-------------- next part --------------
diff -ur eggdrop1.6.original/src/mod/channels.mod/channels.c eggdrop1.6.modified/src/mod/channels.mod/channels.c
--- eggdrop1.6.original/src/mod/channels.mod/channels.c Sat Mar  8 06:00:06 2003
+++ eggdrop1.6.modified/src/mod/channels.mod/channels.c Sun Mar  9 03:48:20 2003
@@ -31,6 +31,7 @@
 static Function *global = NULL;
 
 static char chanfile[121], glob_chanmode[64];
+static char *lastdeletedmask;
 
 static struct udef_struct *udef;
 
@@ -796,6 +797,8 @@
 {
   write_channels();
   free_udef(udef);
+  if (lastdeletedmask)
+    nfree(lastdeletedmask);
   rem_builtins(H_chon, my_chon);
   rem_builtins(H_dcc, C_dcc_irc);
   rem_tcl_commands(channels_cmds);
@@ -903,6 +906,7 @@
   global_aop_min = 5;
   global_aop_max = 30;
   setstatic = 0;
+  lastdeletedmask = 0;
   use_info = 1;
   strcpy(chanfile, "chanfile");
   chan_hack = 0;
diff -ur eggdrop1.6.original/src/mod/channels.mod/cmdschan.c eggdrop1.6.modified/src/mod/channels.mod/cmdschan.c
--- eggdrop1.6.original/src/mod/channels.mod/cmdschan.c Sat Mar  8 06:00:06 2003
+++ eggdrop1.6.modified/src/mod/channels.mod/cmdschan.c Sun Mar  9 05:17:19 2003
@@ -423,7 +423,7 @@
 {
   int console = 0, i = 0, j;
   struct chanset_t *chan = NULL;
-  char s[UHOSTLEN], *ban, *chname;
+  char s[UHOSTLEN], *ban, *chname, *mask;
   masklist *b;
 
   if (!par[0]) {
@@ -451,10 +451,12 @@
   if (console) {
     i = u_delban(NULL, s, (u->flags & USER_MASTER));
     if (i > 0) {
-      putlog(LOG_CMDS, "*", "#%s# -ban %s", dcc[idx].nick, s);
-      dprintf(idx, "%s: %s\n", IRC_REMOVEDBAN, s);
+      if (lastdeletedmask) mask = lastdeletedmask;
+      else mask = s;
+      putlog(LOG_CMDS, "*", "#%s# -ban %s", dcc[idx].nick, mask);
+      dprintf(idx, "%s: %s\n", IRC_REMOVEDBAN, mask);
       for (chan = chanset; chan != NULL; chan = chan->next)
-        add_mode(chan, '-', 'b', s);
+        add_mode(chan, '-', 'b', mask);
       return;
     }
   }
@@ -465,13 +467,15 @@
     dprintf(idx, "Invalid channel.\n");
     return;
   }
-  if (atoi(ban) > 0) {
-    egg_snprintf(s, sizeof s, "%d", -i);
+  if ((i = atoi(ban)) > 0) {
+    egg_snprintf(s, sizeof s, "%d", i);
     j = u_delban(chan, s, 1);
     if (j > 0) {
-      putlog(LOG_CMDS, "*", "#%s# (%s) -ban %s", dcc[idx].nick, chan->dname, s);
-      dprintf(idx, "Removed %s channel ban: %s\n", chan->dname, s);
-      add_mode(chan, '-', 'b', s);
+      if (lastdeletedmask) mask = lastdeletedmask;
+      else mask = s;
+      putlog(LOG_CMDS, "*", "#%s# (%s) -ban %s", dcc[idx].nick, chan->dname, mask);
+      dprintf(idx, "Removed %s channel ban: %s\n", chan->dname, mask);
+      add_mode(chan, '-', 'b', mask);
       return;
     }
     i = 0;
@@ -513,9 +517,9 @@
 
 static void cmd_mns_exempt(struct userrec *u, int idx, char *par)
 {
-  int i = 0, j;
+  int console = 0, i = 0, j;
   struct chanset_t *chan = NULL;
-  char s[UHOSTLEN], *exempt, *chname;
+  char s[UHOSTLEN], *exempt, *chname, *mask;
   masklist *e;
 
   if (!use_exempts) {
@@ -529,8 +533,10 @@
   exempt = newsplit(&par);
   if (par[0] && strchr(CHANMETA, par[0]))
     chname = newsplit(&par);
-  else
+  else {
     chname = dcc[idx].u.chat->con_chan;
+    console = 1;
+  }
   if (chname || !(u->flags & USER_MASTER)) {
     if (!chname)
       chname = dcc[idx].u.chat->con_chan;
@@ -542,26 +548,32 @@
     }
   }
   strncpyz(s, exempt, sizeof s);
-  i = u_delexempt(NULL, s, (u->flags & USER_MASTER));
-  if (i > 0) {
-    putlog(LOG_CMDS, "*", "#%s# -exempt %s", dcc[idx].nick, s);
-    dprintf(idx, "%s: %s\n", IRC_REMOVEDEXEMPT, s);
-    for (chan = chanset; chan != NULL; chan = chan->next)
-      add_mode(chan, '-', 'e', s);
-    return;
+  if (console) {
+    i = u_delexempt(NULL, s, (u->flags & USER_MASTER));
+    if (i > 0) {
+      if (lastdeletedmask) mask = lastdeletedmask;
+      else mask = s;
+      putlog(LOG_CMDS, "*", "#%s# -exempt %s", dcc[idx].nick, mask);
+      dprintf(idx, "%s: %s\n", IRC_REMOVEDEXEMPT, mask);
+      for (chan = chanset; chan != NULL; chan = chan->next)
+        add_mode(chan, '-', 'e', mask);
+      return;
+    }
   }
   /* Channel-specific exempt? */
   if (chname)
     chan = findchan_by_dname(chname);
   if (chan) {
-    if (atoi(exempt) > 0) {
-      egg_snprintf(s, sizeof s, "%d", -i);
+    if ((i = atoi(exempt)) > 0) {
+      egg_snprintf(s, sizeof s, "%d", i);
       j = u_delexempt(chan, s, 1);
       if (j > 0) {
+        if (lastdeletedmask) mask = lastdeletedmask;
+        else mask = s;
         putlog(LOG_CMDS, "*", "#%s# (%s) -exempt %s", dcc[idx].nick,
-               chan->dname, s);
-        dprintf(idx, "Removed %s channel exempt: %s\n", chan->dname, s);
-        add_mode(chan, '-', 'e', s);
+               chan->dname, mask);
+        dprintf(idx, "Removed %s channel exempt: %s\n", chan->dname, mask);
+        add_mode(chan, '-', 'e', mask);
         return;
       }
       i = 0;
@@ -599,15 +611,18 @@
         }
       }
     }
+  } else {
+    dprintf(idx, "Invalid channel.\n");
+    return; 
   }
   dprintf(idx, "No such exemption.\n");
 }
 
 static void cmd_mns_invite(struct userrec *u, int idx, char *par)
 {
-  int i = 0, j;
+  int console = 0, i = 0, j;
   struct chanset_t *chan = NULL;
-  char s[UHOSTLEN], *invite, *chname;
+  char s[UHOSTLEN], *invite, *chname, *mask;
   masklist *inv;
 
   if (!use_invites) {
@@ -621,8 +636,10 @@
   invite = newsplit(&par);
   if (par[0] && strchr(CHANMETA, par[0]))
     chname = newsplit(&par);
-  else
+  else {
     chname = dcc[idx].u.chat->con_chan;
+    console = 1;
+  }
   if (chname || !(u->flags & USER_MASTER)) {
     if (!chname)
       chname = dcc[idx].u.chat->con_chan;
@@ -634,26 +651,32 @@
     }
   }
   strncpyz(s, invite, sizeof s);
-  i = u_delinvite(NULL, s, (u->flags & USER_MASTER));
-  if (i > 0) {
-    putlog(LOG_CMDS, "*", "#%s# -invite %s", dcc[idx].nick, s);
-    dprintf(idx, "%s: %s\n", IRC_REMOVEDINVITE, s);
-    for (chan = chanset; chan != NULL; chan = chan->next)
-      add_mode(chan, '-', 'I', s);
-    return;
+  if (console) {
+    i = u_delinvite(NULL, s, (u->flags & USER_MASTER));
+    if (i > 0) {
+      if (lastdeletedmask) mask = lastdeletedmask;
+      else mask = s;
+      putlog(LOG_CMDS, "*", "#%s# -invite %s", dcc[idx].nick, mask);
+      dprintf(idx, "%s: %s\n", IRC_REMOVEDINVITE, mask);
+      for (chan = chanset; chan != NULL; chan = chan->next)
+        add_mode(chan, '-', 'I', mask);
+      return;
+    }
   }
   /* Channel-specific invite? */
   if (chname)
     chan = findchan_by_dname(chname);
   if (chan) {
-    if (atoi(invite) > 0) {
-      egg_snprintf(s, sizeof s, "%d", -i);
+    if ((i = atoi(invite)) > 0) {
+      egg_snprintf(s, sizeof s, "%d", i);
       j = u_delinvite(chan, s, 1);
       if (j > 0) {
+        if (lastdeletedmask) mask = lastdeletedmask;
+        else mask = s;
         putlog(LOG_CMDS, "*", "#%s# (%s) -invite %s", dcc[idx].nick,
-               chan->dname, s);
-        dprintf(idx, "Removed %s channel invite: %s\n", chan->dname, s);
-        add_mode(chan, '-', 'I', s);
+               chan->dname, mask);
+        dprintf(idx, "Removed %s channel invite: %s\n", chan->dname, mask);
+        add_mode(chan, '-', 'I', mask);
         return;
       }
       i = 0;
@@ -693,6 +716,9 @@
         }
       }
     }
+  } else {
+    dprintf(idx, "Invalid channel.\n");
+    return; 
   }
   dprintf(idx, "No such invite.\n");
 }
diff -ur eggdrop1.6.original/src/mod/channels.mod/userchan.c eggdrop1.6.modified/src/mod/channels.mod/userchan.c
--- eggdrop1.6.original/src/mod/channels.mod/userchan.c Mon Feb 10 06:00:05 2003
+++ eggdrop1.6.modified/src/mod/channels.mod/userchan.c Sun Mar  9 03:46:12 2003
@@ -269,7 +269,9 @@
         nfree(mask);
       }
     }
-    nfree((*u)->mask);
+    if (lastdeletedmask)
+      nfree(lastdeletedmask);
+    lastdeletedmask = (*u)->mask;
     if ((*u)->desc)
       nfree((*u)->desc);
     if ((*u)->user)
@@ -319,7 +321,9 @@
         nfree(mask);
       }
     }
-    nfree((*u)->mask);
+    if (lastdeletedmask)
+      nfree(lastdeletedmask);
+    lastdeletedmask = (*u)->mask;
     if ((*u)->desc)
       nfree((*u)->desc);
     if ((*u)->user)
@@ -370,7 +374,9 @@
         nfree(mask);
       }
     }
-    nfree((*u)->mask);
+    if (lastdeletedmask)
+      nfree(lastdeletedmask);
+    lastdeletedmask = (*u)->mask;
     if ((*u)->desc)
       nfree((*u)->desc);
     if ((*u)->user)


More information about the Patches mailing list