BT.VoiceOnMsg.tcl 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. #########################################################################
  2. ## BlackTools - The Ultimate Channel Control Script ##
  3. ## One TCL. One smart Eggdrop ##
  4. #########################################################################
  5. ########################### VOICEONMSG TCL ##########################
  6. #########################################################################
  7. ## ##
  8. ## BlackTools : http://blacktools.tclscripts.net ##
  9. ## Bugs report : http://www.tclscripts.net/ ##
  10. ## Online Help : irc://irc.undernet.org/tcl-help ##
  11. ## #TCL-HELP / UnderNet ##
  12. ## You can ask in english or romanian ##
  13. ## ##
  14. #########################################################################
  15. proc voiceonmsg:public:me {nick host hand chan keyword arg} {
  16. global black
  17. voiceonmsg:public $nick $host $hand $chan $arg
  18. }
  19. proc voiceonmsg:public {nick host hand chan arg} {
  20. global black
  21. if {![validchan $chan]} {
  22. return
  23. }
  24. if {[setting:get $chan voiceonmsg]} {
  25. if {[matchattr $hand "nmo|MAOV" $chan]} {
  26. return
  27. }
  28. if {![info exists black(voiceonmsg:list:$chan)]} {
  29. set black(voiceonmsg:list:$chan) ""
  30. }
  31. if {[isvoice $nick $chan]} { return }
  32. if {[isop $nick $chan]} { return }
  33. if {![botisop $chan]} { return }
  34. if {![info exists black(voiceonmsg:$host:$chan)]} {
  35. if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $host]] == -1} {
  36. lappend black(voiceonmsg:list:$chan) $host
  37. }
  38. set black(voiceonmsg:$host:$chan) 1
  39. utimer 300 [list voiceonmsg:remove $host $chan]
  40. return
  41. }
  42. if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $host]] == -1} {
  43. lappend black(voiceonmsg:list:$chan) $host
  44. }
  45. set current_count $black(voiceonmsg:$host:$chan)
  46. set black(voiceonmsg:$host:$chan) [expr $current_count + 1]
  47. foreach tmr [utimers] {
  48. if {[string match -nocase "*voiceonmsg:remove:expire $host $chan*" [join [lindex $tmr 1]]]} {
  49. killutimer [lindex $tmr 2]
  50. }
  51. }
  52. utimer 300 [list voiceonmsg:remove:expire $host $chan]
  53. set linenum [setting:get $chan voiceonmsg-linenum]
  54. if {$linenum == ""} {
  55. set linenum $black(voiceonmsg:linenum)
  56. }
  57. if {$black(voiceonmsg:$host:$chan) >= $linenum} {
  58. if {[setting:get $chan xonly] && [onchan $black(chanserv) $chan]} {
  59. putserv "PRIVMSG $black(chanserv) :voice $chan $nick"
  60. } else {
  61. pushmode $chan +v $nick
  62. }
  63. voiceonmsg:remove $host $chan
  64. }
  65. }
  66. }
  67. proc voiceonmsg:remove {host chan} {
  68. global black
  69. foreach tmr [utimers] {
  70. if {[string match "*voiceonmsg:remove:expire $host $chan*" [join [lindex $tmr 1]]]} {
  71. killutimer [lindex $tmr 2]
  72. }
  73. if {[string match "*voiceonmsg:remove $host $chan*" [join [lindex $tmr 1]]]} {
  74. killutimer [lindex $tmr 2]
  75. }
  76. }
  77. }
  78. proc voiceonmsg:remove:the_list {h chan} {
  79. global black
  80. if {[info exists black(voiceonmsg:list:$chan)]} {
  81. if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]] > -1} {
  82. set position [lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]]
  83. set black(voiceonmsg:list:$chan) [lreplace $black(voiceonmsg:list:$chan) $position $position]
  84. }
  85. }
  86. }
  87. proc voiceonmsg:remove:expire {host chan} {
  88. global black
  89. foreach tmr [utimers] {
  90. if {[string match "*voiceonmsg:remove:expire $host $chan*" [join [lindex $tmr 1]]]} {
  91. killutimer [lindex $tmr 2]
  92. }
  93. }
  94. if {[info exists black(voiceonmsg:$host:$chan)]} {
  95. unset black(voiceonmsg:$host:$chan)
  96. }
  97. }
  98. proc voiceonmsg:changenick {nick host hand chan newnick} {
  99. global black
  100. if {![validchan $chan]} {
  101. return
  102. }
  103. if {[setting:get $chan voiceonmsg]} {
  104. if {[info exists black(voiceonmsg:list:$chan)] && $black(voiceonmsg:list:$chan) != ""} {
  105. set h $nick
  106. if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]] > -1} {
  107. set position [lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]]
  108. set black(voiceonmsg:list:$chan) [lreplace $black(voiceonmsg:list:$chan) $position $position]
  109. }
  110. lappend black(voiceonmsg:list:$chan) $newnick
  111. if {[info exists black(voiceonmsg:$h:$chan)]} {
  112. set black(voiceonmsg:$newnick:$chan) $black(voiceonmsg:$h:$chan)
  113. unset black(voiceonmsg:$h:$chan)
  114. }
  115. }
  116. }
  117. }
  118. proc voiceonmsg:part {nick host hand chan arg} {
  119. global black
  120. voiceonmsg:remove:expire $host $chan
  121. voiceonmsg:remove:the_list $host $chan
  122. }
  123. proc voiceonmsg:split {nick host hand chan args} {
  124. global black
  125. voiceonmsg:remove:expire $host $chan
  126. voiceonmsg:remove:the_list $host $chan
  127. }
  128. proc voiceonmsg:kick {nick host hand chan kicked reason} {
  129. global black
  130. set kickhost [getchanhost $kicked $chan]
  131. voiceonmsg:remove:expire $kickhost $chan
  132. voiceonmsg:remove:the_list $kickhost $chan
  133. }
  134. proc voiceonmsg:timer {} {
  135. global black
  136. set channels ""
  137. foreach chan [channels] {
  138. if {[setting:get $chan voiceonmsg]} {
  139. lappend channels $chan
  140. }
  141. }
  142. if {$channels != ""} {
  143. voiceonmsg:act $channels 0
  144. timer 1 voiceonmsg:timer
  145. }
  146. }
  147. proc voiceonmsg:act {channels counter} {
  148. global black
  149. set chan [lindex $channels $counter]
  150. set cc [expr $counter + 1]
  151. if {[info exists black(voiceonmsg:list:$chan)] && $black(voiceonmsg:list:$chan) != ""} {
  152. foreach nick [chanlist $chan] {
  153. set h [getchanhost $nick $chan]
  154. set position [lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]]
  155. if {$position > -1} {
  156. set handle [nick2hand $nick $chan]
  157. if {![matchattr $handle "-|gf" $chan]} {
  158. set idletime [setting:get $chan voiceonmsg-idletime]
  159. if {$idletime == ""} {
  160. set idletime $black(voiceonmsg:idletime)
  161. }
  162. set idletime [time_return_minute $idletime]
  163. if {[getchanidle $nick $chan] >= $idletime} {
  164. if {[isvoice $nick $chan]} {
  165. if {[setting:get $chan xonly] && [onchan $black(chanserv) $chan]} {
  166. putserv "PRIVMSG $black(chanserv) :devoice $chan $nick"
  167. } else {
  168. utimer 2 [list pushmode $chan -v $nick]
  169. }
  170. }
  171. voiceonmsg:remove:expire $h $chan
  172. voiceonmsg:remove:the_list $h $chan
  173. }
  174. }
  175. } else {
  176. if {![info exists black(voiceonmsg:$h:$chan)]} {
  177. voiceonmsg:remove:the_list $h $chan
  178. } else {
  179. voiceonmsg:remove:expire $h $chan
  180. voiceonmsg:remove:the_list $h $chan
  181. }
  182. }
  183. }
  184. }
  185. if {[lindex $channels $cc] == ""} {
  186. return
  187. } else {
  188. voiceonmsg:act $channels $cc
  189. }
  190. }
  191. proc remove:flood:join {chan} {
  192. global black
  193. if {[info exists black(countflood:join:$chan)]} {
  194. unset black(countflood:join:$chan)
  195. }
  196. }
  197. ##############
  198. #########################################################################
  199. ## END ##
  200. #########################################################################