home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz KrOnIcKLeZ 3 / HaCKeRz_KrOnIcKLeZ.iso / scriptz / newnick.tcl < prev    next >
Text File  |  1996-04-23  |  3KB  |  78 lines

  1. # newnick1.tcl - allows a user to change their registered handle on 
  2. # the bot via /msg.
  3. # 2 February 1996 by Gord-@saFyre <ggold@panix.com>
  4.  
  5. bind msg - newnick msg_newnick
  6.  
  7. proc msg_newnick {nick uhost hand args} {
  8.   global botnick global admin notify-newusers
  9.   if {$hand == "*"} {
  10.     putserv "NOTICE $nick :You are not registered on this bot under your current userhost mask ($uhost)"
  11.     if {[validuser [string tolower $nick]]} {
  12.       putserv "NOTICE $nick :There is, however, a user named $nick registered.  If this is you and you have already set a password on this bot, you may add your current userhost mask to my records by issuing the command /msg $botnick ident <password>"
  13.       putserv "NOTICE $nick :If it is you, and you either forgot or never set a password, contact $admin for help."
  14.       putserv "NOTICE $nick :If it is not you, then please choose a different nick and register with this bot by issuing the command /msg $botnick hello"
  15.       return 0
  16.     }
  17.     putserv "NOTICE $nick :If you are registered under another account and nick, and have already set a password on this bot, please change to that nick and issue the command /msg $botnick ident <password>"
  18.     putserv "NOTICE $nick :Otherwise, you can register with this bot by issuing the command /msg $botnick hello"
  19.     return 0
  20.   }
  21.   if {[string compare [string tolower $nick] [string tolower $hand]] != 0} {
  22.     if {[validuser [string tolower $nick]]} {
  23.       putserv "NOTICE $nick :Sorry, that nick is already registered to someone on this bot.  Please choose another."
  24.     } else {
  25.       if {[notecnt $hand] > 0} {
  26.         putserv "NOTICE $nick :You currently have notes stored in my note file. You must erase these notes (/msg $botnick notes <password> erase all) before changing your registered nick."
  27.       } else {
  28.         if {[lsearch -exact [dcc_list_hand] $hand] == -1} {
  29.           putcmdlog "NEWNICK request: $hand now known as $nick"
  30.           if {![catch {set notify-newusers}]} {
  31.             sendnote $botnick ${notify-newusers} "NEWNICK request: $hand now known as $nick"
  32.           }
  33.           chhandle $hand $nick
  34.           putserv "NOTICE $nick :You are now registered with this bot as $nick"
  35.           return 0
  36.         } else {
  37.           putserv "NOTICE $nick :You currently have an active telnet or dcc chat connection with this bot.  Please .quit it and try again."
  38.         }
  39.       }
  40.     }
  41.   }
  42.   putserv "NOTICE $nick :You are registered with this bot as $hand"
  43.   return 0
  44. }
  45.  
  46. # returns a list of currently active dcc-connected users
  47. proc dcc_list_hand {} {
  48.   set wholist ""
  49.   foreach i [dcclist] {
  50.     set onbot [lindex $i 1]
  51.     append wholist "$onbot "
  52.   }
  53.   set $wholist [string trim $wholist]
  54.   return "$wholist"
  55. }
  56.  
  57. # returns the number of notes the user has in the notes file
  58. proc notecnt {who} {
  59.   global notefile
  60.   set msgcount 0
  61.   if {![validuser $who]} {
  62.     return -1
  63.   }
  64.   if {![file exists $notefile]} {
  65.     return -1
  66.   }
  67.   set fd [open "|/usr/bin/grep -i $who $notefile" r]
  68.   while {![eof $fd]} {
  69.    catch {set inp [gets $fd]}
  70.    if {[string compare [string tolower [lindex $inp 0]] [string tolower $who]] == 0} {
  71.      set msgcount [expr $msgcount + 1]
  72.    }
  73.   }
  74.   catch {close $fd}
  75.   return $msgcount
  76. }
  77.  
  78.