DoctorD90

Hosts.tcl

May 3rd, 2013
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 3.99 KB | None | 0 0
  1. ### Hosts.tcl 1.5.2 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. #Script's List: www.EggTcl.tk
  30.  
  31. #PURPOSE
  32. #Manage own user's hosts from publics and queries commands.
  33.  
  34. #USAGE
  35. #Use commands that you set in SETTINGS section.
  36.  
  37. #SETTINGS
  38. #Set public command to add host.
  39. set hst(padd) ".+host"
  40. #Set query command to add host.
  41. set hst(madd) ".+host"
  42. #Set public command to list hosts.
  43. set hst(psee) ".host"
  44. #Set query command to list hosts.
  45. set hst(msee) ".host"
  46. #Set public command to del host.
  47. set hst(pdel) ".-host"
  48. #Set query command to del host.
  49. set hst(mdel) ".-host"
  50.  
  51.  
  52. ### DON'T EDIT ANYTHING BELOW ###
  53.  
  54. bind pub - $hst(psee) pub_hosts
  55. proc pub_hosts {nick uhost hand chan text} {
  56.   msg_hosts $nick $uhost $hand $text
  57. }
  58.  
  59. bind msg - $hst(msee) msg_hosts
  60. proc msg_hosts {nick uhost hand text} {
  61.   if {![validuser $hand]} {
  62.     putserv "NOTICE $nick :You Are Not Found In User Database."
  63.     return
  64.   }
  65.   set i 0
  66.   set hsts [getuser $hand HOSTS]
  67.   foreach mask $hsts {
  68.     if {[string match -nocase *telnet* $mask]} {
  69.       append mask "  \002#WARN:\002 Probably required for telnet session."
  70.     }
  71.     putserv "NOTICE $nick :\002$i\002) $mask"
  72.     incr i
  73.   }
  74. }
  75.  
  76.  
  77. bind pub - $hst(padd) pub_hostadd
  78. proc pub_hostadd {nick uhost hand chan text} {
  79.   msg_hostadd $nick $uhost $hand $text
  80. }
  81.  
  82. bind msg - $hst(madd) msg_hostadd
  83. proc msg_hostadd {nick uhost hand text} {
  84.   if {![validuser $hand]} {
  85.     putserv "NOTICE $nick :You Are Not Found In User Database."
  86.     return
  87.   }
  88.   if {![string length [string trim $text]]} {
  89.     putserv "NOTICE $nick :\002AddHost:\002 HostMask Required."
  90.     return
  91.   }
  92.   if {![regexp -nocase -- {([^\s]+![^\s]+@[^\s]+)} $text all mask]} {
  93.     putserv "NOTICE $nick :\002AddHost:\002 HostMask Not Allowed (\037nick!ident@host\037)."
  94.     return
  95.   }
  96.   if {$mask == "*!*@*"} {
  97.     putserv "NOTICE $nick :SecuritySystem: Ignore Mask not allowed."
  98.     return
  99.   }
  100.   setuser $hand HOSTS $mask
  101.   putserv "NOTICE $nick :\002AddHost:\002 \037$mask\037 Added."
  102. }
  103.  
  104.  
  105. bind pub - $hst(pdel) pub_delhost
  106. proc pub_delhost {nick uhost hand chan text} {
  107.   msg_delhost $nick $uhost $hand $text
  108. }
  109.  
  110. bind msg - $hst(mdel) msg_delhost
  111. proc msg_delhost {nick uhost hand text} {
  112.   if {![validuser $hand]} {
  113.     putserv "NOTICE $nick :You Are Not Found In User Database."
  114.     return
  115.   }
  116.   if {![string length [string trim $text]]} {
  117.     putserv "NOTICE $nick :\002DelHost:\002 HostMask Number Required."
  118.     return
  119.   }
  120.   set hsts [getuser $hand HOSTS]
  121.   if {![llength $hsts]} {
  122.     putserv "NOTICE $nick :\002DelHost:\002 You MUST have at least one hostmask."
  123.     return
  124.   }
  125.   set nmsk [lindex $text 0]
  126.   set lhsts [expr {[llength $hsts] - 1}]
  127.   if {![string is integer -strict $nmsk] || $nmsk < "0" || $nmsk > $lhsts} {
  128.     putserv "NOTICE $nick :\002DelHost:\002 It has to be a number beetwen 0 and $lhsts"
  129.     return
  130.   }
  131.   set dmsk [lindex $hsts $nmsk]
  132.   if {[delhost $hand $dmsk]} {
  133.     putserv "NOTICE $nick :\002DelHost:\002 \037$dmsk\037 Deleted."
  134.   } else {
  135.     putserv "NOTICE $nick :\002DelHost:\002 Fail to delete \002$dmsk\002."
  136.   }
  137. }
  138.  
  139. ###
  140. putlog "Hosts.tcl LOADED"
Advertisement
Add Comment
Please, Sign In to add comment