Code: Select all
proc setHost uhost {
set host [lindex [split $uhost @] 1]
set n [llength [split $host .]]
if {[regexp -all {[A-z]{1,}(\.?)} $host] == $n && ![regexp {[0-9]} $host]} {
set ehost *!*[string trimleft $uhost ~]
} else if {[string match "*.users.quakenet.org" $host]} {
set ehost *!*[string trimleft $uhost ~]
} {
set ehost [maskhost $uhost]
}
set ehost
}
Code: Select all
bind msg - register register:nick
bind msg - addhost addhost:nick
# register the user.
proc register:nick {n u h a} {
if {$hand == "*" && $a != ""} {
adduser $n [setHost $u]
setuser $n PASS [lindex [split $a] 0]
puthelp "notice $n :You've been added with handle $n."
} {
puthelp "notice $n :You're already added with handle $h or you didn't specify a password."
}
}
# add a new host.
proc addhost:nick {n u h a} {
set hh [lindex [split $a] 0]
set p [lindex [split $a] 1]
if {[validuser $hh] && [passwdok $hh $p]} {
setuser $hh HOSTS [setHost $u]
puthelp "notice $n :Added you new host to handle $hh."
} {
puthelp "notice $n :Invalid handle or wrong password."
}
}
proc setHost uhost {
set host [lindex [split $uhost @] 1]
set n [llength [split $host .]]
if {[regexp -all {[A-z]{1,}(\.?)} $host] == $n && ![regexp {[0-9]} $host]} {
set ehost *!*[string trimleft $uhost ~]
} else if {[string match "*.users.quakenet.org" $host]} {
set ehost *!*[string trimleft $uhost ~]
} {
set ehost [maskhost $uhost]
}
set ehost
}
Code: Select all
############
## User management Tcl by Honey_bee @ Quakenet
bind msg - register register:nick
bind msg - addhost addhost:nick
bind msg - chhandle chhandle:nick
bind msg - chpass chpass:nick
bind msg - auth auth:nick
bind msg - deauth deauth:nick
# register the user.
proc register:nick {n u h a} {
global botnick
set pass [lindex [split $a] 0]
if {$a == ""} {
puthelp "NOTICE $n :Usage: /msg $botnick REGISTER <your password>"
return 1
}
if {$pass == ""} {
puthelp "NOTICE $n :You need to specify password try /msg $botnick <you password>"
return 1
}
if {[validuser $h] == 1} {
puthelp "NOTICE $n : $h is already registered, try to change your nickname /nick <new nick> and try again."
putlog "$n tried to get registered with handle $h, which is already in use."
return 1
}
if {$hand == "*" && $a != ""} {
adduser $n [setHost $u]
setuser $n PASS [lindex [split $a] 0]
sendnote UM honey_bee "A new User is added with handle: $n and hostmask [setHost $u]"
puthelp "notice $n :You've been added with handle $n."
} {
puthelp "notice $n :user with nickname < $h > already registered or you didn't specify a password."
}
}
# add a new host.
proc addhost:nick {n u h a} {
global botnick
set hh [lindex [split $a] 0]
set p [lindex [split $a] 1]
if {$a == ""} {
puthelp "NOTICE $n :Usage: /msg $botnick addhost <your password>"
return 1
}
if {$p == ""} {
puthelp "NOTICE $n :You need to specify password try /msg $botnick addhost <you password>"
return 1
}
if {[validuser $h] != 1} {
puthelp "NOTICE $n :You are not REGISTERED, try to register yourself /msg $botnick REGISTER <yourpass>"
return 1
}
if {[passwdok $hh ""] == 1} {
puthelp "NOTICE $n :You don't have a password set, try to set a password /msg $botnick HELP PASS"
return 1
}
if {[passwdok $hh $p] != 1} {
puthelp "NOTICE $n : You have supplied a wrong password try again."
return 1
}
if {[validuser $hh] && [passwdok $hh $p]} {
setuser $hh HOSTS [setHost $u]
sendnote UM honey_bee "New host is added $hh: [setHost $u]"
puthelp "notice $n :Added you new host to handle $hh."
} {
puthelp "notice $n :Invalid handle or wrong password."
}
}
proc chhandle:nick {n u h a} {
global botnick
set newhandle [lindex $a 0]
set p [lrange $a 1 end]
if {$a == ""} {
puthelp "NOTICE $n :Usage: /msg $botnick chhandle <newhandle> <your password>"
return 1
}
if {$p == ""} {
puthelp "NOTICE $n :You need to specify password try /msg $botnick <you password>"
return 1
}
if {[validuser $newhandle] == 1} {
puthelp "NOTICE $n :This handle is already owned by someone try another."
return 1
}
if {[validuser $h] != 1} {
puthelp "NOTICE $n :You are not REGISTERED, try to register yourself /msg $botnick REGISTER <yourpass>"
return 1
}
if {[passwdok $h ""] == 1} {
puthelp "NOTICE $n :You don't have a password set, try to set a password /msg $botnick HELP PASS"
return 1
}
if {[passwdok $h $p] != 1} {
puthelp "NOTICE $n : You have supplied a wrong password try again."
return 1
}
if {[validuser $h] && [passwdok $h $p]} {
chhandle $h $newhandle
sendnote UM honey_bee "changed handle for $h to $newhandle"
puthelp "notice $n :Your handle is successfully changed."
} {
puthelp "notice $n :unable to change your hostmask right now, contact an OP"
}
}
proc chpass:nick {n u h a} {
global botnick
set hh [lindex [split $a] 0]
set p [lindex [split $a] 1]
if {$a == ""} {
puthelp "NOTICE $n :Usage: /msg $botnick chpass <new password>"
return 1
}
if {$p == ""} {
puthelp "NOTICE $n :You need to specify password try /msg $botnick chpass <newpass>"
return 1
}
if {[validuser $hh] != 1} {
puthelp "NOTICE $n :You are not REGISTERED, try to register yourself /msg $botnick REGISTER <yourpass>"
return 1
}
if {[passwdok $hh ""] == 1} {
puthelp "NOTICE $n :You don't have a password set, try to set a password /msg $botnick HELP PASS"
return 1
}
if {[validuser $hh] {
setuser $hh PASS $p
puthelp "notice $n :Your password is successfully changed."
} {
puthelp "notice $n :unable to change your password right now, contact an OP"
}
}
proc auth:nick {n u h a} {
global botnick
set p [lindex $a 0]
if {$p == ""} {
puthelp "NOTICE $n :Usage: /msg $botnick auth <password>"
return 0
}
if {[matchattr $h C] == 1} {
puthelp "NOTICE $n : You are already Authenticated."
return 0
}
if {[validuser $h] != 1} {
puthelp "NOTICE $n : Your are not REGISTERED yet, try /msg $botnick REGISTER <your password>"
return 1
}
set ch [passwdok $h ""]
if {$ch == 1} {
puthelp "NOTICE $n :No password set. Type /msg $botnick PASS <password>"
return 0
}
if {[passwdok $h $p] == 0} {
puthelp "NOTICE $n :Incorrect password, login failed!"
}
if {[passwdok $h $p] == 1} {
foreach userhost [getuser $h HOSTS] {
if {[string tolower [setHost $u]] == [string tolower $userhost]} {
putlog "host [setHost $u] is already present in $h HOSTS: $userhost"
return 1
} else {
# this will make sure if the current host is added if not lets add it
setuser $hh HOSTS [setHost $u]
chattr $hh +C
puthelp "NOTICE $nick :login successful."
}
}
proc deauth:nick {n u h a} {
global X botnick
if {$a == ""} {
puthelp "NOTICE $n : Usage: /msg $botnick deauth <password>"
return 0
}
if {[matchattr $h C] == 0} {
puthelp "NOTICE $n : You never authenticated."
return 0
}
if {[passwdok $hand $a] == 1} {
chattr $h -C
puthelp "NOTICE $n : DeAuthentication successful"
}
if {[passwdok $h $a] == 0} {
puthelp "NOTICE $n : DeAuthentication failed"
}
}
proc setHost uhost {
set host [lindex [split $uhost @] 1]
set n [llength [split $host .]]
if {[regexp -all {[A-z]{1,}(\.?)} $host] == $n && ![regexp {[0-9]} $host]} {
set ehost *!*[string trimleft $uhost ~]
} else if {[string match "*.users.quakenet.org" $host]} {
set ehost *!*[string trimleft $uhost ~]
} {
set ehost [maskhost $uhost]
}
set ehost
}
Code: Select all
if {$a == ""} {
Code: Select all
if {$pass == ""} {
Code: Select all
proc register:nick {n u h a} {
global botnick
set pass [lindex [split $a] 0]
if {$a == ""} {
puthelp "NOTICE $n :Usage: /msg $botnick REGISTER <your password>"
return 1
}
# rest goes here...
}
Code: Select all
proc register:nick {n u h a} {
global botnick
set pass [lindex [split $a] 0]
if {$a == ""} {
puthelp "NOTICE $n :Usage: /msg $botnick REGISTER <your password>"
return 1
}
# rest goes here....
}
Code: Select all
if {[llength [split $a]] < 1} {
puthelp "NOTICE $n :Usage: /msg $botnick REGISTER <your password>"
} elseif {[validuser $n] || [validuser $h]} {
puthelp "NOTICE $n :User already exists."
} else {
adduser $n [setHost $u]; setuser $n PASS [lindex [split $a] 0]
# other stuff
}
Code: Select all
if {[matchattr $h C] == "0"} {
Code: Select all
if {![matchattr $h C]} {
, I wanted it to be
can you please change it?*!*@honeybee.users.quakenet.org
Something like:honeybee wrote:Is it possible to restrict users not to trigger a command more than 3 times if the password supplied is incorrect?
and if they tirgger it more than 3 times they will be ignored for lets say X mints.
I'm trying to figure that out but found it to be kinda too difficult. thanks for all the help
Code: Select all
proc wrongPass {v o s} {
upvar $v uv
if {![info exists uv]} {
set uv [list [unixtime] 0]; return 0
}
foreach {ct co} $uv {break}
if {[unixtime]-$ct > $s} {
set uv [list [unixtime] 0]; return 0
}
if {$co >= $o} {
return 1
}
return 0
}
Code: Select all
if {![wrongPass wrongPass([string tolower $nick]) 3 180]} {
if {![passwdok $hand $pass]} {
foreach {foo bar} $wrongPass([string tolower $nick]) {break}
set wrongPass([string tolower $nick]) [list [unixtime] [incr bar]]
} {
unset wrongPass([stringtolower $nick])
# do stuff...
}
}
You didn't say tha in your initial post, you saidSir_Fz: the host for QuakeNet registered users is still *!ident@username.users.quakenet.org like
Quote:
*!*sexy@honeybee.users.quakenet.org
, I wanted it to be
Quote:
*!*@honeybee.users.quakenet.org
can you please change it?
But to fix it, just change the 2ndhoneybee wrote:4) registered quakenet users eg: *!honey@honey.users.quakenet.org
Code: Select all
set ehost *!*[string trimleft $uhost ~]
Code: Select all
set ehost *!*@[lindex [split $uhost @] 1]
Code: Select all
set ehost *!*@[lindex [split $uhost @] 1]
Code: Select all
if {[passwdok $h $oldpass] != 1} {
puthelp "NOTICE $n : password inncorrect try again."
return 1
}
Code: Select all
if {![wrongPass wrongPass([string tolower $n]) 3 180]} {
if {![passwdok $h $oldpass]} {
puthelp "NOTICE $n : password incorrect try again."
foreach {foo bar} $wrongPass([string tolower $n]) {break}
set wrongPass([string tolower $n]) [list [unixtime] [incr bar]]
} {
unset wrongPass([stringtolower $])
puthelp "NOTICE $n : Password incorrect, ignoring for 3 mints. try laters"
}
return 1
}
Code: Select all
proc setHost uhost {
set host [lindex [split $uhost @] 1]
set n [llength [split $host .]]
if {[string match "*.users.quakenet.org" $host]} {
set ehost *!*@[lindex [split $uhost @] 1]
} elseif {[regexp -all {[A-z]{1,}(\.?)} $host] == $n && ![regexp {[0-9]} $host]} {
set ehost *!*[string trimleft $uhost ~]
} {
set ehost [maskhost $uhost]
}
set ehost
}
Code: Select all
proc rightPass {v o s n h op} {
upvar $v uv
if {![info exists uv]} {
set uv [list [unixtime] 0]
}
foreach {ct co} $uv {break}
if {[unixtime]-$ct > $s} {
set uv [list [unixtime] 0]
foreach {ct co} $uv {break}
}
if {$co >= $o} {return 0}
if {![passwdok $h $op]} {
puthelp "NOTICE $n :password incorrect try again."
set uv [list [unixtime] [incr co]]
return 0
}
unset uv
return 1
}
Code: Select all
if {[rightPass wrongPass([string tolower $n]) 3 180 $n $h $oldpass]} {
# He got the right pass
}