#################################################### #################################################### ############### User expire system ################ ################## Version 1.0 ################### ###### Made by Raymond 'Rajohan' Johannessen ##### ##### http://www.rajohan.net/sbnc/expire.tcl ##### #################################################### #################################################### bind time - "* * * * *" time:expired internalbind command expire:commands internalbind command expiredate:commands proc expire:commands {client parameters} { if {[string equal -nocase [lindex $parameters 0] "help"] && [getbncuser $client "admin"]} { bncaddcommand expire Admin "Manage or view an bnc users expire date" "Syntax: expire \n expire add \n expire del \n expire info " } if {[string equal -nocase [lindex $parameters 0] "expire"] && [getbncuser $client "admin"]} { if {[llength $parameters] < 1} { bncreply "Syntax: expire " haltoutput } else { switch [lindex $parameters 1] { "add" { expire:add [lindex $parameters 2] [lindex $parameters 3] haltoutput } "del" { expire:del [lindex $parameters 2] haltoutput } "info" { expire:info [lindex $parameters 2] haltoutput } default { bncreply "Syntax: expire " haltoutput } } } } } proc expiredate:commands {client parameters} { if {[string equal -nocase [lindex $parameters 0] "help"]} { bncaddcommand expiredate User "View your bnc accounts expire date" "Syntax: expiredate" } elseif {[string equal -nocase [lindex $parameters 0] "expiredate"]} { expiredate haltoutput } } proc validbncuser {user} { if { [lsearch -exact [split [string tolower [join [bncuserlist]]]] [string tolower $user]] eq "-1" } { return 0 } else { return 1 } } proc expire:add {username date} { if {[string equal $username ""]} { bncreply "Error: requires a username." bncreply "Example: expire add rajohan 13.03.2008" } elseif {[string equal $date ""]} { bncreply "Error: requires a date." bncreply "Example: expire add rajohan 13.03.2008" } elseif {![validbncuser $username]} { bncreply "Username do not exist" } else { bncreply "Done." bncreply "Expire: added bnc user \"$username\" to expire \"$date\"." setbncuser $username tag expire $date } } proc expire:del {username} { if {[string equal $username ""]} { bncreply "Error: requires a username." bncreply "Example: expire del rajohan" } elseif {![validbncuser $username]} { bncreply "Username do not exist" } else { set date "never" bncreply "Done." bncreply "Removed expire date for bnc user \"$username\"." setbncuser $username tag expire $date } } proc expire:info {username} { if {[string equal $username ""]} { bncreply "Error: requires a username." bncreply "Example: expire info rajohan" } elseif {![validbncuser $username]} { bncreply "Username do not exist" } else { set expiredate [getbncuser $username tag expire] if {$expiredate == ""} { set expiredate "never" } bncreply "Bnc account \"$username\" expires \"$expiredate\"." } } proc expiredate {} { set username [getctx] set expiredate [getbncuser $username tag expire] if {$expiredate == ""} { set expiredate "never" } bncreply "Your bnc account expires \"$expiredate\"." } proc time:expired {min hour day month year} { set date [clock format [clock seconds] -format "%d.%m.%Y"] set username [getctx] set expiredate [getbncuser $username tag expire] if {$expiredate == "none" || $expiredate == ""} { return 0 } elseif {$expiredate <= $date} { bncreply "Your bnc account has expired. Your account has been suspended." setbncuser $username suspendreason "Your bnc account has expired" setbncuser $username tag suspend "1" setbncuser $username lock "1" bnckill "Your bnc account has expired. Your account has been suspended." } else { bncreply "Your bnc account will expire \"$expiredate\"." } }