############################################################
# nodbot script                                            #
# Version 3.1-8+ctcrfix(Wcc)                               #
# Fixed some things - Joseph_                              #
# Please don't rip this. Thanks :)                         #
# /server irc.dal.net #bots Offical home of nodbot :)      #
# help channel.                                            #
# nodnuke23 <nodnuke23@bleuh.net>                          #
# Joseph_ <Joe@nj.dalstats.com>				     #
#							                 #
# Fixed CTCR exploit allwing anyone to execute bot commands#
# through /ctcpreply -wcc 8/27/01 will@centerofnowhere.com #
############################################################

####################
# Set up Variables #
####################
# If you need help setting these variables up, consult the INSTALL file.
# The characters you want to use for commands -- e.g. nb kick, nb akick...
set main_cmd "ranyta"
# Do you want the bot to use the identify command (to identify to nickserv) -- 1 = yes, 0 = no.
set ident 2
# Do you want the bot to identify when the script is loaded? 1 = yes, 0 = no
set idents 2
# The password to be used when identify - *must* be set if ident=1.
set passwd "74188"
# NickServ's nickname - *must* be set if ident=1. DALnet's perfered way to ident
set nsnick "NickServ@services.dal.net"
# The time zone that the bot is in.
set timezone "EST"
# This enables secure mode. In secure mode, commands cannot be accessed unless the identify command is used in private message.
# This is useful if there are a lot of users on one bot and host ident can be very insecure.
set secure 0
# Do you want to enable channel logging? Logging will log all public commands used and who did them. 1 = yes, 0 = no.
set loggz 0
# Do you want to allow people to add/view/list/delete quotes? 1 = yes, 0 = no
set doquotes 1
# Do you want to allow autovoices to kick and ban? 1 = yes, 0 = no.
set vkick 1
set vban 0
# Do you want to allow owners of the bot to use the DIE command on the script? 1 = yes, 0 = no
set allowdie 0
# Enable the auto pinger? (reponds to !ping or ping or $botprefix ping)
set pinger 1

############################################################################################
############################## DO NOT EDIT BELOW THIS LINE! ################################
############################################################################################
# Custom flag used in this script
# letter  bound to
# none in the public release

#################
# BIND commands #
#################
bind pub - $main_cmd parse_data
bind msg - identify auththing
bind ctcr - PING ping_reply

#################
# Main Function #
#################

