[eggheads-patches] PATCH: tcl_chnick.patch

Peter 'Rattacresh' Backes rtc at rhrk.uni-kl.de
Thu Oct 7 14:36:33 CST 1999


Items marked as '#' are changes towards the philosophy of 
botrec2.patch

# allow to change +b's to our nick if currently not connected
* strcasecmp for ircnick, rfc_casecmp for botnetnick. Should be vice 
versa
* Let tcl_chnick change any nick to our current irc nick as cmd_nick 
and cmd_chnick allow it, too...
* Someone replaced the invalid prefixes string in 1.3.28 by a 
BADNICKCHARS variable, but only in cmds.c. Someone else added two 
chars to BADNICKHARS which of course didn't take any effect in 
tcluser.c... So I moved it to eggdrop.h and replaced the prefix char 
string in tclusers.h by BADNICKCHARS, too.
* renamed BADNICKCHARS to BADHANDCHARS to avoid confusion.
* renamed variable 'nick' to 'newnick' in tcl_chnick to be more like 
cmd_chnick.


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

-------------- next part --------------
diff -urN eggdrop1.3.29/doc/UPDATES1.3 eggdrop1.3.29+tcl_chnick/doc/UPDATES1.3
--- eggdrop1.3.29/doc/UPDATES1.3	Thu Oct  7 16:12:38 1999
+++ eggdrop1.3.29+tcl_chnick/doc/UPDATES1.3	Thu Oct  7 16:13:34 1999
@@ -4,6 +4,7 @@
 
 1.3.29
 Foundby   Fixedby   What....
+          rtc       fixed tcl_chnick, new +b/botnetnick philisophy
 Ben       Fabian    eggdrop.conf.dist now talks positively about allow-resync
           rtc       fixed .console to not allow channels starting with '*'.
 SuperS	  Fabian    if run with '-n', eggdrop now only prints every line once
diff -urN eggdrop1.3.29/src/cmds.c eggdrop1.3.29+tcl_chnick/src/cmds.c
--- eggdrop1.3.29/src/cmds.c	Thu Oct  7 16:12:45 1999
+++ eggdrop1.3.29+tcl_chnick/src/cmds.c	Thu Oct  7 15:56:53 1999
@@ -30,8 +30,6 @@
 extern char network[], owner[], spaces[];
 extern time_t now, online_since;
 
