
Code: Select all
bind pub nfo|nfo !users user
proc user {nick uhost hand chan text} {
set option1 [lindex [split $text] 0]
set whom [lindex [split $text] 1]
set option2 [lindex [split $text] 2]
if {$option1 == ""} {
putserv "NOTICE $nick :Option1 includes\: add, del or mod."
return 0
}
set host "$whom![getchanhost $whom $chan]"
set split(host) [lindex [split $host !@] 2]
set user [string range [regsub -nocase -all -- {[^a-z\-]} $whom ""] 0 8]
switch -- $option1 {
add {
if {$whom == ""} {
putserv "NOTICE $nick :Syntax is\: \"!users add <nick> \[voice/friend\](optional)\"."
return 0
} elseif {![onchan $whom $chan]} {
putserv "NOTICE $nick :$whom is not here."
return 0
}
if {$option2 == ""} {
if {[validuser [nick2hand $whom $chan]]} {
putserv "NOTICE $nick :User file for $whom already exists, please use \"!hosts add $whom\" to add a host."
return 0
} else {
if {[regexp -nocase -- {@([:0-9A-Fa-f]+$)} $host a b]} {
adduser $user "$user!*@$b"
save
} elseif {[regexp -nocase -- {@(.*)?(\d+(.|-)){4}} $host]} {
adduser $user "$user!*@*.[lrange [split $host .] 1 end]"
save
} elseif {[regexp -nocase -- {@.*([-./][[:alnum:]]+[-./][[:alnum:]]{2,4})$} $host a]} {
adduser $user "$user!*$a"
save
} else {
putnotc $nick "Host match error!"
return
}
putserv "NOTICE $nick :Userfile created for $whom."
}
} else {
if {![validuser [nick2hand $whom $chan]]} {
adduser $user $option2
save
}
}
}
del {
if {[matchattr [nick2hand $nick $chan] |o $chan]} {
if {$option2 != ""} {
putserv "NOTICE $nick :Syntax is\: \"!users del <nick>\"."
return 0
} elseif {$whom == ""} {
putserv "NOTICE $nick :You must specify who to delete."
return 0
} elseif {![validuser [nick2hand $whom $chan]]} {
putserv "NOTICE $nick :I have no user info for $whom."
return 0
}
deluser [nick2hand $whom $chan]
putserv "NOTICE $nick :Userfile for $whom has been deleted."
save
} else {
putserv "NOTICE $nick :You don't have access to this command."
return 0
}
}
mod {
if {$whom == "" || $option2 == ""} {
putserv "NOTICE $nick :Syntax is\: \"!users mod <nick> <voice/devoice/friend/unfriend/bop>\"."
return 0
} elseif {![onchan $whom $chan]} {
putserv "NOTICE $nick :$whom is not here."
return 0
} elseif {![validuser [nick2hand $whom $chan]]} {
putserv "NOTICE $nick :I have no user info for $whom, please add them with \"!users add $whom\"."
return 0
}
chattr [nick2hand $whom $chan] $option2
save
}
}
switch -- $option2 {
friend {
if {![onchan $whom $chan]} {
putserv "NOTICE $nick :$whom is not here."
return 0
} else {
chattr [nick2hand $whom $chan] |+f $chan
save
putserv "NOTICE $nick :$whom is now a friend of mine! <3"
}
}
unfriend {
if {![matchattr [nick2hand $nick $chan] |o $chan] && $option1 == "mod" || $option1 == "add"} {
putserv "NOTICE $nick :You don't have access to this command."
return 0
} elseif {![onchan $whom $chan]} {
putserv "NOTICE $nick :$whom is not here."
return 0
}
chattr [nick2hand $whom $chan] |-f $chan
save
putserv "NOTICE $nick :$whom is no longer a friend of mine! </3"
}
voice {
if {![onchan $whom $chan]} {
putserv "NOTICE $nick :$whom is not here."
return 0
}
pushmode $chan +v $whom
if {![validuser [nick2hand $whom $chan]]} {
if {[regexp -nocase -- {@([:0-9A-Fa-f]+$)} $host a b]} {
adduser $user "$user!*@$b"
save
} elseif {[regexp -nocase -- {@(.*)?(\d+(.|-)){4}} $host]} {
adduser $user "$user!*@*.[lrange [split $host .] 1 end]"
save
} elseif {[regexp -nocase -- {@.*([-./][[:alnum:]]+[-./][[:alnum:]]{2,4})$} $host a]} {
adduser $user "$user!*$a"
save
}
chattr $user |+A $chan
save
putserv "NOTICE $nick :$whom will now be voiced on join."
} else {
set check [nick2hand $whom $chan]
if {![matchattr $check A|A $chan]} {
chattr $check |+A $chan
save
putserv "NOTICE $nick :$whom was successfully added to the autovoice list."
} else {
return 0
}
}
}
devoice {
if {![matchattr [nick2hand $nick $chan] |o $chan] && $option1 == "mod" || $option1 == "add"} {
putserv "NOTICE $nick :You don't have access to this command."
return
} elseif {![onchan $whom $chan]} {
putserv "NOTICE $nick :$whom is not here."
return 0
}
pushmode $chan -v $whom
if {![validuser [nick2hand $whom $chan]] || ![matchattr [nick2hand $whom $chan] |A $chan]} {
return 0
} else {
chattr [nick2hand $whom $chan] |-A $chan
save
putserv "NOTICE $nick :$whom will no longer de voiced on join"
}
}
bop {
if {![matchattr $nick |oO $chan]} {
putserv "NOTICE $nick :You do not have permission to use this command."
return 0
}
chattr [nick2hand $whom $chan] |+ol $chan
save
putserv "NOTICE $nick :$whom can now use my op comands on $chan."
}
}
}