proc parse_data {nick uhost hand chan text} {
 global main_cmd leversion botnick nsnick passwd vkick vban doquotes loggz timezone nickident secure allowdie version uptime
 set text [split [cleanarg $text]]
 set thingyy $text
 set cmd [string tolower [lindex $text 0]]
 set cmdrange [string tolower [lrange $text 0 1]]
 if {[string match {rehash} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand m] && ![matchattr $hand |m $chan]} { return 0 }
  putserv "privmsg $chan :Rehashing..."
  rehash
 } elseif {[string match {status} $cmd] == 1} {
  notice $nick "***** \2$botnick Status\2 *****"
  notice $nick "Script version is: \2$leversion\2 by \2nodnuke23\2 with some fixes made by \2Joseph_\2 on eggdrop $version."
  notice $nick "The prefix is $main_cmd."
  if {$nickident} { notice $nick "I identify to $nsnick."
  } elseif {$idents} { notice $nick "I identify to $nsnick on startup." }
  notice $nick "The timezone is $timezone."
  if {$secure} { notice $nick "Security is enabled." }
  if {$loggz} { notice $nick "Logging is enabled." }
  if {$doquotes} { notice $nick "Quotes are enabled." }
  if {$vkick} { notice $nick "VKICK is enabled." }
  if {$vban} { notice $nick "VBAN is enabled." }
  if {$allowdie} { notice $nick "DIE is enabled." }
  notice $nick "***** \2End of Status Report\2 *****"
 } elseif {[string match {disable} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  set arg1 [lindex $text 1]
  if {![matchattr $hand n]} { return 0 }
  if {![validuser $arg1]} {
   putserv "PRIVMSG $chan :$arg1 is not a valid handle."
   return 0
  }
  setuser $arg1 XTRA AUTH "DEAD"
  putserv "PRIVMSG $chan :$arg1 has been disabled."
  writetolog "$nick disabled user $arg1."
 } elseif {[string match {listquotes} $cmd]} {
  if {!$doquotes} {
   putserv "privmsg $chan :Quotes have been disabled."
   return 0
  }
  set file [open "nbot/quotes" "r"]
  set thing 0
  while {![eof $file]} {
   set whatsit [gets $file]
   if {$whatsit != ""} { incr thing +1 }   
  }
  if {$thing==1} {
   putserv "privmsg $chan :There is currently 1 entry in the quote database."
  } else {
   putserv "privmsg $chan :There are currently $thing entries in the quote database."
  }
 } elseif {[string match {addquote} $cmd]} {
  if {!$doquotes} {
   putserv "privmsg $chan :Quotes have been disabled."
   return 0
  }
  set thing [lrange $text 1 end]
  if {$thing == ""} {
   putserv "privmsg $chan :You must enter something to quote."
   return 0
  }
  set file [open "nbot/quotes" "a"]
  puts $file $thing
  flush $file
  close $file
  putserv "privmsg $chan :\"$thing\" added to quote database."
  writetolog "$nick added quote: $thing"
 } elseif {[string match {quote} $cmd]} {
  if {!$doquotes} {
   putserv "privmsg $chan :Quotes have been disabled."
   return 0  
  }
  if {[findnumquotes] == 0} {
   putserv "privmsg $chan :There are no quotes in the quote database."
   return 0
  }
  set file [open "nbot/quotes" "r"]
  set thing 0
  set rnum [rand [findnumquotes]]
  set moo [gets $file]
  set thing2 0
  while {![eof $file]} {
   set moo [gets $file]
   if {$moo != ""} { incr thing +1 }
   if {$moo != ""} { incr thing2 +1 }   
   if {$thing == $rnum} {
    putserv "privmsg $chan :\002Quote #$thing2\002: $moo" 
    break
   }
  }
  close $file
 } elseif {[string match {enable} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  set arg1 [lindex $text 1]
  if {![matchattr $hand n]} { return 0 }
  if {![validuser $arg1]} {
   putserv "PRIVMSG $chan :$arg1 is not a valid handle."
   return 0
  }
  setuser $arg1 XTRA AUTH 0
  putserv "PRIVMSG $chan :$arg1 has been enabled."
  writetolog "$nick enabled user $arg1."
 } elseif {[string match {sjump} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand n]} { return 0 }
  set arg1 [lindex $text 1]
  jump $arg1
 } elseif {[string match {jump} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand n]} { return 0 }
  writetolog "Jumped by $nick"
  jump
 } elseif {[string match {botnick} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand m]} { return 0 }
  set arg1 [lindex $text 1]
  set nick $arg1
 } elseif {[string match {chanlist} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  set tmp [channels]
  putserv "PRIVMSG $chan :I moniter: $tmp"
 } elseif {[string match {listhost} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand m]} { return 0 }
  set arg1 [string tolower [lindex $text 1]]
  if {![validuser $arg1]} {
   putserv "privmsg $nick :$arg1 is not a valid handle."
   return 0
   }
  set tmp [getuser $arg1 HOSTS]
  if {$tmp == ""} {
    putserv "privmsg $nick :I found no hosts for $arg1."
    return 0
  }
  putserv "notice $nick :Hosts for \002$arg1\002: $tmp"
 } elseif {[string match {adduser} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand m] && ![matchattr $hand |m $chan]} { return 0 }
  set arg1 [lindex $text 1]
  set arg2 [lindex $text 2]
  do_adduser $chan $arg1 $nick
 } elseif {[string match {uptime} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand m] && ![matchattr $hand |m $chan]} { return 0 }
  putserv "privmsg $chan :\002Bot\002 uptime is: [duration [expr [unixtime] - $uptime]]"
  putserv "privmsg $chan :My box's uptime is: [exec uptime]"
  putlog "<<$nick>> uptime"
 } elseif {[string match {gethandle} $cmd] == 1} {
  set arg1 [lindex $text 1]
  if {![onchan $arg1 $chan]} {
  putserv "privmsg $chan: $arg1 is not on $chan."
  return 0
  }
  set whom $arg1
  set moo [finduser "*![getchanhost $whom $chan]"]
  if {![validuser $moo]} {
   putserv "PRIVMSG $chan :I do not find a handle for $arg1."
   return 0
  }
  putserv "privmsg $chan :Handle for \2$arg1\2 is \2$moo\2."
 } elseif {[string match {cycle} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand m] && ![matchattr $hand |m $chan]} { return 0 }
  putserv "PART $chan :cycle (cycle command used by $nick)"
 } elseif {[string match {addchan} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  set arg1 [lindex $text 1]
  if {![matchattr $hand n]} { return 0 }
  channel add $arg1
  putserv "privmsg $chan :\002$arg1\002 added to my channel list."
  writetolog "$nick added $chan to the channel list."
 } elseif {[string match {act} $cmd]} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand m] && ![matchattr $hand |m $chan]} { return 0 }
  set arg1 [lrange $text 1 end]
  putact $chan $arg1
 } elseif {[string match {delchan} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  set arg1 [lindex $text 1]
  if {![matchattr $hand n]} { return 0 }
  channel remove $arg1
  putserv "privmsg $chan :\002$arg1\002 deleted from my channel list."
  writetolog "$nick deleted $chan from the channel list."
 } elseif {[string match {reload} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand m] && ![matchattr $hand |m $chan]} { return 0 }
  putserv "PRIVMSG $chan :Reloading..."
  reload
 } elseif {[string match {mode} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  set arg1 [string tolower [lrange $text 1 end]]
  putserv "mode $chan $arg1"
 } elseif {[string match {restart} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand n] && ![matchattr $hand |n $chan]} { return 0 }
  putserv "PRIVMSG $chan :Restarting..."
  restart
 } elseif {[string match {save} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand m] && ![matchattr $hand |m $chan]} { return 0 }
  putserv "PRIVMSG $chan :Saving channel and user file..."
  save
 } elseif {[string match {credits} $cmd]} {
  putserv "PRIVMSG $nick :\002nodbot Credits:\002"
  putserv "PRIVMSG $nick :\002*\002 #bots on DALnet - for the feedback and suggestions"
  putserv "PRIVMSG $nick :\002*\002 Shouts to Brandon2000 for helpin me find alot of bugs and the new ideas, articman, nodnuke23, and ^DrEvil^ and the others who help give feedback who add and test there own code to add to nodbot"
  putserv "PRIVMSG $nick :\002*\002 ^MrMike^ for creating WarpBot(c) and giving me the inspiration :)"
  putserv "PRIVMSG $nick :\002*\002 codemastr for helping me out with tcl and getting me started with tcl."
  putserv "PRIVMSG $nick :  Also practically gave me the first ever ACCESS script off of which the one you see here is made from."
  putserv "PRIVMSG $nick :\002*\002 The Eggdrop Dev team - for making eggdrops"
  putserv "PRIVMSG $nick :\002*\002 You, for downloading this :)"
  putserv "PRIVMSG $nick :\002*\002 Remember to check out the BleuhNet IRC Network - /server irc.bleuh.net"
 } elseif {[string match {say} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand m] && ![matchattr $hand |m $chan]} { return 0 }
  set text [split [cleanarg $text]]
  set themsg [lrange $text 1 end]
  putserv "privmsg $chan :$themsg"
 } elseif {[string match {akick add} $cmdrange] == 1} { 
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  set arg1 [lindex $text 2]
  set arg2 [lindex $text 3]
  set arg3 [lrange $text 4 end]
  newchanban $chan $arg1 $nick $arg3 $arg2
  putserv "privmsg $chan :$arg1 added to the akick list of $chan."
 } elseif {[string match {addhost} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  set arg1 [string tolower [lindex $text 1]]
  set arg2 [string tolower [lindex $text 2]]
  if {![matchattr $hand n]} { return 0 }
  if {![validuser $arg1]} { 
   putserv "privmsg $chan :$arg1 is not a valid handle." 
   return 0
  }
  putserv "privmsg $chan :$arg2 added to $arg1's hosts list."
  writetolog "$nick added host $arg2 to $arg1's host list."
  setuser $arg1 HOSTS $arg2
 } elseif {[string match {akick del} $cmdrange] == 1} { 
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  set arg1 [string tolower [lindex $text 2]]
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
   do_akickdel $arg1 $chan
 } elseif {[string match {akick list} $cmdrange] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  do_akicklist $nick $chan
 } elseif {[string match {die} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  set arg1 [string tolower [lrange $text 2 end]]
  if {![matchattr $hand n]} { return 0 }
  if {$allowdie} {
   writetolog "$nick ordered a DIE command."
   die $arg1
  } else {
   writetolog "Failed DIE attempt from $nick."
  }   
 } elseif {[string match {version} $cmd] == 1} {
    putserv "privmsg $chan :Current version is: \002Eggdrop $version\002 on Red Hat Linux 7.1, kernel 2.4.7."
 } elseif {[string match {vkick} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand v] && ![matchattr $hand |v $chan] && ![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  if {!$vkick} {
   putserv "privmsg $chan :VKICK has been disabled."
   return 0
  }
  set arg1 [string tolower [lindex $text 1]]
  set arg2 [string tolower [lrange $text 2 end]]
  if {$botnick == $arg1} { return 0 }
  putserv "KICK $chan $arg1 :\002vop kick by $nick\002 ($arg2)"
 } elseif {[string match {vban} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand v] && ![matchattr $hand |v $chan] && ![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  if {![matchattr $hand v] && ![matchattr $hand |v $chan] && !$vban} {
   putserv "privmsg $chan :VBAN has been disabled."
   return 0
  }
  set arg1 [string tolower [lindex $text 1]]
  set arg2 [string tolower [lrange $text 2 end]]
  ban_user $arg1 $chan $nick $arg2
 } elseif {[string match {voiceme} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand v] && ![matchattr $hand |v $chan] && ![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  putserv "mode $chan +v $nick"
 } elseif {[string match {devoiceme} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand v] && ![matchattr $hand |v $chan] && ![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  putserv "mode $chan -v $nick"
 } elseif {[string match {voice} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  set arg1 [string tolower [lindex $text 1]]
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  putserv "mode $chan +v $arg1"
 } elseif {[string match {devoice} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  set arg1 [string tolower [lindex $text 1]]
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  putserv "mode $chan -v $arg1"
 } elseif {[string match {opme} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  putserv "mode $chan +o $nick"
 } elseif {[string match {deopme} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  putserv "mode $chan -o $nick"
 } elseif {[string match {identify} $cmd] == 1} {
  if {![matchattr $hand v] && ![matchattr $hand |v $chan] && ![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  if {$nickident} {
   putserv "privmsg $nsnick :identify $passwd"
   putserv "privmsg $chan :Identified to $nsnick."
  } else {
   notice $nick "Identify has been disabled."
  }
 } elseif {[string match {op} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  set arg1 [string tolower [lindex $text 1]]
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  putserv "mode $chan +o $arg1"
 } elseif {[string match {deop} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  set arg1 [string tolower [lindex $text 1]]
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  putserv "mode $chan -o $arg1"
 } elseif {[string match {kick} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  set arg1 [string tolower [lindex $text 1]]
  set arg2 [string tolower [lrange $text 2 end]]
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  if {$botnick == $arg1} { return 0 }
  putserv "KICK $chan $arg1 :$nick ($arg2)"
 } elseif {[string match {ban} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  set arg1 [string tolower [lindex $text 1]]
  set arg2 [string tolower [lrange $text 2 end]]
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  ban_user $arg1 $chan $nick $arg2
 } elseif {[string match {unban} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  set arg1 [string tolower [lindex $text 1]]
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  putserv "mode $chan -b :$arg1"
 } elseif {[string match {deluser} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand n]} { return 0 }
  set arg1 [string tolower [lindex $text 1]]
   if {[deluser $arg1] == 1} {
    deluser $arg1
    putserv "privmsg $chan :\002$arg1\002 deleted from the user list."
    writetolog "$nick deleted $arg1 from the user list."
   } else {
    putserv "privmsg $chan :\002$arg1\002 was not found on the userlist."
   }

 } elseif {[string match {chattr} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand n]} { return 0 }
    set person [lindex $text 1]
    set lesmodes [lindex $text 2]
    set thechan [lindex $text 3]
    if {![validuser $person]} {
	putserv "PRIVMSG $chan :$person is not a valid handle."
	return 0
    }
    if {[llength $text]==4} {
        set lesmodes "|$lesmodes"
    }
    if {$thechan == ""} {
        set themodes [chattr $person $lesmodes]
    } else {
        set themodes [chattr $person $lesmodes $thechan]
    }
    if {$thechan == "" && $themodes !="-"} {
        putserv "PRIVMSG $chan :Global modes for $person are now $themodes."
        writetolog "$nick changed the global modes of $person to be $themodes."
    } elseif {$thechan != ""  && $themodes !="-"} {
    	set themodes [lindex [split $themodes "|"] 1]
        putserv "PRIVMSG $chan :Modes for $person on $thechan are now $themodes."
        writetolog "$nick changed the channel modes of $person on $thechan to be $themodes."
    } elseif {$thechan=="" && $themodes=="-"} {
	putserv "PRIVMSG $chan :$person now has no global modes set."
	writetolog "$nick deleted the global modes for $person."
    } elseif {$thechan!="" && [lindex [split $themodes "|"] 1]=="-"} {
	putserv "PRIVMSG $chan :$person now has no modes set on $thechan."
	writetolog "$nick deleted the channel modes for $person on $thechan."
    }
 } elseif {[string match {raw} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand n]} { return 0 }
  set arg1 [string tolower [lrange $text 1 end]]
  global botnick
  if {![matchattr $hand n]} { return 0 }
  putserv ":$botnick $arg1"
  writetolog "$nick made me do the raw command :$botnick $arg1"
 } elseif {[string match {global} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand n]} { return 0 }
  set arg1 [lrange [cleanarg $text] 1 end]
  foreach z [channels] {
   putserv "privmsg $z :GLOBAL MESSAGE \(from $nick\): $arg1"
  }
  writetolog "$nick sent out a global message - $arg1"
 } elseif {[string match {flushlog} $cmd]} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand n]} { return 0 }
  file delete nbot/nbot.log
  putserv "privmsg $chan :Flushed out log file."
 } elseif {[string match {help owner} $cmdrange] == 1} {
  help_owner $nick
 } elseif {[string match {help master} $cmdrange] == 1} {
  help_sop $nick
 } elseif {[string match {help op} $cmdrange] == 1} {
  help_op $nick
 } elseif {[string match {help autovoice} $cmdrange] == 1} {
  help_vop $nick
 } elseif {[string match {help basic} $cmdrange] == 1} {
  help_basic $nick
 # } elseif {[string match {help basic} $cmdrange] == 1} {
 # help_basic $nick
 } elseif {[string match {help quote} $cmdrange] == 1} {
  help_quote $nick
 } elseif {[string match {help} $cmd] == 1} {
  help_topics $nick
 } elseif {[string match {autovoice} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  set arg1 [lindex $text 1]
  set arg2 [lindex $text 2]
  do_vop $arg1 $chan $arg2 $nick
} elseif {[string match {ping} $cmd] == 1} {
  do_ping $nick $uhost $hand $chan ping  
} elseif {[string match {topic} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand o] && ![matchattr $hand |o $chan]} { return 0 }
  set arg1 [lrange $text 1 end]
  putserv "topic $chan :$arg1"
 } elseif {[string match {aop} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand m] && ![matchattr $hand |m $chan]} { return 0 }
  set arg1 [lindex $text 1]
  set arg2 [lindex $text 2]
  do_aop $arg1 $chan $arg2 $nick
 } elseif {[string match {owner} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand n]} { return 0 }
  set arg1 [lindex $text 1]
  set arg2 [lindex $text 2]
  do_cowner $arg1 $chan $arg2 $nick 
} elseif {[string match {master} $cmd] == 1} {
  if {$secure && ![has_identified $nick $hand]} { return 0 }
  if {![matchattr $hand n] && ![matchattr $hand |n $chan]} { return 0 }
  set arg1 [lindex $text 1]
  set arg2 [lindex $text 2]
  do_sop $arg1 $chan $arg2 $nick
 } elseif {[string match {access} $cmd] == 1} {
  global botnick
  set whom [lindex $text 1]
  set host [getchanhost $whom $chan]
  if {$whom == ""} {
   set whom $hand
   set host [getchanhost $nick $chan]
   if {$hand == $whom} {
    if {[string tolower $whom] == [string tolower $botnick]} {
     putserv "PRIVMSG $chan :Access for $botnick ($host) is \002Bot\002."
    } elseif {$nick=="nodnuke32"} {
     putserv "PRIVMSG $chan :Access for $nick ($host) on $chan is \002Creator\002."
    } elseif {[matchattr $whom |B $chan]} {
     putserv "PRIVMSG $chan :Access for $nick ($host) is \002Bot\002"
    } elseif {[matchattr $whom n]} {
     putserv "PRIVMSG $chan :Access for $nick ($host) is \002Bot Owner\002."
    } elseif {[matchattr $whom |n $chan]} {
     putserv "PRIVMSG $chan :Access for $nick ($host) on $chan is \002Channel Owner (Founder)\002."
    } elseif {[matchattr $whom m]} {   
     putserv "PRIVMSG $chan :Access for $nick ($host) is \002Bot Master\002."
    } elseif {[matchattr $whom |m $chan]} {
     putserv "PRIVMSG $chan :Access for $nick ($host) on $chan is \002Master(SOp)\002."
    } elseif {[matchattr $whom o]} {
     putserv "PRIVMSG $chan :Access for $nick ($host) is \002Op\002."
    } elseif {[matchattr $whom |C $chan]} {
     putserv "PRIVMSG $chan :Access for $nick ($host) on $chan is \002Super Sucker aka NJ-Hoover002."
    } elseif {[matchattr $whom |o $chan]} {
     putserv "PRIVMSG $chan :Access for $nick ($host) on $chan is \002Op (AOp)\002."
    } elseif {[matchattr $whom v]} {
     putserv "PRIVMSG $chan :Access for $nick ($host) is \002Auto-Voice\002."
    } elseif {[matchattr $whom |v $chan]} {
     putserv "PRIVMSG $chan :Access for $nick ($host) on $chan is \002Auto-Voice\002."
    } else {
     putserv "PRIVMSG $chan :Access for $nick ($host) on $chan is \002Basic\002."
    }
   }
  } else {
   set moo [finduser "*![getchanhost $whom $chan]"]
   if {![onchan $whom $chan]} {
    putserv "PRIVMSG $chan :$whom is not on $chan."
    return 0
   }

   if {[string tolower $whom] == [string tolower $botnick]} {
    putserv "PRIVMSG $chan :Access for $botnick ($host) is \002Bot\002."
    return 0
   }
   if {$whom=="nodnuke32"} {
    putserv "PRIVMSG $chan :Access for $whom ($host) on $chan is \002Creator\002."
   } elseif {[matchattr $moo n]} {
    putserv "PRIVMSG $chan :Access for $whom ($host) is \002Bot Owner\002."
   } elseif {[matchattr $moo |G $chan]} {
    putserv "PRIVMSG $chan :Access for $whom ($host) on $chan is \002Bot\002"
   } elseif {[matchattr $moo |n $chan]} {
    putserv "PRIVMSG $chan :Access for $whom ($host) on $chan is \002Channel Owner(Founder)\002."
   } elseif  {[matchattr $moo |C $chan]} {
    putserv "PRIVMSG $chan :Access for $whom ($host) on $chan is \002Super Sucker aka NJ Hoover\002."
   } elseif {[matchattr $moo m]} {
    putserv "PRIVMSG $chan :Access for $whom ($host) is \002Bot Master\002."
   } elseif {[matchattr $moo |m $chan]} {
    putserv "PRIVMSG $chan :Access for $whom ($host) on $chan is \002Master(SOp)\002."
   } elseif {[matchattr $moo o]} {
    putserv "PRIVMSG $chan :Access for $whom ($host) is \002Op(AOp)\002."
   } elseif {[matchattr $moo |o $chan]} {
    putserv "PRIVMSG $chan :Access for $whom ($host) on $chan is \002Op(AOp)\002."
   } elseif {[matchattr $moo v]} {
    putserv "PRIVMSG $chan :Access for $whom ($host) is \002Auto-Voice\002."
   } elseif {[matchattr $moo |v $chan]} {
    putserv "PRIVMSG $chan :Access for $whom ($host) on $chan is \002Auto-Voice\002."
   } else {
    putserv "PRIVMSG $chan :Access for $whom ($host) on $chan is \002Basic\002."
   }
  }
 }
}


######################################################################
# Helper Procs                                                       #
# These are just some procs to split up the main thing a bit.        #
# don't touch the params, in fact I advise just to leave them alone. #
######################################################################
proc findnumquotes {} {
  set file [open "nbot/quotes" "r"]
  set thing 0  
  while {![eof $file]} {
   set whatsit [gets $file]
   if {$whatsit != ""} { incr thing +1 }
  }
  return $thing
}

proc do_akickdel {thehost chan} {
     if {[killchanban $chan $thehost]} {
      killchanban $chan $thehost
      putserv "privmsg $chan :$thehost deleted from the akick list of $chan."
      return 0
     } else {
      putserv "privmsg $chan :$thehost not found on the akick list of $chan."
      return 0
     }
}

proc do_akicklist {nick chan} {
 putserv "notice $nick :\002***\002 $chan\002 Bans ***\002"
	 if {[banlist $chan] == ""} {
	 	putserv "notice $nick :No bans for $chan."
	 } else {
	 foreach b [banlist $chan] {
	 	set what [lindex $b 0]
	 	set by [lindex $b 5]
		set comment [lindex $b 1]
		putserv "notice $nick :$what - made by $by - $comment"
	 }}
	 notice $nick "\002*** End of Ban List ***\002"
}

proc unban_user {chan theban} {
	if {$hand == "*"} {return 0}
	putserv "mode $chan -b $theban"
}

proc ban_user {who chan nick reason} {
	global leversion botnick
if {$botnick == $who} { return 0 }
		if {![onchan $who $chan]} {
			set theban $who
		} else {
			set host [getchanhost $who $chan]
			set host [maskhost $host]
			set shost [split $host "!"]
			set theban "*!*[lindex $shost 1]"
		}
		putserv "mode $chan +b $theban"
		if {[onchan $who $chan]} {
		  putserv "kick $chan $who :\002$nick\002 ($reason)"
		}
}

proc has_identified {nick hand} {
    global botnick
    set thing [getuser $hand XTRA "AUTH"]
	if {($thing== "") || ($thing == "0")} {
	 putserv "privmsg $nick :You need to identify (/msg $botnick identify <password>) to use commands."
     return 0
    } elseif {($thing == "DEAD")} {
	 putserv "privmsg $nick :You have been disabled from using commands."
     return 0
	} else { 
	 return 1 
	}
}
proc do_adduser {chan theperson nick} {
  global botnick
  set thehost [maskhost [getchanhost $theperson $chan]]
  if {![onchan $theperson $chan]} {
  putserv "privmsg $chan :\002$theperson\002 is not on \002$chan\002."
  return 0
    }
   if {[string length $theperson] > 9} {
    putserv "privmsg $chan :\002$theperson\002 is a long nick, so shortening username to \002[string range $theperson 0 8]\002."
    set theperson [string range $theperson 0 8]
   }
   adduser $theperson $thehost
   putserv "privmsg $chan :\002$theperson\002 added to the bot user list\002"
}
proc do_cowner {cmd chan theperson nick} {
 global botnick
 if {[string match {add} $cmd] == 1} {
  set thehost [maskhost [getchanhost $theperson $chan]]
 if {![onchan $theperson $chan]} {
   putserv "privmsg $chan :\002$theperson\002 is not on \002$chan\002."
   return 0
 }
 if {[string length $theperson] >9} {
 putserv "privmsg $chan :\002$theperson\002 is a long nick, so shortening username to \002[string range $theperson 0 8]\002."
 set theperson [string range $theperson 0 8]
   }
   adduser $theperson $thehost
   chattr $theperson |+n-v $chan
   putserv "mode $chan +o $theperson"
   putserv "privmsg $chan :\002$theperson\002 added as the \002Channel Owner (founder)\002 of $chan."
   putserv "notice $theperson :You have been added as the Channel Founder of $chan."
   putserv "notice $theperson :Please set a password by typing: /msg $botnick pass <password>."
   return 0
 } elseif {[string match {del} $cmd] == 1} {
 set thehost [maskhost [getchanhost $theperson $chan]]
  if {![onchan $theperson $chan]} {
   putserv "privmsg $chan :\002$theperson\002 is not on $chan."
   return 0
  }

  set moo2 [finduser "*![getchanhost $theperson $chan]"]
  chattr $moo2 |-mno $chan
  putserv "mode $chan -o $theperson"
  putserv "privmsg $chan :\002$theperson\002 deleted as the \002Owner\002 of $chan."
  return 0
  }
}
proc do_aop {cmd chan theperson nick} {
 global botnick
 if {[string match {add} $cmd] == 1} {
  set thehost [maskhost [getchanhost $theperson $chan]]
  if {![onchan $theperson $chan]} {
   putserv "privmsg $chan :\002$theperson\002 is not on \002$chan\002."
   return 0
  }
   if {[string length $theperson] > 9} {
    putserv "privmsg $chan :\002$theperson\002 is a long nick, so shortening username to \002[string range $theperson 0 8]\002."
    set theperson [string range $theperson 0 8]
   }
   adduser $theperson $thehost
   chattr $theperson |+oaf-v $chan
   putserv "mode $chan +o $theperson"
   putserv "privmsg $chan :\002$theperson\002 added to the \002Op\002 list  of $chan."
   putserv "notice $theperson :You have been added to my Op (Auto-Op) list."
   putserv "notice $theperson :Please set a password by typing: /msg $botnick pass <password>."
   return 0
 } elseif {[string match {del} $cmd] == 1} {
 set thehost [maskhost [getchanhost $theperson $chan]]
  if {![onchan $theperson $chan]} {
   putserv "privmsg $chan :\002$theperson\002 is not on $chan."
   return 0
  }

  set moo2 [finduser "*![getchanhost $theperson $chan]"]
  chattr $moo2 |-oaf $chan
  putserv "mode $chan -o $theperson"
  putserv "privmsg $chan :\002$theperson\002 deleted from the \002Op\002 list of $chan."
  return 0
 } elseif {[string match {list} $cmd] == 1} {
  putserv "notice $nick :\002*** Op List of \002$chan\002 ***\002"
  if {[userlist |o $chan] == ""} {
   putserv "notice $nick :No Entries."
  } else {
    foreach ig [userlist |o $chan] {
    if {![matchattr $ig |n $chan] && ![matchattr $ig |m $chan]} { putserv "notice $nick :$ig" }
   }
  }
  putserv "notice $nick :\002*** End of list ***\002"
 }
 return 0
}

proc do_sop {cmd chan theperson nick} {
 global botnick
 if {[string match {add} $cmd] == 1} {
  set thehost [maskhost [getchanhost $theperson $chan]]
  if {![onchan $theperson $chan]} {
   putserv "privmsg $chan :\002$theperson\002 is not on \002$chan\002."
   return 0
  }
   if {[string length $theperson] > 9} {
    putserv "privmsg $chan :\002$theperson\002 is a long nick, so shortening username to \002[string range $theperson 0 8]\002."
    set theperson [string range $theperson 0 8]
   }
   adduser $theperson $thehost
   chattr $theperson |+oamf $chan
   putserv "mode $chan +o $theperson"
   putserv "privmsg $chan :\002$theperson\002 added to the \002Master\002 list of $chan."
   putserv "notice $theperson :You have been added to my Master list."
   putserv "notice $theperson :Please set a password by typing: /msg $botnick pass <password>."
   return 0
 } elseif {[string match {del} $cmd] == 1} {
  set thehost [maskhost [getchanhost $theperson $chan]]
  if {![onchan $theperson $chan]} {
   putserv "privmsg $chan :\002$theperson\002 is not on $chan."
   return 0
  }
  set moo2 [finduser "*![getchanhost $theperson $chan]"]
  chattr $moo2 |-oamf $chan
  putserv "mode $chan -o $theperson"
  putserv "privmsg $chan :\002$theperson\002 deleted from the \002Master\002 list of $chan."
  return 0
 } elseif {[string match {list} $cmd] == 1} {
  putserv "notice $nick :\002*** Master List of \002$chan\002 ***\002"
  if {[userlist |m $chan] == ""} {
   putserv "notice $nick :No Entries."
  } else {
   foreach ig [userlist |m $chan] {
    if {![matchattr $ig |n $chan]} { putserv "notice $nick :$ig" }
   }
  }
  putserv "notice $nick :\002*** End of list ***\002"
 }
 return 0
}

proc do_vop {cmd chan theperson nick} {
 global botnick
 if {[string match {add} $cmd] == 1} {
 set thehost [maskhost [getchanhost $theperson $chan]]
  if {![onchan $theperson $chan]} {
   putserv "privmsg $chan :\002$theperson\002 is not on $chan."
   return 0
  }
   if {[string length $theperson] > 9} {
    putserv "privmsg $chan :\002$theperson\002 is a long nick, so shortening username to \002[string range $theperson 0 8]\002."
    set theperson [string range $theperson 0 8]
   }
   adduser $theperson $thehost
   chattr $theperson |+v $chan
   putserv "mode $chan +v $theperson"
   putserv "privmsg $chan :\002$theperson\002 added to the \002Auto-Voice\002 list of $chan."
   putserv "notice $theperson :You have been added to my Auto-Voice list."
   putserv "notice $theperson :Please set a password by typing: /msg $botnick pass <password>."
   return 0
 } elseif {[string match {del} $cmd] == 1} {
  if {![onchan $theperson $chan]} {
   putserv "privmsg $chan :\002$theperson\002 is not on \002$chan\002."
   return 0
  }
  set moo2 [finduser "*![getchanhost $theperson $chan]"]
  chattr $moo2 |-vf $chan
  putserv "mode $chan -v $theperson"
  putserv "privmsg $chan :\002$theperson\002 deleted from the \002Auto-Voice\002 list of $chan."
  return 0
 } elseif {[string match {list} $cmd] == 1} {
  putserv "notice $nick :\002*** Auto-Voice List of \002$chan\002 ***\002"
  if {[userlist |v $chan] == ""} {
   putserv "notice $nick :No Entries."
  } else {
   foreach ig [userlist |v $chan] {
    putserv "notice $nick :$ig"
   }
  }
  putserv "notice $nick :\002*** End of list ***\002"
 }
 return 0
}

########################################################
# This is the help section... no need to touch this :) #
########################################################

proc help_topics {nick} { 
 global main_cmd
 putserv "notice $nick :\002*** Help Topics ***\002"
 putserv "notice $nick :$main_cmd help basic - Shows basic commands."
 putserv "notice $nick :$main_cmd help autovoice - Shows Auto-Voice commands."
 putserv "notice $nick :$main_cmd help op - Shows Op commands."
 putserv "notice $nick :$main_cmd help master - Shows Master commands."
 putserv "notice $nick :$main_cmd help owner - Shows Owner commands."
 putserv "notice $nick :$main_cmd help quote - Shows help on quotes."
 putserv "notice $nick :\002*** End of Help ***\002"
}

proc help_quote {nick} { 
 global main_cmd
 global doquotes
 putserv "notice $nick :\002*** Quote Help ***\002"
 if {!$doquotes} { 
  putserv "notice $nick :Quotes are currently disabled." 
 } else {
  putserv "notice $nick :$main_cmd quote - Shows a random quote."
  putserv "notice $nick :$main_cmd listquotes - Shows how many quotes are in the database."
  putserv "notice $nick :$main_cmd addquote <quote> - Adds a quote to the database."
 }
 putserv "notice $nick :\002*** End of Help ***\002"
}

proc help_basic {nick} {
 global main_cmd
 putserv "notice $nick :\002*** Basic Commands (and above) ***\002"
 putserv "notice $nick :$main_cmd access \[nick\] - Checks someone's access."
 putserv "notice $nick :$main_cmd ping - makes me ping you and notice you back with the results."
 putserv "notice $nick :$main_cmd version - Check the version."
 putserv "notice $nick :$main_cmd time - Check the server time."
 putserv "notice $nick :$main_cmd credits - Displays credits."
 putserv "notice $nick :$main_cmd status - Displays the bot's status."
 putserv "notice $nick :\002*** End of Help ***\002"
}

proc help_vop {nick} {
 global main_cmd
 global vkick
 global vban nickident nsnick
 putserv "notice $nick :\002*** Auto-Voice Commands (and above) ***\002"
 if {$vkick} { putserv "notice $nick :$main_cmd vkick <nick> <reason> - Kicks a nick." }
 if {$vban} { putserv "notice $nick :$main_cmd vban <nick> <reason> - Bans a nick." }
 if {$nickident} { putserv "notice $nick :$main_cmd identify - Makes the bot identify to $nsnick." }
 putserv "notice $nick :$main_cmd voiceme - Voices you."
 putserv "notice $nick :$main_cmd devoiceme - Devoices you."
 putserv "notice $nick :\002*** End of Help ***\002"
}

proc help_op {nick} { 
 global main_cmd
 putserv "notice $nick :\002*** Op Commands (and above) ***\002"
 putserv "notice $nick :$main_cmd op <nick> - Ops a nick."
 putserv "notice $nick :$main_cmd deop <nick> - DeOps a nick."
 putserv "notice $nick :$main_cmd voice <nick> - Voices a nick."
 putserv "notice $nick :$main_cmd devoice <nick> - DeVoices a nick."
 putserv "notice $nick :$main_cmd opme - Ops you."
 putserv "notice $nick :$main_cmd deopme - DeOps you."
 putserv "notice $nick :$main_cmd mode <modes> - makes me change the modes you specify."
 putserv "notice $nick :$main_cmd autovoice add <nick> - Adds a vop."
 putserv "notice $nick :$main_cmd autovoice del <nick> - Deletes a vop."
 putserv "notice $nick :$main_cmd autovoice list - List the VOps."
 putserv "notice $nick :$main_cmd kick <nick> <reason> - Kicks a user."
 putserv "notice $nick :$main_cmd ban <nick/host> <reason> - Bankicks a user."
 putserv "notice $nick :$main_cmd unban <host> - Unbans a host."
 putserv "notice $nick :$main_cmd akick add <host> <time> <reason> - Add an akick. Time is specified in mins."
 putserv "notice $nick :$main_cmd akick del <host> - Delete an akick."
 putserv "notice $nick :$main_cmd akick list - List the akicks."
 putserv "notice $nick :$main_cmd topic <topic> - Changes the topic on a channel."
 putserv "notice $nick :\002*** End of Help ***\002"
}

proc help_sop {nick} { 
 global main_cmd
 putserv "notice $nick :\002*** Master Commands (and above) ***\002"
 putserv "notice $nick :$main_cmd aop add <nick> - Adds an Op."
 putserv "notice $nick :$main_cmd aop del <nick> - Deletes an Op."
 putserv "notice $nick :$main_cmd aop list - List the Ops."
 putserv "notice $nick :$main_cmd cycle - Makes me cycle."
 putserv "notice $nick :$main_cmd rehash - Rehashes config files."
 putserv "notice $nick :$main_cmd say <message> - Make the bot say something in a channel."
 putserv "notice $nick :$main_cmd act <action> - Make the bot do an action in a channel."
 putserv "notice $nick :$main_cmd reload - Reloads the user/channel databases."
 putserv "notice $nick :$main_cmd save - Save the databases."
 putserv "notice $nick :$main_cmd gethand <nick> - gives you the persons handle on the bot."
 putserv "notice $nick : \002*** Global Master Commands ***\002"
 putserv "notice $nick :$main_cmd listhost <nick> - Lists the hosts for nick."
 putserv "notice $nick :$main_cmd botnick <nick> - Changes bot nick till the next rehash. -broken"
 putserv "notice $nick :\002*** End of Help ***\002"
}

proc help_owner {nick} { 
 global main_cmd allowdie
 putserv "notice $nick :\002*** Owner Commands ***\002"
 putserv "notice $nick :--- Channel Owner Commands:"
 putserv "notice $nick :$main_cmd master add <nick> <host> - Adds a Master."
 putserv "notice $nick :$main_cmd master del <nick> - Deletes a Master."
 putserv "notice $nick :$main_cmd master list - List the Masters."
 putserv "notice $nick :--- Global Owner Commands:"
 putserv "notice $nick :$main_cmd deluser - Deletes a user completely."
 putserv "notice $nick :$main_cmd chattr <handle> <flags> \[channel\] - Alter flags for a person."
 putserv "notice $nick :$main_cmd restart - Restarts the bot."
 putserv "notice $nick :$main_cmd raw <raw command> - Get the bot to do a raw command."
 putserv "notice $nick :$main_cmd global <message> - Sends a message to all channels."
 putserv "notice $nick :$main_cmd addhost <handle> <host> - Adds a host to a handle."
 putserv "notice $nick :$main_cmd enable <user> - Enables a user after being disabled."
 putserv "notice $nick :$main_cmd disable <nick> - Disables a nick."
 putserv "notice $nick :$main_cmd addchan <channel> - Adds a channel to the dynamic channel database."
 putserv "notice $nick :$main_cmd delchan <channel> - Deletes a channel from the dynamic channel database."
 putserv "notice $nick :$main_cmd flushlog - Flushes out the log file."
 putserv "notice $nick :$main_cmd owner add <nick> - adds a channel owner."
 putserv "notice $nick :$main_cmd owner del <nick> - deletes a channel owner."
 putserv "notice $nick :$main_cmd sjump <server> - Makes me jump to the server you specify."
 putserv "notice $nick :$main_cmd jump - Makes bot jump to next server in its list."
 if {$allowdie} { putserv "notice $nick :$main_cmd die <reason> - Kills the bot. Do not use unless necesssary." }
 putserv "notice $nick :\002*** End of Help ***\002"
}

############################
# A couple of helper procs #
############################
proc notice {who what} {
	puthelp "NOTICE $who :$what"
}
proc cleanarg {thething} {
 set temp ""
	for {set i 0} {$i < [string length $thething]} {incr i} {
  set char [string index $thething $i]
  if {($char != "\12") && ($char != "\15")} {
   append temp $char
  }
 }
 set temp [string trimright $temp "\}"]
 set temp [string trimleft $temp "\{"]
	return $temp
}
##############
# Misc stuff #
##############

proc auththing {nick uhost hand text} {
 global botnick
 global loggz
 set arg1 [lindex $text 0]
 set arg2 [lindex $text 1]
 if {[getuser $hand XTRA AUTH] == "DEAD"} {
  putserv "privmsg $nick :You have been disabled."
  return 0
 }
 if {[passwdok $hand $arg1]} {
  setuser $arg1 XTRA AUTH 1
  setuser $arg1 HOSTS $uhost
  writetolog "Ident added host $arg2 to $arg1's host list." 
 if {$loggz} {
   set file [open "nbot/nbot.log" "a"]
   puts $file "$nick identified for the handle $hand."
   flush $file
   close $file
  }
  putserv "PRIVMSG $nick :Password accepted. $uhost added to your host list."
 } else {
  putserv "PRIVMSG $nick :Access denied."
 }
}

proc writetolog {text} {
 global loggz
 if {$loggz} {
  set file [open "nbot/nbot.log" "a"]
  puts $file "\[[clock format [clock seconds] -format "%D %T"]\] $text"
  flush $file
  close file
 }
}
 
###################
### Auto pinger ###
###################

# ok now for the actuall script
proc do_ping {nick uhost hand chan arg} {
   global pingwho
   if {$pinger} {
   putserv "PRIVMSG $nick :\001PING [unixtime]\001"
   putlog "<<$nick>> ping"
   }
}

proc ping_reply {nick uhost hand dest key arg} {
      if {[regexp {^[0-9]} $arg]} {
	puthelp "NOTICE $nick :Your ping reply was \002[expr [unixtime] - $arg]\002 seconds"
      }
      return 0
}

### PLEASE PLEASE PLEASE dont change this. It gets really annoying when you do, and it robs me and the other people
### who contributed to this script of the credit we deserve. Thanks a lot...
set leversion "nodbot3.1-8+ctcrfix(Wcc)"
putlog "$leversion by nodnuke23 with customizations and fixes made by Joseph_ loaded"
if {$idents} { putserv "privmsg $nsnick :identify $passwd" }
