TCL User Add

User Add

unbind msg - hello *msg:hello
unbind dcc m|m adduser *dcc:adduser 
unbind dcc m|- +user *dcc:+user
unbind dcc t|- +bot *dcc:+bot

bind msg - hello msg:hello
bind dcc m|m adduser dcc:adduser
bind dcc m|- +user dcc:+user
bind dcc t|- +bot dcc:+bot

if {![info exists whois-fields]} {
    set whois-fields ""
}
set ffound 0
foreach f2 [split ${whois-fields}] {
    if {[string tolower $f2] == [string tolower "Added"]} {
        set ffound 1
        break
    }
}
if {$ffound == 0} {
    append whois-fields " " "Added"
}
proc msg:hello {nick host hand paras} {
    if { $hand != "*" } {
        *msg:hello $nick $host $hand $paras
    } elseif {[validuser $nick]} {
        *msg:hello $nick $host $hand $paras
    } else {
        *msg:hello $nick $host $hand $paras
	if {[validuser $nick]} {
            setuser $nick xtra Added "by $nick as $nick ([strftime %Y-%m-%d@%H:%M])"
	}
    }
}
proc dcc:adduser {hand idx paras} {
    set user [lindex $paras 1]
    if {$user == ""} {
	if {[string index $paras 0] == "!"} {
	    set user [string range [lindex $paras 0] 1 end]
	} else {
	    set user [lindex $paras 0]
	}
    }
    if {[validuser $user]} {
	*dcc:adduser $hand $idx $paras
    } else {
	*dcc:adduser $hand $idx $paras
	if {[validuser $user]} {
            setuser $user xtra Added "by $hand as $user ([strftime %Y-%m-%d@%H:%M])"
	    tellabout $hand $user
	}
    }
}
# dcc:+user start
proc dcc:+user {hand idx paras} {
    set user [lindex $paras 0]
    if {[validuser $user]} {
        *dcc:+user $hand $idx $paras
    } else {
        *dcc:+user $hand $idx $paras
        if {[validuser $user]} {
            setuser $user xtra Added "by $hand as $user ([strftime %Y-%m-%d@%H:%M])"
	    tellabout $hand $user
        }
    }
}
# dcc:+bot start
proc dcc:+bot {hand idx paras} {
    set user [lindex $paras 0]
    if {[validuser $user]} {
        *dcc:+bot $hand $idx $paras
    } else {
        *dcc:+bot $hand $idx $paras
        if {[validuser $user]} {
            setuser $user xtra Added "by $hand as $user ([strftime %Y-%m-%d@%H:%M])"
	    tellabout $hand $user
        }
    }
}
# tellabout start
proc tellabout {hand user} {
    global nick notify-newusers
    foreach ppl ${notify-newusers} {
	sendnote $nick $ppl "introduced to $user by $hand"
    }
}
putlog "AddedTcl by Nils Ostbjerg loaded"