[eggheads-patches] PATCH: chanmeta.patch

Peter 'Rattacresh' Backes rtc at rhrk.uni-kl.de
Fri Oct 8 19:50:22 CST 1999


requires tcl_chnick.patch (which should be used in conjunction with 
botrec2.patch).

* More fixes for modeless + channels
* .chattr doesn't reset the channel if no changes have been made.
* You get the correct error message if you .chattr lamer |xyz and 
lamer has an invalid console channel.
* .botattr bot +s #test was changing global +s.
* .botattr bot |+s with conchan = '*' complained about invalid 
channel.
* userrec.c:change_chandle didn't check for some illegal prefix 
chars, now uses BADHANDCHARS.
* probably more...


-- Peter 'Rattacresh' Backes, rtc at rhrk.uni-kl.de

-------------- next part --------------
diff -urN eggdrop1.3.29/doc/UPDATES1.3 eggdrop1.3.29+chanmeta/doc/UPDATES1.3
--- eggdrop1.3.29/doc/UPDATES1.3	Fri Oct  8 17:32:10 1999
+++ eggdrop1.3.29+chanmeta/doc/UPDATES1.3	Fri Oct  8 17:38:22 1999
@@ -4,6 +4,8 @@
 
 1.3.29
 Foundby   Fixedby   What....
+          rtc       several changes for modeless +channels, 
+                    fixed bugs in .chattr/.botattr
           dw        kicks weren't being logged
           rtc       added assert debugging feature
 	  Fabian    main() wasn't removing unknown sockets correctly
diff -urN eggdrop1.3.29/src/cmds.c eggdrop1.3.29+chanmeta/src/cmds.c
--- eggdrop1.3.29/src/cmds.c	Fri Oct  8 17:32:13 1999
+++ eggdrop1.3.29+chanmeta/src/cmds.c	Fri Oct  8 17:38:38 1999
@@ -628,7 +628,9 @@
   get_user_flagrec(u, &fr, dcc[idx].u.chat->con_chan);
   strcpy(s1, par);
   nick = newsplit(&par);
