SHOW:
|
|
- or go back to the newest paste.
| 1 | - | ### Hosts.tcl 1.5.2 hnyhZSUq |
| 1 | + | ### Hosts.tcl 1.5.0 hnyhZSUq |
| 2 | ||
| 3 | #SUGGESTED | |
| 4 | # PBinSrc.tcl fMrtKqyq | |
| 5 | # TCLLoader.tcl smApj15u | |
| 6 | ||
| 7 | #LICENSE | |
| 8 | # Copyright © 2013 Alberto Dietze "DoctorD90" | |
| 9 | # | |
| 10 | # This program is free software: you can redistribute it and/or modify | |
| 11 | # it under the terms of the GNU General Public License as published by | |
| 12 | # the Free Software Foundation, either version 3 of the License, or | |
| 13 | # (at your option) any later version. | |
| 14 | # | |
| 15 | # This program is distributed in the hope that it will be useful, | |
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 | # GNU General Public License for more details. | |
| 19 | # | |
| 20 | # You should have received a copy of the GNU General Public License | |
| 21 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 22 | # | |
| 23 | # Full GPLv3 Text: http://www.gnu.org/licenses/gpl.txt | |
| 24 | ||
| 25 | #PATERNITY | |
| 26 | #Coder: DoctorD90 | |
| 27 | #Network: irc.OnlineGamesNet.net | |
| 28 | #Chan: #eHito | |
| 29 | #Mail: [email protected] | |
| 30 | #Script's List: www.EggTcl.tk | |
| 31 | ||
| 32 | #PURPOSE | |
| 33 | #Manage own user's hosts from publics and queries commands. | |
| 34 | ||
| 35 | #USAGE | |
| 36 | #Use commands that you set in SETTINGS section. | |
| 37 | ||
| 38 | #SETTINGS | |
| 39 | #Set public command to add host. | |
| 40 | - | set hst(padd) ".+host" |
| 40 | + | set hst(padd) ".host+" |
| 41 | #Set query command to add host. | |
| 42 | - | set hst(madd) ".+host" |
| 42 | + | set hst(madd) ".host+" |
| 43 | - | #Set public command to list hosts. |
| 43 | + | |
| 44 | - | set hst(psee) ".host" |
| 44 | + | set hst(psee) ".hosts" |
| 45 | #Set query command to list hosts. | |
| 46 | - | set hst(msee) ".host" |
| 46 | + | set hst(msee) ".hosts" |
| 47 | - | #Set public command to del host. |
| 47 | + | |
| 48 | - | set hst(pdel) ".-host" |
| 48 | + | set hst(pdel) ".host-" |
| 49 | #Set query command to del host. | |
| 50 | - | set hst(mdel) ".-host" |
| 50 | + | set hst(mdel) ".host-" |
| 51 | ||
| 52 | ||
| 53 | ### DON'T EDIT ANYTHING BELOW ### | |
| 54 | ||
| 55 | bind pub - $hst(psee) pub_hosts | |
| 56 | proc pub_hosts {nick uhost hand chan text} {
| |
| 57 | msg_hosts $nick $uhost $hand $text | |
| 58 | } | |
| 59 | ||
| 60 | bind msg - $hst(msee) msg_hosts | |
| 61 | proc msg_hosts {nick uhost hand text} {
| |
| 62 | if {![validuser $hand]} {
| |
| 63 | - | putserv "NOTICE $nick :You Are Not Found In User Database." |
| 63 | + | notice $nick "You Are Not Found In User Database." |
| 64 | return | |
| 65 | } | |
| 66 | set i 0 | |
| 67 | set hsts [getuser $hand HOSTS] | |
| 68 | foreach mask $hsts {
| |
| 69 | if {[string match -nocase *telnet* $mask]} {
| |
| 70 | append mask " \002#WARN:\002 Probably required for telnet session." | |
| 71 | } | |
| 72 | - | putserv "NOTICE $nick :\002$i\002) $mask" |
| 72 | + | notice $nick "\002$i\002) $mask" |
| 73 | incr i | |
| 74 | } | |
| 75 | } | |
| 76 | ||
| 77 | ||
| 78 | bind pub - $hst(padd) pub_hostadd | |
| 79 | proc pub_hostadd {nick uhost hand chan text} {
| |
| 80 | msg_hostadd $nick $uhost $hand $text | |
| 81 | } | |
| 82 | ||
| 83 | bind msg - $hst(madd) msg_hostadd | |
| 84 | proc msg_hostadd {nick uhost hand text} {
| |
| 85 | if {![validuser $hand]} {
| |
| 86 | - | putserv "NOTICE $nick :You Are Not Found In User Database." |
| 86 | + | notice $nick "You Are Not Found In User Database." |
| 87 | return | |
| 88 | } | |
| 89 | if {![string length [string trim $text]]} {
| |
| 90 | - | putserv "NOTICE $nick :\002AddHost:\002 HostMask Required." |
| 90 | + | notice $nick "\002AddHost:\002 HostMask Required." |
| 91 | return | |
| 92 | } | |
| 93 | if {![regexp -nocase -- {([^\s]+![^\s]+@[^\s]+)} $text all mask]} {
| |
| 94 | - | putserv "NOTICE $nick :\002AddHost:\002 HostMask Not Allowed (\037nick!ident@host\037)." |
| 94 | + | notice $nick "\002AddHost:\002 HostMask Not Allowed (\037nick!ident@host\037)." |
| 95 | return | |
| 96 | } | |
| 97 | if {$mask == "*!*@*"} {
| |
| 98 | - | putserv "NOTICE $nick :SecuritySystem: Ignore Mask not allowed." |
| 98 | + | notice $nick "SecuritySystem: Ignore Mask not allowed." |
| 99 | return | |
| 100 | } | |
| 101 | setuser $hand HOSTS $mask | |
| 102 | - | putserv "NOTICE $nick :\002AddHost:\002 \037$mask\037 Added." |
| 102 | + | notice $nick "\002AddHost:\002 \037$mask\037 Added." |
| 103 | } | |
| 104 | ||
| 105 | ||
| 106 | bind pub - $hst(pdel) pub_delhost | |
| 107 | proc pub_delhost {nick uhost hand chan text} {
| |
| 108 | msg_delhost $nick $uhost $hand $text | |
| 109 | } | |
| 110 | ||
| 111 | bind msg - $hst(mdel) msg_delhost | |
| 112 | proc msg_delhost {nick uhost hand text} {
| |
| 113 | if {![validuser $hand]} {
| |
| 114 | - | putserv "NOTICE $nick :You Are Not Found In User Database." |
| 114 | + | notice $nick "You Are Not Found In User Database." |
| 115 | return | |
| 116 | } | |
| 117 | if {![string length [string trim $text]]} {
| |
| 118 | - | putserv "NOTICE $nick :\002DelHost:\002 HostMask Number Required." |
| 118 | + | notice $nick "\002DelHost:\002 HostMask Number Required." |
| 119 | return | |
| 120 | } | |
| 121 | set hsts [getuser $hand HOSTS] | |
| 122 | if {![llength $hsts]} {
| |
| 123 | - | putserv "NOTICE $nick :\002DelHost:\002 You MUST have at least one hostmask." |
| 123 | + | notice $nick "\002DelHost:\002 You MUST have at least one hostmask." |
| 124 | return | |
| 125 | } | |
| 126 | set nmsk [lindex $text 0] | |
| 127 | set lhsts [expr {[llength $hsts] - 1}]
| |
| 128 | if {![string is integer -strict $nmsk] || $nmsk < "0" || $nmsk > $lhsts} {
| |
| 129 | - | putserv "NOTICE $nick :\002DelHost:\002 It has to be a number beetwen 0 and $lhsts" |
| 129 | + | notice $nick "\002DelHost:\002 It has to be a number beetwen 0 and $lhsts" |
| 130 | return | |
| 131 | } | |
| 132 | set dmsk [lindex $hsts $nmsk] | |
| 133 | if {[delhost $hand $dmsk]} {
| |
| 134 | - | putserv "NOTICE $nick :\002DelHost:\002 \037$dmsk\037 Deleted." |
| 134 | + | notice $nick "\002DelHost:\002 \037$dmsk\037 Deleted." |
| 135 | } else {
| |
| 136 | - | putserv "NOTICE $nick :\002DelHost:\002 Fail to delete \002$dmsk\002." |
| 136 | + | notice $nick "\002DelHost:\002 Fail to delete \002$dmsk\002." |
| 137 | } | |
| 138 | } | |
| 139 | ||
| 140 | ### | |
| 141 | putlog "Hosts.tcl LOADED" |