[eggheads-patches] PATCH: action_fix_tcl.diff, alltools_tcl.diff, botchk.diff, compat_tcl.diff, scripts-doc.diff

Tothwolf tothwolf at concentric.net
Wed Oct 6 18:44:00 CST 1999


These are all updates/fixes/minor changes for files in the scripts/ dir.

-Toth
-------------- next part --------------
Index: scripts/action.fix.tcl
===================================================================
RCS file: /usr/local/cvsroot/eggdrop1.3/scripts/action.fix.tcl,v
retrieving revision 1.2
diff -u -r1.2 action.fix.tcl
--- scripts/action.fix.tcl	1999/06/27 20:37:25	1.2
+++ scripts/action.fix.tcl	1999/10/06 23:16:07
@@ -1,13 +1,14 @@
-# cleanup by Tothwolf 25May1999
+# Tothwolf  25May1999: cleanup
+# Tothwolf  04Oct1999: changed proc names slightly
 
 # fix for mirc dcc chat /me's
-bind filt - "\001ACTION *\001" filt_act
-proc filt_act {idx text} {
+bind filt - "\001ACTION *\001" filt:dcc_action
+proc filt:dcc_action {idx text} {
   return ".me [string trim [join [lrange [split $text] 1 end]] \001]"
 }
 
 # fix for telnet session /me's
-bind filt - "/me *" filt_telnet_act
-proc filt_telnet_act {idx text} {
+bind filt - "/me *" filt:telnet_action
+proc filt:telnet_action {idx text} {
   return ".me [join [lrange [split $text] 1 end]]"
 }
-------------- next part --------------
Index: scripts/alltools.tcl
===================================================================
RCS file: /usr/local/cvsroot/eggdrop1.3/scripts/alltools.tcl,v
retrieving revision 1.2
diff -u -r1.2 alltools.tcl
--- scripts/alltools.tcl	1999/10/04 21:25:44	1.2
+++ scripts/alltools.tcl	1999/10/06 23:16:52
@@ -1,33 +1,32 @@
 # All-Tools TCL, includes toolbox.tcl, toolkit.tcl and moretools.tcl
-# toolbox is Authored by cmwagner at sodre.net
-# toolkit is Authored by (Someone claim this)[unknown]
-# moretools is Authored by David Sesno(walker at shell.pcrealm.net)
-# modified for 1.3.0 bots by TG
-# rewritten and updated by Tothwolf 02May1999
-# updated even more by guppy 02May1999
-# fixed what guppy broke and updated again by Tothwolf 02May1999
-# more changes from Tothwolf 24/25May1999
-# reversed some of these weird changes and more fixes by rtc 20Sep1999
-# version for 1.3 bots only by rtc 24Sep1999
-
+# toolbox was authored by cmwagner at sodre.net
+# toolkit was authored by (Someone claim this)[unknown]
+# moretools was authored by David Sesno(walker at shell.pcrealm.net)
+#
+# TG        ?????????: modified for 1.3.0 bots
+# Tothwolf  02May1999: rewritten and updated
+# guppy     02May1999: updated even more
+# Tothwolf  02May1999: fixed what guppy broke and updated again
+# Tothwolf  24/25May1999: more changes
+# rtc       20Sep1999: added isnumber, changes
+# dw        ??Sep1999: use regexp for isnumber checking
+# Tothwolf  06Oct1999: optimized completely
+#
 ########################################
 # Descriptions of avaliable commands:
-## (removed from toolkit):
-# newflag <flag> - REMOVED numeric flags are no longer supported in this way
-#
 ## (toolkit):
-# putmsg <nick> <text>
-#   send a message to someone on irc
+# putmsg <nick/chan> <text>
+#   send a privmsg to the given nick or channel
 #
-# putchan <channel> <text>
-#   send a public message to a channel
-#   technically identical to putmsg
+# putchan <nick/chan> <text>
+#   send a privmsg to the given nick or channel
+#   (for compat only, this is the same as 'putmsg' above)
 #
-# putnotc <nick/channel> <text>
-#   send a notice to a nick/channel
+# putnotc <nick/chan> <text>
+#   send a notice to the given nick or channel
 #
-# putact <nick/channel> <text>
-#   send an action to a nick/channel
+# putact <nick/chan> <text>
+#   send an action to the given nick or channel
 #
 ## (toolbox):
 # strlwr <string>
@@ -54,34 +53,31 @@
 #
 # timerexists <command>
 #   if the given command is scheduled by a timer, return its timer id
-#   else return ""
+#   else return empty string
 #
 # utimerexists <command>
 #   if the given command is scheduled by a utimer, return its utimer id
-#   else return ""
+#   else return empty string
 #
 # inchain <bot>
 #   if the given bot is connected to the botnet, return 1
 #   else return 0
+#   (for compat only, same as 'islinked')
 #
 # randstring <length>
 #   returns a random string of the given length
 #
 # putdccall <text>
 #   send the given text to all dcc users
-#   returns nothing
 #
 # putdccbut <idx> <text>
 #   send the given text to all dcc users except for the given idx
-#   returns nothing
 #
 # killdccall
 #   kill all dcc user connections
-#   returns nothing
 #
 # killdccbut <idx>
 #   kill all dcc user connections except for the given idx
-#   returns nothing
 #
 ## (moretools):
 # iso <nick> <channel>
@@ -91,8 +87,8 @@
 # realtime [format]
 #   'time' returns the current time in 24 hour format '14:15'
 #   'date' returns the current date in the format '21 Dec 1994'
-#   not specifying any format will return the current time
-#   in 12 hour format '1:15 am'
+#   not specifying any format will return the current time in
+#   12 hour format '1:15 am'
 #
 # testip <ip>
 #   if the given ip is valid, return 1
@@ -100,122 +96,74 @@
 #
 # number_to_number <number>
 #   if the given number is between 1 and 15, return its analog representation
-#   else it returns what it gets.
+#   else return the number given
 #
-## other
+## (other commands):
 # isnumber <string>
-#   returns 1 if 'string' is a number, 0 if not
+#   if the given string is a valid number, return 1
+#   else return 0
 #
 ########################################
 
 # So scripts can see if allt is loaded.
 set alltools_loaded 1
-set allt_version 205
+set allt_version 204
 
 # For backward comptibility.
 set toolbox_revision 1007
 set toolbox_loaded 1
 set toolkit_loaded 1
-
-# Procs.............
-proc number_to_number {number} {
-  switch -- $number {
-    "0" {return "Zero"}
-    "1" {return "One"}
-    "2" {return "Two"}
-    "3" {return "Three"}
-    "4" {return "Four"}
-    "5" {return "Five"}
-    "6" {return "Six"}
-    "7" {return "Seven"}
-    "8" {return "Eight"}
-    "9" {return "Nine"}
-    "10" {return "Ten"}
-    "11" {return "Eleven"}
-    "12" {return "Twelve"}
-    "13" {return "Thirteen"}
-    "14" {return "Fourteen"}
-    "15" {return "Fifteen"}
-    default {return $number}
-  }
-}
-
-proc isnumber {string} {
-  return [expr {![regexp \[^0-9\] $string] && $string != ""}]
-}
-
-proc testip {address} {
-  set testhost [split $address "."]
-  if {[llength $testhost] != 4} {return 0}
-  foreach part $testhost {
-    # >= 0 is just for undertandability, not really needed.
-    if {[string length $part] > 3 || ![isnumber $part] || !($part >= 0 && $part <= 255)} {
-      return 0
-    }
-  }
-  return 1
-}
 
-proc realtime {{type ""}} {
-  switch -- $type {
-    time {
-      return [clock format [clock seconds] -format "%H:%M"]
-    }
-    date {
-      return [clock format [clock seconds] -format "%d %b %Y"]
-    }
-    "" {
-      return [clock format [clock seconds] -format "%I:%M %P"]
-    }
-  }
-}
+#
+# toolbox:
+#
 
-proc iso {nick chan} {
-  return [matchattr [nick2hand $nick $chan] o|o $chan]
+proc putmsg {dest text} {
+  puthelp "PRIVMSG $dest :$text"
 }
 
-proc putmsg {target text} {
-  putserv "PRIVMSG $target :$text"
+proc putchan {dest text} {
+  puthelp "PRIVMSG $dest :$text"
 }
 
-proc putnotc {target text} {
-  putserv "NOTICE $target :$text"
+proc putnotc {dest text} {
+  puthelp "NOTICE $dest :$text"
 }
 
-proc putchan {target text} {
-  putserv "PRIVMSG $target :$text"
+proc putact {dest text} {
+  puthelp "PRIVMSG $dest :\001ACTION $text\001"
 }
 
-proc putact {target text} {
-  putserv "PRIVMSG $target :\001ACTION $text\001"
-}
+#
+# toolkit:
+#
 
 proc strlwr {string} {
-  return [string tolower $string]
+  string tolower $string
 }
 
 proc strupr {string} {
-  return [string toupper $string]
+  string toupper $string
 }
 
 proc strcmp {string1 string2} {
-  return [string compare $string1 $string2]
+  string compare $string1 $string2
 }
 
 proc stricmp {string1 string2} {
-  return [string compare [string tolower $string1] [string tolower $string2]]
+  string compare [string tolower $string1] [string tolower $string2]
 }
 
 proc strlen {string} {
-  return [string length $string]
+  string length $string
 }
 
 proc stridx {string index} {
-  return [string index $string $index]
+  string index $string $index
 }
 
 proc iscommand {command} {
-  if {[info commands $command] == $command} {
+  if {[string compare [info commands $command] ""]} then {
     return 1
   }
   return 0
@@ -223,35 +171,32 @@
 
 proc timerexists {command} {
   foreach i [timers] {
-    if {[lindex $i 1] == $command} {
+    if {[string compare $command [lindex $i 1]] == 0} then {
       return [lindex $i 2]
     }
   }
-  return ""
+  return
 }
 
 proc utimerexists {command} {
   foreach i [utimers] {
-    if {[lindex $i 1] == $command} {
+    if {[string compare $command [lindex $i 1]] == 0} then {
       return [lindex $i 2]
     }
   }
-  return ""
+  return
 }
 
 proc inchain {bot} {
-  return [islinked $bot]
+  islinked $bot
 }
 
 proc randstring {length} {
-  # [rtc] not for tcllib as rand is an eggdrop extension
-  set result ""
   set chars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
   set count [string length $chars]
   for {set i 0} {$i < $length} {incr i} {
     append result [string index $chars [rand $count]]
   }
-  return $result
 }
 
 proc putdccall {text} {
@@ -263,7 +208,7 @@
 proc putdccbut {idx text} {
   foreach i [dcclist CHAT] {
     set j [lindex $i 0]
-    if {$j != $idx} {
+    if {$j != $idx} then {
       putdcc $j $text
     }
   }
@@ -278,9 +223,114 @@
 proc killdccbut {idx} {
   foreach i [dcclist CHAT] {
     set j [lindex $i 0]
-    if {$j != $idx} {
+    if {$j != $idx} then {
       killdcc $j
     }
   }
 }
 
+#
+# moretools:
+#
+
+proc iso {nick chan} {
+  matchattr [nick2hand $nick $chan] o|o $chan
+}
+
+proc realtime {args} {
+  switch -exact -- $args {
+    time {
+      strftime "%H:%M"
+    }
+    date {
+      strftime "%d %b %Y"
+    }
+    default {
+      strftime "%I:%M %P"
+    }
+  }
+}
+
+proc testip {ip} {
+  set tmp [split $ip .]
+  if {[llength $tmp] != 4} then {
+    return 0
+  }
+  set index 0
+  foreach i $tmp {
+    if {((![regexp \[^0-9\] $i]) || ([string length $i] > 3) ||
+         (($index == 3) && (($i > 254) || ($i < 1))) ||
+         (($index <= 2) && (($i > 255) || ($i < 0))))} then {
+      return 0
+    }
+    incr index
+  }
+  return 1
+}
+
+proc number_to_number {number} {
+  switch -exact -- $number {
+    0 {
+      return Zero
+    }
+    1 {
+      return One
+    }
+    2 {
+      return Two
+    }
+    3 {
+      return Three
+    }
+    4 {
+      return Four
+    }
+    5 {
+      return Five
+    }
+    6 {
+      return Six
+    }
+    7 {
+      return Seven
+    }
+    8 {
+      return Eight
+    }
+    9 {
+      return Nine
+    }
+    10 {
+      return Ten
+    }
+    11 {
+      return Eleven
+    }
+    12 {
+      return Twelve
+    }
+    13 {
+      return Thirteen
+    }
+    14 {
+      return Fourteen
+    }
+    15 {
+      return Fifteen
+    }
+    default {
+      return $number
+    }
+  }
+}
+
+#
+# other commands:
+#
+
+proc isnumber {string} {
+  if {([string compare $string ""]) && (![regexp \[^0-9\] $string])} then {
+    return 1
+  }
+  return 0
+}
-------------- next part --------------
Index: scripts/botchk
===================================================================
RCS file: /usr/local/cvsroot/eggdrop1.3/scripts/botchk,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 botchk
--- scripts/botchk	1999/06/23 19:51:25	1.1.1.1
+++ scripts/botchk	1999/10/06 23:17:32
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# new botchk  (for eggdrop 1.1)
+# new botchk  (for eggdrop 1.1+)
 #
 # This is a script suitable for use in a crontab.  It checks to make sure
 # your bot is running.  YOU NEED A SEPARATE CRON JOB FOR EACH BOT.  If your
@@ -31,41 +31,68 @@
 ########## you probably don't need to change anything below here ##########
 
 cd $botdir
-if test -r pid.$botname; then
+
+# is there a pid file?
+if test -r pid.$botname
+then
   # there is a pid file -- is it current?
   botpid=`cat pid.$botname`
-  if `kill -CHLD $botpid >/dev/null 2>&1`; then
-    # it's still going
-    # back out quietly
+  if `kill -CHLD $botpid >/dev/null 2>&1`
+  then
+    # it's still going -- back out quietly
     exit 0
   fi
   echo ""
-  echo "Stale pid.$botname file (erasing it)"
+  echo "Stale pid.$botname file, erasing..."
   rm -f pid.$botname
-fi
-echo ""
-echo "Couldn't find the bot running.  Reloading it..."
-echo ""
-# Check for userfile first
-if test -r $userfile; then
-   # It's there, load the bot
-  ./$botscript
-  exit 0
 fi
-if test -r $userfile~new; then
-   # Bot f*@!ed up while saving the userfile last time.  Move it over.
-   echo "Userfile missing.  Using last saved userfile..."
-   mv $userfile~new $userfile
-  ./$botscript
-  exit 0
+
+if test -r CANTSTART.$botname
+then
+  if test -r $userfile || test -r $userfile~new || test -r $userfile~bak
+  then
+    echo ""
+    echo "Userfile found, removing check file 'CANTSTART.$botname'..."
+    rm -f CANTSTART.$botname
+  fi
 fi
-if test -r $userfile~bak; then
-   # Userfile is missing, use backup userfile.
-   echo "Userfile missing.  Using backup userfile..."
-   cp $userfile~bak $userfile
-  ./$botscript
-  exit 0
+
+# test if we have run botchk previously and didn't find a userfile
+if test ! -f CANTSTART.$botname
+then
+  echo ""
+  echo "Couldn't find bot '$botname' running, reloading..."
+  echo ""
+  # check for userfile and reload bot if found
+  if test -r $userfile
+  then
+    # It's there, load the bot
+    ./$botscript
+    exit 0
+  else
+    if test -r $userfile~new
+    then
+      # Bot f*@!ed up while saving the userfile last time.  Move it over.
+      echo "Userfile missing.  Using last saved userfile..."
+      mv -f $userfile~new $userfile
+      ./$botscript
+      exit 0
+    else
+      if test -r $userfile~bak
+      then
+        # Userfile is missing, use backup userfile.
+        echo "Userfile missing.  Using backup userfile..."
+        cp -f $userfile~bak $userfile
+        ./$botscript
+        exit 0
+      else
+        # Well, nothing to work with...
+        echo "No userfile.  Could not reload the bot..."
+        echo "No userfile." > CANTSTART.$botname
+        exit 1
+      fi
+    fi
+  fi
 fi
-# Well, nothing to work with...
-echo "No userfile.  Could not reload the bot.."
+
 exit 0
-------------- next part --------------
Index: scripts/compat.tcl
===================================================================
RCS file: /usr/local/cvsroot/eggdrop1.3/scripts/compat.tcl,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 compat.tcl
--- scripts/compat.tcl	1999/06/23 19:51:25	1.1.1.1
+++ scripts/compat.tcl	1999/10/06 23:18:14
@@ -2,76 +2,77 @@
 # This script just quickly maps old tcl functions to the new ones,
 # use this is you are to lazy to get of your butt and update your scripts :D
 #
-# cleanup by Tothwolf 25May1999
+# Tothwolf  25May1999: cleanup
+# Tothwolf  06Oct1999: optimized completely
 
 proc gethosts {hand} {
-  return [getuser $hand HOSTS]
+  getuser $hand HOSTS
 }
 
 proc addhost {hand host} {
-  return [setuser $hand HOSTS $host]
+  setuser $hand HOSTS $host
 }
 
 proc chpass {hand pass} {
-  return [setuser $hand PASS $pass]
+  setuser $hand PASS $pass
 }
 
 # setxtra is no longer relevant 
 
 proc getxtra {hand} {
-  return [getuser $hand XTRA]
+  getuser $hand XTRA
 }
 
 proc setinfo {hand info} {
-  return [setuser $hand INFO $info]
+  setuser $hand INFO $info
 }
 
 proc getinfo {hand} {
-  return [getuser $hand INFO]
+  getuser $hand INFO
 }
 
 proc getaddr {hand} {
-  return [getuser $hand BOTADDR]
+  getuser $hand BOTADDR
 }
 
 proc setaddr {hand addr} {
-  return [setuser $hand BOTADDR $addr]
+  setuser $hand BOTADDR $addr
 }
 
 proc getdccdir {hand} {
-  return [getuser $hand DCCDIR]
+  getuser $hand DCCDIR
 }
 
 proc setdccdir {hand dccdir} {
-  return [setuser $hand DCCDIR $dccdir]
+  setuser $hand DCCDIR $dccdir
 }
 
 proc getcomment {hand} {
-  return [getuser $hand COMMENT]
+  getuser $hand COMMENT
 }
 
 proc setcomment {hand comment} {
-  return [setuser $hand COMMENT $comment]
+  setuser $hand COMMENT $comment
 }
 
 proc getemail {hand} {
-  return [getuser $hand XTRA email]
+  getuser $hand XTRA email
 }
 
 proc setemail {hand email} {
-  return [setuser $hand XTRA EMAIL $email]
+  setuser $hand XTRA EMAIL $email
 }
 
 proc getchanlaston {hand} {
-  return [lindex [getuser $hand LASTON] 1]
+  lindex [getuser $hand LASTON] 1
 }
 
 proc time {} {
-  return [strftime "%H:%M"]
+  strftime "%H:%M"
 }
 
 proc date {} {
-  return [strftime "%d %b %Y"]
+  strftime "%d %b %Y"
 }
 
 # as you can see it takes a lot of effort to simulate all the old commands
-------------- next part --------------
Index: scripts/CONTENTS
===================================================================
RCS file: /usr/local/cvsroot/eggdrop1.3/scripts/CONTENTS,v
retrieving revision 1.2
diff -u -r1.2 CONTENTS
--- scripts/CONTENTS	1999/10/06 08:06:25	1.2
+++ scripts/CONTENTS	1999/10/06 23:14:44
@@ -8,11 +8,13 @@
    gets rid of those ugly /me's people do instead of a .me.
 
 alltools.tcl
-   toolbox.tcl, toolkit.tcl and a few more tools all in 1 file
+   toolbox.tcl, toolkit.tcl, moretools.tcl and a few more tools all in 1 file
    toolbox.tcl
-      cmwagner's collection of handy proc's
+      cmwagner's collection of handy procs
    toolkit.tcl
-      a few useful proc's that may be required by other Tcl scripts
+      a few useful procs that may be required by other Tcl scripts
+   moretools.tcl
+      more useful procs from David Sesno
 
 autobotchk
    tcl script used to crontab your Eggdrop
@@ -38,7 +40,7 @@
 
 ques5.tcl
    makes web pages of who's on each channel, updated periodically
-   (requires toolkit.tcl)
+   (requires alltools.tcl)
 
 sentinel1.54.tcl (by slennox)
    flood protection script for eggdrop 1.3.17 and later, with integrated


More information about the Patches mailing list