-  if (nick[0] && !strchr("#&+-*", nick[0]) && glob_master(fr)) {
+  /* don't remove '+' as someone couldn't have '+' in CHANMETA cause 
+   * he doesn't use br0ken IRCnet ++rtc */
+  if (nick[0] && !strchr(CHANMETA "+-*", nick[0]) && glob_master(fr)) {
     for (i = 0; i < dcc_total; i++)
       if (!strcasecmp(nick, dcc[i].nick) &&
 	  (dcc[i].type == &DCC_CHAT) && (!ok)) {
@@ -644,7 +646,9 @@
     dest = idx;
   if (!nick[0])
     nick = newsplit(&par);
-  if (strchr("#&*", nick[0])) {
+  /* ugly hack for stupid modeless channels ++rtc */
+  if ((nick [0] == '+' && findchan(nick)) || 
+      (nick [0] != '+' && strchr(CHANMETA "*", nick[0]))) {
     if (strcmp(nick, "*") && !findchan(nick)) {
       dprintf(idx, "Invalid console channel: %s\n", nick);
       return;
@@ -1399,7 +1403,7 @@
 
 static void cmd_chattr(struct userrec *u, int idx, char *par)
 {
-  char *hand, *tmpchg = NULL, *chg = NULL, work[1024];
+  char *hand, *arg = NULL, *tmpchg = NULL, *chg = NULL, work[1024];
   struct chanset_t *chan = NULL;
   struct userrec *u2;
   struct flag_record pls = {0, 0, 0, 0, 0, 0},
@@ -1414,47 +1418,75 @@
   }
   hand = newsplit(&par);
   u2 = get_user_by_handle(userlist, hand);
-  if ((hand[0] == '*') || !u2) {
+  if (!u2) {
     dprintf(idx, "No such user!\n");
     return;
   }
-  if (par[0] && ((strchr(CHANMETA, par[0]) == NULL) || par[0]=='+')) {
-    chg = newsplit(&par);
-    if (!par[0] && strpbrk(chg, "&|"))
-      par = dcc[idx].u.chat->con_chan;
-     else if (par[0] && !strpbrk(chg, "&|")) {
-       context;
-       tmpchg = nmalloc(sizeof(chg)+1);
-       sprintf(tmpchg,"|%s",chg);
-       chg = nmalloc(sizeof(tmpchg));
-       strcpy(chg,tmpchg);
-     }
-  }
-  chan = findchan(par);
-  if (!chan && par[0] && (par[0] != '*')) {
-    dprintf(idx, "No channel record for %s.\n", par);
-    if (tmpchg) {
-      nfree(chg); nfree(tmpchg);
-    }
+
+  /* Parse args */
+  if (par[0]) {
+    arg = newsplit (&par);
+    if (par[0]) {
+      /* .chattr <handle> <changes> <channel> */
+      chg = arg;
+      arg = newsplit (&par);
+      chan = findchan (arg);
+    } else {
+      chan = findchan (arg);
+      /* ugly hack for stupid modeless channels ++rtc */
+      if (!(arg[0] == '+' && chan) &&
+          !(arg[0] != '+' && strchr (CHANMETA, arg[0]))) {
+	/* .chattr <handle> <changes> */
+        chg = arg;
+        chan = NULL; /* uh, !strchr (CHANMETA, channel[0]) && channel found?? */
+	arg = NULL;
+      }
+      /* .chattr <handle> <channel>: nothing to do... */
+    }
+  }
+  /* arg:  pointer to channel name, NULL if none specified
+   * chan: pointer to channel structure, NULL if none found or none specified
+   * chg:  pointer to changes, NULL if none specified
+   */
+  ASSERT (!(arg == NULL && chan != NULL));
+  if (arg && !chan) {
+    dprintf(idx, "No channel record for %s.\n", arg);
     return;
   }
+  if (chg) {
+    if (!arg && strpbrk(chg, "&|")) {
+      /* .chattr <handle> *[&|]*: use console channel if found... */
+      if (!strcmp ((arg = dcc[idx].u.chat->con_chan), "*"))
+        arg = NULL;
+      else
+        chan = findchan (arg);
+      if (arg && !chan) {
+        dprintf (idx, "Invalid console channel %s.\n", arg);
+	return;
+      }
+    } else if (arg && !strpbrk(chg, "&|")) {
+      context;
+      tmpchg = nmalloc(sizeof(chg)+1);
+      sprintf(tmpchg,"|%s",chg);
+      chg = tmpchg;
+    }
+  }
+  par = arg;
   user.match = FR_GLOBAL;
   if (chan)
     user.match |= FR_CHAN;
   get_user_flagrec(u, &user, chan ? chan->name : 0);
   if (!chan && !glob_botmast(user)) {
     dprintf(idx, "You do not have Bot Master privileges.\n");
-    if (tmpchg) {
-      nfree(chg); nfree(tmpchg);
-    }
+    if (tmpchg)
+      nfree(tmpchg);
     return;
   }
   if (chan && !glob_master(user) && !chan_master(user)) {
     dprintf(idx, "You do not have channel master privileges for channel %s\n",
 	    par);
-    if (tmpchg) {
-      nfree(chg); nfree(tmpchg);
-    }
+    if (tmpchg)
+      nfree(tmpchg);
     return;
   }
   user.match &= fl;
@@ -1462,24 +1494,24 @@
     pls.match = user.match;
     break_down_flags(chg, &pls, &mns);
     /* no-one can change these flags on-the-fly */
-    pls.global &=~(USER_BOT);
-    mns.global &=~(USER_BOT);
+    pls.global &= ~(USER_BOT);
+    mns.global &= ~(USER_BOT);
 
     if (chan) {
       pls.chan &= ~(BOT_SHARE);
       mns.chan &= ~(BOT_SHARE);
     }
     if (!glob_owner(user)) {
-      pls.global &=~(USER_OWNER | USER_MASTER | USER_BOTMAST | USER_UNSHARED);
-      mns.global &=~(USER_OWNER | USER_MASTER | USER_BOTMAST | USER_UNSHARED);
+      pls.global &= ~(USER_OWNER | USER_MASTER | USER_BOTMAST | USER_UNSHARED);
+      mns.global &= ~(USER_OWNER | USER_MASTER | USER_BOTMAST | USER_UNSHARED);
 
       if (chan) {
 	pls.chan &= ~USER_OWNER;
 	mns.chan &= ~USER_OWNER;
       }
       if (!glob_master(user)) {
-	pls.global &=USER_PARTY | USER_XFER;
-	mns.global &=USER_PARTY | USER_XFER;
+	pls.global &= USER_PARTY | USER_XFER;
+	mns.global &= USER_PARTY | USER_XFER;
 
 	if (!glob_botmast(user)) {
 	  pls.global = 0;
@@ -1542,21 +1574,20 @@
 	      chan->name, work);
     else
       dprintf(idx, "No flags for %s on %s.\n", hand, chan->name);
-    if ((me = module_find("irc", 0, 0))) {
+    if (chg && (me = module_find("irc", 0, 0))) {
       Function *func = me->funcs;
 
       if (chan)
 	(func[IRC_RECHECK_CHANNEL]) (chan, 0);
     }
   }
-  if (tmpchg) {
-      nfree(chg); nfree(tmpchg);
-    }
+  if (tmpchg)
+    nfree(tmpchg);
 }
 
 static void cmd_botattr(struct userrec *u, int idx, char *par)
 {
-  char *hand, *chg = NULL, work[1024];
+  char *hand, *chg = NULL, *arg = NULL, *tmpchg = NULL, work[1024];
   struct chanset_t *chan = NULL;
   struct userrec *u2;
   struct flag_record pls =
@@ -1571,7 +1602,7 @@
   }
   hand = newsplit(&par);
   u2 = get_user_by_handle(userlist, hand);
-  if ((hand[0] == '*') || !u2 || !(u2->flags & USER_BOT)) {
+  if (!u2 || !(u2->flags & USER_BOT)) {
     dprintf(idx, "No such bot!\n");
     return;
   }
@@ -1579,22 +1610,67 @@
     if (!strcasecmp(dcc[idx2].nick, hand))
       break;
   if (idx2 != dcc_total) {
-    dprintf(idx, "You may not change the attributes of a linked bot.\n");
+    dprintf(idx, "You may not change the attributes of a directly linked bot.\n");
     return;
   }
-  if (par[0] && ((strchr(CHANMETA, par[0]) == NULL) || par[0]=='+')) {
-    chg = newsplit(&par);
-    if (!par[0] && strpbrk(chg, "|&"))
-      par = dcc[idx].u.chat->con_chan;
-  }
-  if (!(chan = findchan(par)) && par[0]) {
-    dprintf(idx, "No channel record for %s.\n", par);
+  /* Parse args */
+  if (par[0]) {
+    arg = newsplit (&par);
+    if (par[0]) {
+      /* .botattr <handle> <changes> <channel> */
+      chg = arg;
+      arg = newsplit (&par);
+      chan = findchan (arg);
+    } else {
+      chan = findchan (arg);
+      /* ugly hack for stupid modeless channels ++rtc */
+      if (!(arg[0] == '+' && chan) &&
+          !(arg[0] != '+' && strchr (CHANMETA, arg[0]))) {
+	/* .botattr <handle> <changes> */
+        chg = arg;
+        chan = NULL; /* uh, !strchr (CHANMETA, channel[0]) && channel found?? */
+	arg = NULL;
+      }
+      /* .botattr <handle> <channel>: nothing to do... */
+    }
+  }
+  /* arg:  pointer to channel name, NULL if none specified
+   * chan: pointer to channel structure, NULL if none found or none specified
+   * chg:  pointer to changes, NULL if none specified
+   */
+  ASSERT (!(arg == NULL && chan != NULL));
+
+  if (arg && !chan) {
+    dprintf(idx, "No channel record for %s.\n", arg);
     return;
   }
+
+  if (chg) {
+    if (!arg && strpbrk(chg, "&|")) {
+      /* botattr <handle> *[&|]*: use console channel if found... */
+      if (!strcmp ((arg = dcc[idx].u.chat->con_chan), "*"))
+        arg = NULL;
+      else
+        chan = findchan (arg);
+      if (arg && !chan) {
+        dprintf (idx, "Invalid console channel %s.\n", arg);
+	return;
+      }
+    } else if (arg && !strpbrk(chg, "&|")) {
+      context;
+      tmpchg = nmalloc(sizeof(chg)+1);
+      sprintf(tmpchg,"|%s",chg);
+      chg = tmpchg;
+    }
+  }
+  par = arg;
+  
   user.match = FR_GLOBAL;
   get_user_flagrec(u, &user, chan ? chan->name : 0);
   if (!glob_botmast(user)) {
     dprintf(idx, "You do not have Bot Master privileges.\n");
+    if (tmpchg)
+      nfree(tmpchg);
     return;
   }
   if (chg) {
@@ -1652,6 +1728,8 @@
     else
       dprintf(idx, "No bot flags for %s on %s.\n", hand, chan->name);
   }
+  if (tmpchg)
+    nfree(tmpchg);
 }
 
 static void cmd_chat(struct userrec *u, int idx, char *par)
diff -urN eggdrop1.3.29/src/mod/irc.mod/chan.c eggdrop1.3.29+chanmeta/src/mod/irc.mod/chan.c
--- eggdrop1.3.29/src/mod/irc.mod/chan.c	Fri Oct  8 17:32:11 1999
+++ eggdrop1.3.29+chanmeta/src/mod/irc.mod/chan.c	Fri Oct  8 15:21:37 1999
@@ -1886,7 +1886,7 @@
   {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
   int ignoring;
 
-  if (!strchr("#&+@", *msg))
+  if (!strchr(CHANMETA "@", *msg))
     return 0;
   ignoring = match_ignore(from);
   to = newsplit(&msg);
diff -urN eggdrop1.3.29/src/userrec.c eggdrop1.3.29+chanmeta/src/userrec.c
--- eggdrop1.3.29/src/userrec.c	Fri Oct  8 17:32:13 1999
+++ eggdrop1.3.29+chanmeta/src/userrec.c	Fri Oct  8 15:21:37 1999
@@ -543,7 +543,7 @@
   if (!u)
     return 0;
   /* nothing that will confuse the userfile */
-  if ((newh[1] == 0) && strchr("+*:=.-#&", newh[0]))
+  if ((newh[1] == 0) && strchr(BADHANDCHARS, newh[0]))
     return 0;
   check_tcl_nkch(u->handle, newh);
   /* yes, even send bot nick changes now: */


More information about the Patches mailing list