BT.Idle.tcl 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. #########################################################################
  2. ## BlackTools - The Ultimate Channel Control Script ##
  3. ## One TCL. One smart Eggdrop ##
  4. #########################################################################
  5. ############################# IDLE 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 antidle:process {why type user host nick hand chan chan1} {
  16. global botnick black
  17. set show_user $user
  18. set flag "-|+f"
  19. set handle [nick2hand $user]
  20. if {[matchattr $hand q]} {
  21. blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
  22. return
  23. }
  24. if {[matchattr $hand -|q $chan]} {
  25. blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
  26. return
  27. }
  28. if {($why == "") && ($type == "0")} {
  29. blacktools:tell $nick $host $hand $chan $chan1 gl.instr "idle"
  30. return
  31. }
  32. if {($why == "") && ($type == "1")} {
  33. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "idle"
  34. return
  35. }
  36. if {($why == "") && ($type == "2")} {
  37. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "idle"
  38. return
  39. }
  40. if {![validchan $chan]} {
  41. blacktools:tell $nick $host $hand $chan $chan1 gl.novalidchan none
  42. return
  43. }
  44. if {![onchan $botnick $chan]} {
  45. blacktools:tell $nick $host $hand $chan $chan1 gl.notonchan none
  46. return
  47. }
  48. switch $why {
  49. +o {
  50. setting:set $chan +idleop ""
  51. blacktools:tell $nick $host $hand $chan $chan1 idle.11 none
  52. foreach tmr [timers] {
  53. if {[string match "*antidle:module*" [join [lindex $tmr 1]]]} {
  54. return
  55. }
  56. }
  57. set idle_time [time_return_minute $black(idleinterval)]
  58. timer $idle_time antidle:module
  59. }
  60. -o {
  61. setting:set $chan -idleop ""
  62. blacktools:tell $nick $host $hand $chan $chan1 idle.12 none
  63. }
  64. -ho {
  65. setting:set $chan -idlehalfop ""
  66. blacktools:tell $nick $host $hand $chan $chan1 idle.26 none
  67. }
  68. +v {
  69. setting:set $chan +idlevoice ""
  70. blacktools:tell $nick $host $hand $chan $chan1 idle.14 none
  71. foreach tmr [timers] {
  72. if {[string match "*antidle:module*" [join [lindex $tmr 1]]]} {
  73. return
  74. }
  75. }
  76. set idle_time [time_return_minute $black(idleinterval)]
  77. timer $idle_time antidle:module
  78. }
  79. +ho {
  80. setting:set $chan +idlehalfop ""
  81. blacktools:tell $nick $host $hand $chan $chan1 idle.25 none
  82. foreach tmr [timers] {
  83. if {[string match "*antidle:module*" [join [lindex $tmr 1]]]} {
  84. return
  85. }
  86. }
  87. set idle_time [time_return_minute $black(idleinterval)]
  88. timer $idle_time antidle:module
  89. }
  90. -v {
  91. setting:set $chan -idlevoice ""
  92. blacktools:tell $nick $host $hand $chan $chan1 idle.15 none
  93. }
  94. add {
  95. if {$user == ""} {
  96. if {$type == "0"} {
  97. blacktools:tell $nick $host $hand $chan $chan1 gl.instr "idle"
  98. return
  99. }
  100. if {$type == "1"} {
  101. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "idle"
  102. }
  103. return
  104. }
  105. if {[onchan $user $chan]} {
  106. set getuser [nick2hand $user]
  107. if {$getuser != "*"} {
  108. set user $getuser
  109. }
  110. }
  111. if {[validuser $user]} {
  112. chattr $user $flag $chan
  113. blacktools:tell $nick $host $hand $chan $chan1 idle.18 $show_user
  114. } else {
  115. set hosts [getchanhost $user $chan]
  116. set uhost "*!*@[lindex [split $hosts @] 1]"
  117. adduser $user $uhost
  118. chattr $user $flag $chan
  119. blacktools:tell $nick $host $hand $chan $chan1 idle.19 "$show_user $uhost"
  120. }
  121. }
  122. list {
  123. set list [userlist "-|f" $chan]
  124. blacktools:tell $nick $host $hand $chan $chan1 idle.20 "none"
  125. if {$list == ""} {set list "NONE"}
  126. blacktools:tell $nick $host $hand $chan $chan1 idle.21 "$list"
  127. }
  128. del {
  129. if {$user == ""} {
  130. if {$type == "0"} {
  131. blacktools:tell $nick $host $hand $chan $chan1 gl.instr "idle"
  132. return
  133. }
  134. if {$type == "1"} {
  135. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "idle"
  136. }
  137. return
  138. }
  139. if {[onchan $user $chan]} {
  140. set getuser [nick2hand $user]
  141. if {$getuser != "*"} {
  142. set user $getuser
  143. }
  144. }
  145. if {![validuser $user]} {
  146. blacktools:tell $nick $host $hand $chan $chan1 idle.22 "$show_user"
  147. return
  148. }
  149. if {![matchattr $user "-|f" $chan]} {
  150. blacktools:tell $nick $host $hand $chan $chan1 idle.23 "$show_user"
  151. return
  152. }
  153. chattr $user -|-f $chan
  154. blacktools:tell $nick $host $hand $chan $chan1 idle.24 "$show_user"
  155. }
  156. default {
  157. if {$type == "0"} {
  158. blacktools:tell $nick $host $hand $chan $chan1 gl.instr "idle"
  159. return
  160. }
  161. if {$type == "1"} {
  162. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "idle"
  163. }
  164. }
  165. }
  166. }
  167. proc antidle:module {} {
  168. global black
  169. set channels ""
  170. foreach chan [channels] {
  171. if {[setting:get $chan idleop] || [setting:get $chan idlevoice]} {
  172. lappend channels $chan
  173. }
  174. }
  175. if {$channels != ""} {
  176. idlewhois $channels 0
  177. set idle_time [time_return_minute $black(idleinterval)]
  178. timer $idle_time antidle:module
  179. } else {
  180. return
  181. }
  182. }
  183. proc idlewhois {channels counter} {
  184. global black botnick
  185. set chan [lindex $channels $counter]
  186. set cc [expr $counter + 1]
  187. if {$chan != ""} {
  188. black:check:idle $chan
  189. utimer 30 [list idlewhois $channels $cc]
  190. } else {
  191. return
  192. }
  193. }
  194. proc black:check:idle {chan} {
  195. global black
  196. putlog "\[BT\] Scanning for idle on $chan"
  197. set black(idle_chan) $chan
  198. foreach user [chanlist $chan] {
  199. set handle [nick2hand $user]
  200. if {[isop $user $chan] || [isvoice $user $chan] || [ishalfop $user $chan]} {
  201. if {![isbotnick $user]} {
  202. putserv "WHOIS $user $user"
  203. }
  204. }
  205. }
  206. bind raw - 317 idleprocespublic
  207. }
  208. proc idleprocespublic {nick int arg} {
  209. global black
  210. set nick [string tolower [lindex [split $arg] 1]]
  211. set handle [nick2hand $nick]
  212. set idler [string tolower [lindex [split $arg] 2]]
  213. set minutesidle [expr $idler / 60]
  214. set chan $black(idle_chan)
  215. if {[onchan $nick $chan]} {
  216. set idlevoicetime [setting:get $chan idlevoicemax]
  217. if {$idlevoicetime == ""} { set idlevoicetime "$black(idlevoicemax)" }
  218. set idleoptime [setting:get $chan idleopmax]
  219. if {$idleoptime == ""} { set idleoptime "$black(idleopmax)" }
  220. set idlehalfoptime [setting:get $chan idlehalfopmax]
  221. if {$idlehalfoptime == ""} { set idlehalfoptime "$black(idlehalfopmax)" }
  222. if {![info exists black(voiceonmsg:$nick:$chan)]} {
  223. if {[setting:get $chan idlevoice]} {
  224. if {![matchattr $handle "-|gf" $chan]} {
  225. if {$minutesidle > $idlevoicetime} {
  226. if {[setting:get $chan xonly]} {
  227. putserv "PRIVMSG $black(chanserv) :devoice $chan $nick"
  228. } else {
  229. pushmode $chan -v $nick
  230. }
  231. }
  232. }
  233. }
  234. if {[setting:get $chan idleop]} {
  235. if {![matchattr $handle "-|af" $chan]} {
  236. if {$minutesidle > $idleoptime} {
  237. if {[setting:get $chan xonly]} {
  238. putserv "PRIVMSG $black(chanserv) :deop $chan $nick"
  239. } else {
  240. pushmode $chan -o $nick
  241. }
  242. }
  243. }
  244. }
  245. if {[setting:get $chan idlehalfop]} {
  246. if {![matchattr $handle "-|f" $chan]} {
  247. if {$minutesidle > $idlehalfoptime} {
  248. if {[setting:get $chan xonly]} {
  249. return
  250. } else {
  251. pushmode $chan -h $nick
  252. }
  253. }
  254. }
  255. }
  256. }
  257. }
  258. }
  259. ##############
  260. #########################################################################
  261. ## END ##
  262. #########################################################################