# newnick1.tcl - allows a user to change their registered handle on
# the bot via /msg.
# 2 February 1996 by Gord-@saFyre <ggold@panix.com>
bind msg - newnick msg_newnick
proc msg_newnick {nick uhost hand args} {
global botnick global admin notify-newusers
if {$hand == "*"} {
putserv "NOTICE $nick :You are not registered on this bot under your current userhost mask ($uhost)"
if {[validuser [string tolower $nick]]} {
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>"
putserv "NOTICE $nick :If it is you, and you either forgot or never set a password, contact $admin for help."
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"
return 0
}
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>"
putserv "NOTICE $nick :Otherwise, you can register with this bot by issuing the command /msg $botnick hello"
putserv "NOTICE $nick :Sorry, that nick is already registered to someone on this bot. Please choose another."
} else {
if {[notecnt $hand] > 0} {
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."
} else {
if {[lsearch -exact [dcc_list_hand] $hand] == -1} {
putcmdlog "NEWNICK request: $hand now known as $nick"
if {![catch {set notify-newusers}]} {
sendnote $botnick ${notify-newusers} "NEWNICK request: $hand now known as $nick"
}
chhandle $hand $nick
putserv "NOTICE $nick :You are now registered with this bot as $nick"
return 0
} else {
putserv "NOTICE $nick :You currently have an active telnet or dcc chat connection with this bot. Please .quit it and try again."
}
}
}
}
putserv "NOTICE $nick :You are registered with this bot as $hand"
return 0
}
# returns a list of currently active dcc-connected users
proc dcc_list_hand {} {
set wholist ""
foreach i [dcclist] {
set onbot [lindex $i 1]
append wholist "$onbot "
}
set $wholist [string trim $wholist]
return "$wholist"
}
# returns the number of notes the user has in the notes file
proc notecnt {who} {
global notefile
set msgcount 0
if {![validuser $who]} {
return -1
}
if {![file exists $notefile]} {
return -1
}
set fd [open "|/usr/bin/grep -i $who $notefile" r]