DoctorD90

Ignore.tcl 2.5.1

May 7th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 6.84 KB | None | 0 0
  1. ### Ignore.tcl 2.5.1 kPnKk1Zs
  2.  
  3. #REQUIREMENTS
  4. # nOwn.tcl dr7v2Zmq
  5.  
  6. #SUGGESTED
  7. # PBinSrc.tcl fMrtKqyq
  8. # TCLLoader.tcl smApj15u
  9.  
  10. #LICENSE
  11. # Copyright © 2013 Alberto Dietze "DoctorD90"
  12. #
  13. #    This program is free software: you can redistribute it and/or modify
  14. #    it under the terms of the GNU General Public License as published by
  15. #    the Free Software Foundation, either version 3 of the License, or
  16. #    (at your option) any later version.
  17. #
  18. #    This program is distributed in the hope that it will be useful,
  19. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. #    GNU General Public License for more details.
  22. #
  23. #    You should have received a copy of the GNU General Public License
  24. #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  25. #
  26. # Full GPLv3 Text: http://www.gnu.org/licenses/gpl.txt
  27.  
  28. #PATERNITY
  29. #Coder: DoctorD90
  30. #Network: irc.OnlineGamesNet.net
  31. #Chan: #eHito
  32. #Script's List: www.EggTcl.tk
  33.  
  34. #PURPOSE
  35. #Ignore people and prevent that can use bot's commands.
  36.  
  37. #USAGE
  38. #Use commands that you set in SETTINGS section.
  39. #Add: <Nick|Mask> <Reason>
  40. #TimeAdd: <Minutes> <Nick|Mask> <Reason>
  41. #Del: <Ignore Entry's Number>
  42.  
  43. #SETTINGS
  44. #Set the time in minutes that temporary ignores should last.
  45. #By default, is used the default value setted
  46. #in your eggdrop's config file.
  47. #If you want change it, change this sett.
  48. set ignore(exp) ${ignore-time}
  49. #Set flag of people can use public command.
  50. set ignore(pflag) "n"
  51. #Set flag of people can use query command.
  52. set ignore(qflag) "n"
  53. #Set public command to add ignore.
  54. set ignore(padd) ".+ignore"
  55. #Set query command to add ignore.
  56. set ignore(qadd) ".+ignore"
  57. #Set public command to add time ignore.
  58. set ignore(ptadd) ".+tignore"
  59. #Set query command to add time ignore.
  60. set ignore(qtadd) ".+tignore"
  61. #Set public command to list ignores.
  62. set ignore(psee) ".ignore"
  63. #Set query command to list ignores.
  64. set ignore(qsee) ".ignore"
  65. #Set public command to del ignore.
  66. set ignore(pdel) ".-ignore"
  67. #Set query command to del ignore.
  68. set ignore(qdel) ".-ignore"
  69. #Set public command to del ignore.
  70. set ignore(padel) ".-ignoreall"
  71. #Set query command to del ignore.
  72. set ignore(qadel) ".-ignoreall"
  73.  
  74.  
  75. ### DON'T EDIT ANYTHING BELOW ###
  76.  
  77. set trigger-on-ignore 0
  78.  
  79. ### Ignore
  80.  
  81. bind pub $ignore(pflag) $ignore(padd) pub_ignoreadd
  82. proc pub_ignoreadd {nick uhost hand chan text} {
  83.   msg_tignoreadd $nick $uhost $hand "${::ignore-time} $text"
  84. }
  85.  
  86. bind msg $ignore(qflag) $ignore(qadd) msg_ignoreadd
  87. proc msg_ignoreadd {nick uhost hand text} {
  88.   msg_tignoreadd $nick $uhost $hand "${::ignore-time} $text"
  89. }
  90.  
  91. bind pub $ignore(pflag) $ignore(ptadd) pub_tignoreadd
  92. proc pub_tignoreadd {nick uhost hand chan text} {
  93.   msg_tignoreadd $nick $uhost $hand $text
  94. }
  95.  
  96. bind msg $ignore(qflag) $ignore(qtadd) msg_tignoreadd
  97. proc msg_tignoreadd {nick uhost hand text} {
  98.   set text [split $text]
  99.   set time [lindex $text 0]
  100.   set target [lindex $text 1]
  101.   set why [join [lrange $text 2 end]]
  102.   ignore_add $nick $target $why $time
  103. }
  104.  
  105. proc ignore_add {nick target why exp} {
  106.   if {![string is integer -strict $exp]} {
  107.     notice $nick "\002AddIgnore:\002 Expiration Ignore In Number Format Required ."
  108.     return
  109.   }
  110.   if {$exp < "0"} {
  111.     set exp "0"
  112.   }
  113.   if {![string length [string trim $target]]} {
  114.     notice $nick "\002AddIgnore:\002 User's Nick|Mask Required."
  115.     return
  116.   }
  117.   if {[regexp -nocase -- {([^\s]+![^\s]+@[^\s]+)} $target mask]} {
  118.     if {$mask == "*!*@*"} {
  119.       notice $nick "SecuritySystem: Ignore Mask not allowed."
  120.       return
  121.     }
  122.   } else {
  123.     if {![onchan $target]} {
  124.       notice $nick "\002$target\002 aint on no one chan in which I am too or Ignore Mask not valid."
  125.       return
  126.     }
  127.     set mask [maskhost ${target}![getchanhost $target] 2]
  128.   }
  129.   if {[isignore $mask]} {
  130.     notice $nick "\002$mask\002 yet Ignored."
  131.     return
  132.   }
  133.   set Bmask "$::botnick![getchanhost $::botnick]"
  134.   if {[lsearch -nocase $Bmask $mask] != "-1"} {
  135.     notice $nick "Dumbass. I aint ignorin' myself!"
  136.     return
  137.   }
  138.   set Nmask [getuser $::owner HOSTS]
  139.   lappend Nmask "[nown]![getchanhost [nown]]"
  140.   if {[lsearch -nocase $Nmask $mask] != "-1"} {
  141.     notice $nick "Dumbass. I aint ignorin' my owner!"
  142.     return
  143.   }
  144.   if {![string length [string trim $why]]} {
  145.     set why "None"
  146.   }
  147.   newignore $mask $nick $why $exp
  148.   notice $nick "\002$mask\002 has been ignored for \002$why\002"
  149. }
  150.  
  151.  
  152. ### UnIgnore
  153.  
  154. bind pub $ignore(pflag) $ignore(pdel) pub_ignoredel
  155. proc pub_ignoredel {nick uhost hand chan text} {
  156.   msg_ignoredel $nick $uhost $hand $text
  157. }
  158.  
  159. bind msg $ignore(qflag) $ignore(qdel) msg_ignoredel
  160. proc msg_ignoredel {nick uhost hand text} {
  161.   if {[iliste $nick]} {return}
  162.   if {![string length [string trim $text]]} {
  163.     notice $nick "\002DelIgnore:\002 Ignore's Number Required."
  164.     return
  165.   }
  166.   set i [lindex [split $text] 0]
  167.   set l [llength [ignorelist]]
  168.   if {![string is integer -strict $i] || $i < "0" || $i >= $l} {
  169.     notice $nick "\002DelIgnore:\002 Ignore's Number Not Accepted."
  170.     return
  171.   }
  172.   set mask [lindex [lindex [ignorelist] $i] 0]
  173.   killignore $mask
  174.   notice $nick "\002$mask\002 UnIgnored"
  175. }
  176.  
  177.  
  178. ### UnIgnoreAll
  179.  
  180. bind pub $ignore(pflag) $ignore(padel) pub_unignoreall
  181. proc pub_unignoreall {nick uhost hand chan text} {
  182.   msg_unignoreall $nick $uhost $hand $text
  183. }
  184.  
  185. bind msg $ignore(qflag) $ignore(qadel) msg_unignoreall
  186. proc msg_unignoreall {nick uhost hand text} {
  187.   if {[iliste $nick]} {return}
  188.   set l [llength [ignorelist]]
  189.   set i 0
  190.   foreach ignore [ignorelist] {
  191.     set mask [lindex $ignore 0]
  192.     killignore $mask
  193.     notice $nick "\002$mask\002 UnIgnored"
  194.     incr i
  195.   }
  196.   if {$i > 1} {
  197.     set ixs s
  198.   } else {
  199.     set ixs ""
  200.   }
  201.   notice $nick "Removed \002$i\002/\002$l\002 ignore$ixs from Ignore List"
  202. }
  203.  
  204.  
  205. ### IgnoreList
  206.  
  207. bind pub $ignore(pflag) $ignore(psee) pub_ignore
  208. proc pub_ignore {nick uhost hand chan text} {
  209.   msg_ignore $nick $uhost $hand $text
  210. }
  211.  
  212. bind msg $ignore(qflag) $ignore(qsee) msg_ignore
  213. proc msg_ignore {nick uhost hand text} {
  214.   if {[iliste $nick]} {return}
  215.   notice $nick "'s  Ignore List"
  216.   set i 0
  217.   foreach ignore [ignorelist] {
  218.     foreach {mask why expt sett who} $ignore { break }
  219.     set Start [ clock format $sett -format "%d/%m/%Y %H:%M:%S" ]
  220.     set End [ clock format $expt -format "%d/%m/%Y %H:%M:%S" ]
  221.     if {$Start > $End} {
  222.       set End NEVER
  223.     }
  224.     notice $nick "\002$i\002) \002$mask (\037From\037: \002$Start\002 - \037Since\037: \002$End\002; \037By\037: \002$who\002; \037Reson\037: \002$why\002)\002"
  225.     incr i
  226.   }
  227.   notice $nick "'s  Ignore List  \002\037*Completed*\037\002"
  228. }
  229.  
  230. proc iliste {who} {
  231.   set r 0
  232.   if {![llength [ignorelist]]} {
  233.     notice $who "'s  Ignore List  \002\037*EMPTY*\037\002"
  234.     set r 1
  235.   }
  236.   return $r
  237. }
  238.  
  239. ###
  240. putlog "Ignore.tcl LOADED"
Advertisement