-#define BADNICKCHARS "-,+*=:!.@#;$%&"
-
 /* add hostmask to a bot's record if possible */
 static int add_bot_hostmask(int idx, char *nick)
 {
@@ -737,7 +735,7 @@
       handle[HANDLEN] = 0;	/* max len = XX .. for the moment :) */
     if (get_user_by_handle(userlist, handle))
       dprintf(idx, "Someone already exists by that name.\n");
-    else if (strchr(BADNICKCHARS, handle[0]) != NULL)
+    else if (strchr(BADHANDCHARS, handle[0]) != NULL)
       dprintf(idx, "You can't start a botnick with '%c'.\n", handle[0]);
     else {
       if (strlen(addr) > 60)
@@ -795,7 +793,7 @@
   for (i = 0; i < strlen(newhand); i++)
     if ((newhand[i] <= 32) || (newhand[i] >= 127) || (newhand[i] == '@'))
       newhand[i] = '?';
-  if (strchr(BADNICKCHARS, newhand[0]) != NULL)
+  if (strchr(BADHANDCHARS, newhand[0]) != NULL)
     dprintf(idx, "Bizarre quantum forces prevent nicknames from starting with %c\n",
            newhand[0]);
   else if (get_user_by_handle(userlist, newhand) &&
@@ -839,7 +837,7 @@
   for (i = 0; i < strlen(newnick); i++)
     if ((newnick[i] <= 32) || (newnick[i] >= 127) || (newnick[i] == '@'))
       newnick[i] = '?';
-  if (strchr(BADNICKCHARS, newnick[0]) != NULL) {
+  if (strchr(BADHANDCHARS, newnick[0]) != NULL) {
     dprintf(idx, "Bizarre quantum forces prevent nicknames from starting with '%c'\n",
 	    newnick[0]);
   } else if (get_user_by_handle(userlist, newnick) &&
@@ -2266,7 +2264,7 @@
     handle[HANDLEN] = 0;	/* max len = XX */
   if (get_user_by_handle(userlist, handle)) {
     dprintf(idx, "Someone already exists by that name.\n");
-  } else if (strchr(BADNICKCHARS, handle[0]) != NULL) {
+  } else if (strchr(BADHANDCHARS, handle[0]) != NULL) {
     dprintf(idx, "You can't start a nick with '%c'.\n", handle[0]);
   } else {
     putlog(LOG_CMDS, "*", "#%s# +user %s %s", dcc[idx].nick, handle, host);
diff -urN eggdrop1.3.29/src/eggdrop.h eggdrop1.3.29+tcl_chnick/src/eggdrop.h
--- eggdrop1.3.29/src/eggdrop.h	Thu Oct  7 16:12:45 1999
+++ eggdrop1.3.29+tcl_chnick/src/eggdrop.h	Thu Oct  7 15:55:53 1999
@@ -35,6 +35,7 @@
  */
 
 #define HANDLEN		9	/* valid values 9->NICKMAX */
+#define BADHANDCHARS	"-,+*=:!.@#;$%&"
 
 /* handy maximum string lengths */
 #define NICKMAX       15	/* valid values HANDLEN->32 */
diff -urN eggdrop1.3.29/src/tcluser.c eggdrop1.3.29+tcl_chnick/src/tcluser.c
--- eggdrop1.3.29/src/tcluser.c	Thu Oct  7 16:12:45 1999
+++ eggdrop1.3.29+tcl_chnick/src/tcluser.c	Thu Oct  7 15:57:05 1999
@@ -361,7 +361,7 @@
 
 static int tcl_chnick STDVAR {
   struct userrec *u;
-  char hand[HANDLEN + 1];
+  char newhand[HANDLEN + 1];
   int x = 1, i;
 
   context;
@@ -370,24 +370,25 @@
   if (!u)
      x = 0;
   else {
-    strncpy(hand, argv[2], HANDLEN);
-    hand[HANDLEN] = 0;
-    for (i = 0; i < strlen(hand); i++)
-      if ((hand[i] <= 32) || (hand[i] >= 127) || (hand[i] == '@'))
-	hand[i] = '?';
-    if (strchr("-,+*=:!.@#;$", hand[0]) != NULL)
+    strncpy(newhand, argv[2], HANDLEN);
+    newhand[HANDLEN] = 0;
+    for (i = 0; i < strlen(newhand); i++)
+      if ((newhand[i] <= 32) || (newhand[i] >= 127) || (newhand[i] == '@'))
+	newhand[i] = '?';
+    if (strchr(BADHANDCHARS, newhand[0]) != NULL)
       x = 0;
-    else if (strlen(hand) < 1)
+    else if (strlen(newhand) < 1)
       x = 0;
-    else if (get_user_by_handle(userlist, hand))
+    else if (get_user_by_handle(userlist, newhand))
       x = 0;
-    else if (!strcasecmp(origbotname, hand) || !rfc_casecmp(botnetnick, hand))
+    else if (!strcasecmp(botnetnick, newhand) && (!(u->flags & USER_BOT) || 
+             nextbot (argv [1]) != -1))
       x = 0;
-    else if (hand[0] == '*')
+    else if (newhand[0] == '*')
       x = 0;
   }
   if (x)
-     x = change_handle(u, hand);
+     x = change_handle(u, newhand);
 
   Tcl_AppendResult(irp, x ? "1" : "0", NULL);
   return TCL_OK;


More information about the Patches mailing list