Advertisement
Guest User

Untitled

a guest
Feb 1st, 2018
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.85 KB | None | 0 0
  1. #Caesar's autovoice script with extra features
  2. #
  3. #Use .chanset #channel +av to start this script working
  4. #
  5. #The bot gives +v to everyone who joins the channel.
  6. #
  7. #Public commands: !voice nick1 nick2 nick3 and !devoice nick1 nick2 nick3...
  8. #
  9. #
  10. #- If a user devoiced and he parts the channel and joins again the bot dosen't give the +v only if the pre-defined time (set duration) passed. Time is in seconds.
  11. #- If the devoiced user changes his nick to gain +v the bot dosen't give the +v only if the pre-defined time (set duration) passed. Time is in seconds
  12. #
  13. #
  14. #See: http://forum.egghelp.org/viewtopic.php?p=106589#106589
  15. #
  16. #This script is useful on those channels where +m mode is set. Users can be Easily and effectivly be muted.
  17. #
  18. #
  19. namespace eval av {
  20. #How long do you want to mute the user (in seconds)?
  21. set duration 300
  22. #Use .chanset #channel +av to start this script working
  23. setudef flag av
  24. array set ignoreList {}
  25.  
  26. bind join * * [namespace current]::joining
  27. bind pub o !voice [namespace current]::voice
  28. bind pub o !devoice [namespace current]::devoice
  29. bind mode - "% +v" [namespace current]::mcVoice
  30. bind mode - "% -v" [namespace current]::mcDevoice
  31. bind cron - {*/1 * * * *} [namespace current]::reset
  32.  
  33. proc joining {nick uhost hand chan} {
  34. variable ignoreList
  35. if {![channel get $chan av] || [isbotnick $nick] || ![botisop $chan]} return
  36. if {[array get ignoreList $chan] != {}} {
  37. if {[lsearch -nocase [dict keys [join $ignoreList($chan)]] $uhost] != -1} return
  38. }
  39. puthelp "MODE $chan +v $nick"
  40. }
  41.  
  42. proc voice {nick uhost hand chan text} {
  43. variable ignoreList
  44. if {![channel get $chan av] || ![botisop $chan] || ![llength $text]} return
  45. foreach user [split $text] {
  46. if {[isbotnick $user] || ![onchan $user $chan] || [isvoice $user $chan]} continue
  47. lappend voiceList $user
  48. }
  49. if {[info exists voiceList]} {
  50. push $chan "+" $voiceList
  51. }
  52. }
  53.  
  54. proc devoice {nick uhost hand chan text} {
  55. if {![channel get $chan av] || ![botisop $chan] || ![llength $text]} return
  56. foreach user [split $text] {
  57. if {[isbotnick $user] || ![onchan $user $chan] || ![isvoice $user $chan]} continue
  58. lappend voiceList $user
  59. }
  60. if {[info exists voiceList]} {
  61. push $chan "-" $voiceList
  62. }
  63. }
  64.  
  65. proc push {chan mc userList} {
  66. set max 6
  67. set len [llength $userList]
  68. while {$len > 0} {
  69. if {$len > $max} {
  70. set mode [string repeat "v" $max]
  71. set users [join [lrange $userList 0 [expr {$max - 1}]]]
  72. set userList [lrange $userList $max end]
  73. incr len -$max
  74. } else {
  75. set mode [string repeat "v" $len]
  76. set users [join $userList]
  77. set len 0
  78. }
  79. puthelp "MODE $chan $mc$mode $users"
  80. }
  81. }
  82.  
  83. proc mcVoice {nick uhost hand chan mc target} {
  84. variable ignoreList
  85. if {![channel get $chan av] || ![botisop $chan]} return
  86. if {[array get ignoreList $chan] != {}} {
  87. set pos [lsearch -nocase [dict keys [join $ignoreList($chan)]] [getchanhost $target $chan]]
  88. if {$pos >= 0} {
  89. set ignoreList($chan) [lreplace $ignoreList($chan) $pos $pos]
  90. }
  91. }
  92. }
  93.  
  94. proc mcDevoice {nick uhost hand chan mc target} {
  95. variable ignoreList
  96. if {![channel get $chan av] || ![botisop $chan]} return
  97. set now [clock seconds]
  98. set uhost [getchanhost $target $chan]
  99. if {[array get ignoreList $chan] != {}} {
  100. set pos [lsearch -nocase [dict keys [join $ignoreList($chan)]] $uhost]
  101. if {$pos >=0 } {
  102. set ignoreList($chan) [lreplace $ignoreList($chan) $pos $pos [list $uhost $now]]
  103. return
  104. }
  105. }
  106. lappend ignoreList($chan) [list $uhost $now]
  107. }
  108.  
  109. proc reset {min hour day month weekday} {
  110. variable ignoreList
  111. variable duration
  112. set now [clock seconds]
  113. foreach chan [channels] {
  114. if {![channel get $chan av]} {
  115. if {[array get ignoreList $chan] != {}} {
  116. array unset ignoreList $chan
  117. }
  118. continue
  119. }
  120. if {[array get ignoreList $chan] != {}} {
  121. set x 0
  122. foreach time [dict values [join $ignoreList($chan)]] {
  123. if {($now - $time) >= $duration} {
  124. set ignoreList($chan) [lreplace $ignoreList($chan) $x $x]
  125. incr x
  126. }
  127. }
  128. }
  129. }
  130. }
  131. }
  132. putlog "\002Caesar's autovoice script has been successfully LOADED!"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement