BT.VoiceOnMsg.tcl 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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 {![info exists black(voiceonmsg:list:$chan)]} {
  26. set black(voiceonmsg:list:$chan) ""
  27. }
  28. set host "$nick"
  29. if {[isvoice $nick $chan]} { return }
  30. if {[isop $nick $chan]} { return }
  31. if {![botisop $chan]} { return }
  32. if {![info exists black(voiceonmsg:$host:$chan)]} {
  33. if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $host]] == -1} {
  34. lappend black(voiceonmsg:list:$chan) $host
  35. }
  36. set black(voiceonmsg:$host:$chan) 1
  37. utimer 300 [list voiceonmsg:remove $host $chan]
  38. return
  39. }
  40. if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $host]] == -1} {
  41. lappend black(voiceonmsg:list:$chan) $host
  42. }
  43. set current_count $black(voiceonmsg:$host:$chan)
  44. set black(voiceonmsg:$host:$chan) [expr $current_count + 1]
  45. foreach tmr [utimers] {
  46. if {[string match "*voiceonmsg:remove:expire $host $chan*" [join [lindex $tmr 1]]]} {
  47. killutimer [lindex $tmr 2]
  48. }
  49. }
  50. utimer 300 [list voiceonmsg:remove:expire $host $chan]
  51. set linenum [setting:get $chan voiceonmsg-linenum]
  52. if {$linenum == ""} {
  53. set linenum $black(voiceonmsg:linenum)
  54. }
  55. if {$black(voiceonmsg:$host:$chan) >= $linenum} {
  56. utimer 2 [list pushmode $chan +v $nick]
  57. voiceonmsg:remove $host $chan
  58. }
  59. }
  60. }
  61. proc voiceonmsg:remove {host chan} {
  62. global black
  63. foreach tmr [utimers] {
  64. if {[string match "*voiceonmsg:remove:expire $host $chan*" [join [lindex $tmr 1]]]} {
  65. killutimer [lindex $tmr 2]
  66. }
  67. if {[string match "*voiceonmsg:remove $host $chan*" [join [lindex $tmr 1]]]} {
  68. killutimer [lindex $tmr 2]
  69. }
  70. }
  71. }
  72. proc voiceonmsg:remove:the_list {h chan} {
  73. global black
  74. if {[info exists black(voiceonmsg:list:$chan)]} {
  75. if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]] > -1} {
  76. set position [lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]]
  77. set black(voiceonmsg:list:$chan) [lreplace $black(voiceonmsg:list:$chan) $position $position]
  78. }
  79. }
  80. }
  81. proc voiceonmsg:remove:expire {host chan} {
  82. global black
  83. foreach tmr [utimers] {
  84. if {[string match "*voiceonmsg:remove:expire $host $chan*" [join [lindex $tmr 1]]]} {
  85. killutimer [lindex $tmr 2]
  86. }
  87. }
  88. if {[info exists black(voiceonmsg:$host:$chan)]} {
  89. unset black(voiceonmsg:$host:$chan)
  90. }
  91. }
  92. proc voiceonmsg:changenick {nick host hand chan newnick} {
  93. global black
  94. if {![validchan $chan]} {
  95. return
  96. }
  97. if {[setting:get $chan voiceonmsg]} {
  98. if {[info exists black(voiceonmsg:list:$chan)] && $black(voiceonmsg:list:$chan) != ""} {
  99. set h $nick
  100. if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]] > -1} {
  101. set position [lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]]
  102. set black(voiceonmsg:list:$chan) [lreplace $black(voiceonmsg:list:$chan) $position $position]
  103. }
  104. lappend black(voiceonmsg:list:$chan) $newnick
  105. if {[info exists black(voiceonmsg:$h:$chan)]} {
  106. set black(voiceonmsg:$newnick:$chan) $black(voiceonmsg:$h:$chan)
  107. unset black(voiceonmsg:$h:$chan)
  108. }
  109. }
  110. }
  111. }
  112. proc voiceonmsg:part {nick host hand chan arg} {
  113. global black
  114. voiceonmsg:remove:expire $nick $chan
  115. voiceonmsg:remove:the_list $nick $chan
  116. }
  117. proc voiceonmsg:split {nick host hand chan args} {
  118. global black
  119. voiceonmsg:remove:expire $nick $chan
  120. voiceonmsg:remove:the_list $nick $chan
  121. }
  122. proc voiceonmsg:kick {nick host hand chan kicked reason} {
  123. global black
  124. voiceonmsg:remove:expire $kicked $chan
  125. voiceonmsg:remove:the_list $kicked $chan
  126. }
  127. proc voiceonmsg:timer {} {
  128. global black
  129. set channels ""
  130. foreach chan [channels] {
  131. if {[setting:get $chan voiceonmsg]} {
  132. lappend channels $chan
  133. }
  134. }
  135. if {$channels != ""} {
  136. voiceonmsg:act $channels 0
  137. timer 1 voiceonmsg:timer
  138. }
  139. }
  140. proc voiceonmsg:act {channels counter} {
  141. global black
  142. set chan [lindex $channels $counter]
  143. set cc [expr $counter + 1]
  144. if {[info exists black(voiceonmsg:list:$chan)] && $black(voiceonmsg:list:$chan) != ""} {
  145. foreach nick [chanlist $chan] {
  146. set h $nick
  147. set position [lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]]
  148. if {$position > -1} {
  149. set handle [nick2hand $nick $chan]
  150. if {![matchattr $handle "-|gf" $chan]} {
  151. set idletime [setting:get $chan voiceonmsg-idletime]
  152. if {$idletime == ""} {
  153. set idletime $black(voiceonmsg:idletime)
  154. }
  155. set idletime [time_return_minute $idletime]
  156. if {[getchanidle $nick $chan] >= $idletime} {
  157. if {[isvoice $nick $chan]} {
  158. utimer 2 [list pushmode $chan -v $nick]
  159. }
  160. voiceonmsg:remove:expire $h $chan
  161. voiceonmsg:remove:the_list $h $chan
  162. }
  163. }
  164. } else {
  165. if {![info exists black(voiceonmsg:$h:$chan)]} {
  166. voiceonmsg:remove:the_list $h $chan
  167. } else {
  168. voiceonmsg:remove:expire $h $chan
  169. voiceonmsg:remove:the_list $h $chan
  170. }
  171. }
  172. }
  173. }
  174. if {[lindex $channels $cc] == ""} {
  175. return
  176. } else {
  177. voiceonmsg:act $channels $cc
  178. }
  179. }
  180. proc remove:flood:join {chan} {
  181. global black
  182. if {[info exists black(countflood:join:$chan)]} {
  183. unset black(countflood:join:$chan)
  184. }
  185. }
  186. ##############
  187. #########################################################################
  188. ## END ##
  189. #########################################################################