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. ## GitHub page : https://github.com/tclscripts/BlackToolS-TCL ##
  11. ## Online Help : irc://irc.undernet.org/tcl-help ##
  12. ## #TCL-HELP / UnderNet ##
  13. ## You can ask in english or romanian ##
  14. ## ##
  15. #########################################################################
  16. proc voiceonmsg:public:me {nick host hand chan keyword arg} {
  17. global black
  18. if {[string equal -nocase $keyword "ACTION"]} {
  19. voiceonmsg:public $nick $host $hand $chan $arg
  20. }
  21. }
  22. proc voiceonmsg:public {nick host hand chan arg} {
  23. global black
  24. if {![validchan $chan]} {
  25. return
  26. }
  27. if {[setting:get $chan voiceonmsg]} {
  28. if {[matchattr $hand "nmo|MAOV" $chan]} {
  29. return
  30. }
  31. if {![info exists black(voiceonmsg:list:$chan)]} {
  32. set black(voiceonmsg:list:$chan) ""
  33. }
  34. if {[isvoice $nick $chan]} { return }
  35. if {[isop $nick $chan]} { return }
  36. if {![botisop $chan]} { return }
  37. if {![info exists black(voiceonmsg:$host:$chan)]} {
  38. if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $host]] == -1} {
  39. lappend black(voiceonmsg:list:$chan) $host
  40. }
  41. set black(voiceonmsg:$host:$chan) 1
  42. utimer 300 [list voiceonmsg:remove $host $chan]
  43. return
  44. }
  45. if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $host]] == -1} {
  46. lappend black(voiceonmsg:list:$chan) $host
  47. }
  48. set current_count $black(voiceonmsg:$host:$chan)
  49. set black(voiceonmsg:$host:$chan) [expr $current_count + 1]
  50. foreach tmr [utimers] {
  51. if {[string match -nocase "*voiceonmsg:remove:expire $host $chan*" [join [lindex $tmr 1]]]} {
  52. killutimer [lindex $tmr 2]
  53. }
  54. }
  55. utimer 300 [list voiceonmsg:remove:expire $host $chan]
  56. set linenum [setting:get $chan voiceonmsg-linenum]
  57. if {$linenum == ""} {
  58. set linenum $black(voiceonmsg:linenum)
  59. }
  60. if {$black(voiceonmsg:$host:$chan) >= $linenum} {
  61. if {[setting:get $chan xonly] && [onchan $black(chanserv) $chan]} {
  62. putserv "PRIVMSG $black(chanserv) :voice $chan $nick"
  63. } else {
  64. pushmode $chan +v $nick
  65. }
  66. voiceonmsg:remove $host $chan
  67. }
  68. }
  69. }
  70. proc voiceonmsg:remove {host chan} {
  71. global black
  72. foreach tmr [utimers] {
  73. if {[string match "*voiceonmsg:remove:expire $host $chan*" [join [lindex $tmr 1]]]} {
  74. killutimer [lindex $tmr 2]
  75. }
  76. if {[string match "*voiceonmsg:remove $host $chan*" [join [lindex $tmr 1]]]} {
  77. killutimer [lindex $tmr 2]
  78. }
  79. }
  80. }
  81. proc voiceonmsg:remove:the_list {h chan} {
  82. global black
  83. if {[info exists black(voiceonmsg:list:$chan)]} {
  84. if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]] > -1} {
  85. set position [lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]]
  86. set black(voiceonmsg:list:$chan) [lreplace $black(voiceonmsg:list:$chan) $position $position]
  87. }
  88. }
  89. }
  90. proc voiceonmsg:remove:expire {host chan} {
  91. global black
  92. foreach tmr [utimers] {
  93. if {[string match "*voiceonmsg:remove:expire $host $chan*" [join [lindex $tmr 1]]]} {
  94. killutimer [lindex $tmr 2]
  95. }
  96. }
  97. if {[info exists black(voiceonmsg:$host:$chan)]} {
  98. unset black(voiceonmsg:$host:$chan)
  99. }
  100. }
  101. proc voiceonmsg:changenick {nick host hand chan newnick} {
  102. global black
  103. if {![validchan $chan]} {
  104. return
  105. }
  106. if {[setting:get $chan voiceonmsg]} {
  107. if {[info exists black(voiceonmsg:list:$chan)] && $black(voiceonmsg:list:$chan) != ""} {
  108. set h $nick
  109. if {[lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]] > -1} {
  110. set position [lsearch -exact [string tolower $black(voiceonmsg:list:$chan)] [string tolower $h]]
  111. set black(voiceonmsg:list:$chan) [lreplace $black(voiceonmsg:list:$chan) $position $position]
  112. }
  113. lappend black(voiceonmsg:list:$chan) $newnick
  114. if {[info exists black(voiceonmsg:$h:$chan)]} {
  115. set black(voiceonmsg:$newnick:$chan) $black(voiceonmsg:$h:$chan)
  116. unset black(voiceonmsg:$h:$chan)
  117. }
  118. }
  119. }
  120. }
  121. proc voiceonmsg:part {nick host hand chan arg} {
  122. global black
  123. voiceonmsg:remove:expire $host $chan
  124. voiceonmsg:remove:the_list $host $chan
  125. }
  126. proc voiceonmsg:split {nick host hand chan args} {
  127. global black
  128. voiceonmsg:remove:expire $host $chan
  129. voiceonmsg:remove:the_list $host $chan
  130. }
  131. proc voiceonmsg:kick {nick host hand chan kicked reason} {
  132. global black
  133. set kickhost [getchanhost $kicked $chan]
  134. voiceonmsg:remove:expire $kickhost $chan
  135. voiceonmsg:remove:the_list $kickhost $chan
  136. }
  137. proc voiceonmsg:timer {chans} {
  138. global black
  139. set channels ""
  140. foreach chan $chans {
  141. lappend channels $chan
  142. }
  143. if {$channels != ""} {
  144. voiceonmsg:act $channels 0
  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. #########################################################################