Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Hosts.tcl 1.5.1 hnyhZSUq
- #SUGGESTED
- # PBinSrc.tcl fMrtKqyq
- # TCLLoader.tcl smApj15u
- #LICENSE
- # Copyright © 2013 Alberto Dietze "DoctorD90"
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- #
- # Full GPLv3 Text: http://www.gnu.org/licenses/gpl.txt
- #PATERNITY
- #Coder: DoctorD90
- #Network: irc.OnlineGamesNet.net
- #Chan: #eHito
- #Mail: DoctorD90@EggTcl.tk
- #Script's List: www.EggTcl.tk
- #PURPOSE
- #Manage own user's hosts from publics and queries commands.
- #USAGE
- #Use commands that you set in SETTINGS section.
- #SETTINGS
- #Set public command to add host.
- set hst(padd) ".+host"
- #Set query command to add host.
- set hst(madd) ".+host"
- #Set public command to list hosts.
- set hst(psee) ".host"
- #Set query command to list hosts.
- set hst(msee) ".host"
- #Set public command to del host.
- set hst(pdel) ".-host"
- #Set query command to del host.
- set hst(mdel) ".-host"
- ### DON'T EDIT ANYTHING BELOW ###
- bind pub - $hst(psee) pub_hosts
- proc pub_hosts {nick uhost hand chan text} {
- msg_hosts $nick $uhost $hand $text
- }
- bind msg - $hst(msee) msg_hosts
- proc msg_hosts {nick uhost hand text} {
- if {![validuser $hand]} {
- notice $nick "You Are Not Found In User Database."
- return
- }
- set i 0
- set hsts [getuser $hand HOSTS]
- foreach mask $hsts {
- if {[string match -nocase *telnet* $mask]} {
- append mask " \002#WARN:\002 Probably required for telnet session."
- }
- notice $nick "\002$i\002) $mask"
- incr i
- }
- }
- bind pub - $hst(padd) pub_hostadd
- proc pub_hostadd {nick uhost hand chan text} {
- msg_hostadd $nick $uhost $hand $text
- }
- bind msg - $hst(madd) msg_hostadd
- proc msg_hostadd {nick uhost hand text} {
- if {![validuser $hand]} {
- notice $nick "You Are Not Found In User Database."
- return
- }
- if {![string length [string trim $text]]} {
- notice $nick "\002AddHost:\002 HostMask Required."
- return
- }
- if {![regexp -nocase -- {([^\s]+![^\s]+@[^\s]+)} $text all mask]} {
- notice $nick "\002AddHost:\002 HostMask Not Allowed (\037nick!ident@host\037)."
- return
- }
- if {$mask == "*!*@*"} {
- notice $nick "SecuritySystem: Ignore Mask not allowed."
- return
- }
- setuser $hand HOSTS $mask
- notice $nick "\002AddHost:\002 \037$mask\037 Added."
- }
- bind pub - $hst(pdel) pub_delhost
- proc pub_delhost {nick uhost hand chan text} {
- msg_delhost $nick $uhost $hand $text
- }
- bind msg - $hst(mdel) msg_delhost
- proc msg_delhost {nick uhost hand text} {
- if {![validuser $hand]} {
- notice $nick "You Are Not Found In User Database."
- return
- }
- if {![string length [string trim $text]]} {
- notice $nick "\002DelHost:\002 HostMask Number Required."
- return
- }
- set hsts [getuser $hand HOSTS]
- if {![llength $hsts]} {
- notice $nick "\002DelHost:\002 You MUST have at least one hostmask."
- return
- }
- set nmsk [lindex $text 0]
- set lhsts [expr {[llength $hsts] - 1}]
- if {![string is integer -strict $nmsk] || $nmsk < "0" || $nmsk > $lhsts} {
- notice $nick "\002DelHost:\002 It has to be a number beetwen 0 and $lhsts"
- return
- }
- set dmsk [lindex $hsts $nmsk]
- if {[delhost $hand $dmsk]} {
- notice $nick "\002DelHost:\002 \037$dmsk\037 Deleted."
- } else {
- notice $nick "\002DelHost:\002 Fail to delete \002$dmsk\002."
- }
- }
- ###
- putlog "Hosts.tcl LOADED"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement