BT.Timers.tcl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. #########################################################################
  2. ## BlackTools - The Ultimate Channel Control Script ##
  3. ## One TCL. One smart Eggdrop ##
  4. #########################################################################
  5. ########################### LOCAL TIMERS ##############################
  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 blacktools:timers:load {chan} {
  17. global black
  18. if {[validchan $chan]} {
  19. #badchan
  20. if {[setting:get $chan antibadchan]} {
  21. if {![info exists black(badchan:$chan:timer_start)]} {
  22. if {[setting:get $chan badchan-scantime] != ""} {
  23. set time [setting:get $chan badchan-scantime]
  24. } else {
  25. set time $black(badchan:scantime)
  26. }
  27. set scan_time [time_return_minute $time]
  28. set black(badchan:$chan:timer_start) $scan_time
  29. }
  30. }
  31. #end
  32. #clonescan
  33. if {[setting:get $chan clonescan]} {
  34. if {![info exists black(clonescan:$chan:timer_start)]} {
  35. if {[setting:get $chan clonescan-scantime] != ""} {
  36. set time [setting:get $chan clonescan-scantime]
  37. } else {
  38. set time $black(clonescantime)
  39. }
  40. set scan_time [time_return_minute $time]
  41. set black(clonescan:$chan:timer_start) $scan_time
  42. }
  43. }
  44. #end
  45. #antispam
  46. if {[setting:get $chan antispam]} {
  47. if {![info exists black(antispam:$chan:timer_start)]} {
  48. if {[setting:get $chan antispam-scantime] != ""} {
  49. set time [setting:get $chan antispam-scantime]
  50. } else {
  51. set time $black(spamcycle)
  52. }
  53. set scan_time [time_return_minute $time]
  54. set black(antispam:$chan:timer_start) $scan_time
  55. }
  56. }
  57. #end
  58. #anunt
  59. if {[setting:get $chan anunt]} {
  60. if {![info exists black(anunt:$chan:timer_start)]} {
  61. if {[setting:get $chan anunt-showtime] != ""} {
  62. set time [setting:get $chan anunt-showtime]
  63. } else {
  64. set time $black(anunttime)
  65. }
  66. set scan_time [time_return_minute $time]
  67. set black(anunt:$chan:timer_start) $scan_time
  68. }
  69. }
  70. #end
  71. #idle
  72. if {[setting:get $chan idleop] || [setting:get $chan idlevoice] || [setting:get $chan idlehalfop]} {
  73. if {![info exists black(idle:$chan:timer_start)]} {
  74. if {[setting:get $chan idle-scantime] != ""} {
  75. set time [setting:get $chan idle-scantime]
  76. } else {
  77. set time $black(idleinterval)
  78. }
  79. set scan_time [time_return_minute $time]
  80. set black(idle:$chan:timer_start) $scan_time
  81. }
  82. }
  83. #end
  84. #VoiceOnMsg
  85. if {[setting:get $chan voiceonmsg]} {
  86. if {![info exists black(voiceonmsg:$chan:timer_start)]} {
  87. set black(voiceonmsg:$chan:timer_start) 1
  88. }
  89. }
  90. #end
  91. #Limit
  92. if {[setting:get $chan limit]} {
  93. if {![info exists black(limit:$chan:timer_start)]} {
  94. set black(limit:$chan:timer_start) 1
  95. }
  96. }
  97. #end
  98. #TopWords
  99. if {[setting:get $chan topwords]} {
  100. if {![info exists black(topwords:$chan:timer_start)]} {
  101. set black(topwords:$chan:timer_start) 1
  102. }
  103. }
  104. #end
  105. #quote
  106. if {[setting:get $chan quoteofday]} {
  107. if {![info exists black(quote:$chan:timer_start)]} {
  108. if {[setting:get $chan quote-showtime] != ""} {
  109. set time [setting:get $chan quote-showtime]
  110. } else {
  111. set time $black(quote:msgtime)
  112. }
  113. set scan_time [time_return_minute $time]
  114. set black(quote:$chan:timer_start) $scan_time
  115. }
  116. }
  117. #end
  118. }
  119. #Auto Unsuspend
  120. set status [s:status]
  121. if {$status == "1"} {
  122. if {![info exists black(s:timer_start)]} {
  123. set black(s:timer_start) 1
  124. }
  125. }
  126. #end
  127. #BanMethod Remove
  128. if {![info exists black(banmethod_rem:timer_start)]} {
  129. set black(banmethod_rem:timer_start) [time_return_minute $black(banmethod_memory_time)]
  130. }
  131. #end
  132. #AutoBroadcast
  133. if {[broadcast:check]} {
  134. if {![info exists black(broadcast:timer_start)]} {
  135. set scan_time [time_return_minute $black(bttime)]
  136. set black(broadcast:timer_start) $scan_time
  137. }
  138. }
  139. #end
  140. }
  141. #AutoUpdate Check
  142. if {![info exists black(update_check_start)]} {
  143. timer $black(update_time_check) blacktools:update:timer
  144. set black(update_check_start) 1
  145. }
  146. #run by minute
  147. proc blacktools:timers:runtime {} {
  148. global black botnick
  149. set badchan_channels ""
  150. set clonescan_channels ""
  151. set antispam_channels ""
  152. set anunt_channels ""
  153. set idle_channels ""
  154. set voiceonmsg_channels ""
  155. set limit_channels ""
  156. set quote_channels ""
  157. set voiceme_channels ""
  158. set topwords_channels ""
  159. if {$black(antibotidle_status) == 1} {
  160. putserv "PRIVMSG ${botnick}\:X :none"
  161. }
  162. foreach chan [channels] {
  163. #badchan
  164. if {[info exists black(badchan:$chan:timer_start)]} {
  165. if {[setting:get $chan antibadchan]} {
  166. if {$black(badchan:$chan:timer_start) == "0"} {
  167. if {[setting:get $chan badchan-scantime] != ""} {
  168. set time [setting:get $chan badchan-scantime]
  169. } else {
  170. set time $black(badchan:scantime)
  171. }
  172. set scan_time [time_return_minute $time]
  173. set black(badchan:$chan:timer_start) $scan_time
  174. }
  175. if {![info exists black(badchan:counter:$chan)]} {
  176. set black(badchan:counter:$chan) 0
  177. }
  178. set black(badchan:counter:$chan) [expr $black(badchan:counter:$chan) + 1]
  179. if {$black(badchan:counter:$chan) > $black(badchan:$chan:timer_start)} {
  180. set black(badchan:counter:$chan) 0
  181. } elseif {$black(badchan:$chan:timer_start) < $black(badchan:counter:$chan)} {
  182. set black(badchan:counter:$chan) 0
  183. } elseif {$black(badchan:counter:$chan) == $black(badchan:$chan:timer_start)} {
  184. lappend badchan_channels $chan
  185. set black(badchan:counter:$chan) 0
  186. }
  187. }
  188. }
  189. #end
  190. #clonescan
  191. if {[info exists black(clonescan:$chan:timer_start)]} {
  192. if {[setting:get $chan clonescan]} {
  193. if {$black(clonescan:$chan:timer_start) == "0"} {
  194. if {[setting:get $chan clonescan-scantime] != ""} {
  195. set time [setting:get $chan clonescan-scantime]
  196. } else {
  197. set time $black(clonescantime)
  198. }
  199. set scan_time [time_return_minute $time]
  200. set black(clonescan:$chan:timer_start) $scan_time
  201. }
  202. if {![info exists black(clonescan:counter:$chan)]} {
  203. set black(clonescan:counter:$chan) 0
  204. }
  205. set black(clonescan:counter:$chan) [expr $black(clonescan:counter:$chan) + 1]
  206. if {$black(clonescan:counter:$chan) > $black(clonescan:$chan:timer_start)} {
  207. set black(clonescan:counter:$chan) 0
  208. } elseif {$black(clonescan:$chan:timer_start) < $black(clonescan:counter:$chan)} {
  209. set black(clonescan:counter:$chan) 0
  210. } elseif {$black(clonescan:counter:$chan) == $black(clonescan:$chan:timer_start)} {
  211. lappend clonescan_channels $chan
  212. set black(clonescan:counter:$chan) 0
  213. }
  214. }
  215. }
  216. #end
  217. #antispam
  218. if {[info exists black(antispam:$chan:timer_start)]} {
  219. if {[setting:get $chan antispam]} {
  220. if {$black(antispam:$chan:timer_start) == "0"} {
  221. if {[setting:get $chan antispam-scantime] != ""} {
  222. set time [setting:get $chan antispam-scantime]
  223. } else {
  224. set time $black(spamcycle)
  225. }
  226. set scan_time [time_return_minute $time]
  227. set black(antispam:$chan:timer_start) $scan_time
  228. }
  229. if {![info exists black(antispam:counter:$chan)]} {
  230. set black(antispam:counter:$chan) 0
  231. }
  232. set black(antispam:counter:$chan) [expr $black(antispam:counter:$chan) + 1]
  233. if {$black(antispam:counter:$chan) > $black(antispam:$chan:timer_start)} {
  234. set black(antispam:counter:$chan) 0
  235. } elseif {$black(antispam:$chan:timer_start) < $black(antispam:counter:$chan)} {
  236. set black(antispam:counter:$chan) 0
  237. } elseif {$black(antispam:counter:$chan) == $black(antispam:$chan:timer_start)} {
  238. lappend antispam_channels $chan
  239. set black(antispam:counter:$chan) 0
  240. }
  241. }
  242. }
  243. #end
  244. #anunt
  245. if {[info exists black(anunt:$chan:timer_start)]} {
  246. if {[setting:get $chan anunt]} {
  247. if {$black(anunt:$chan:timer_start) == "0"} {
  248. if {[setting:get $chan anunt-showtime] != ""} {
  249. set time [setting:get $chan anunt-showtime]
  250. } else {
  251. set time $black(anunttime)
  252. }
  253. set scan_time [time_return_minute $time]
  254. set black(anunt:$chan:timer_start) $scan_time
  255. }
  256. if {![info exists black(anunt:counter:$chan)]} {
  257. set black(anunt:counter:$chan) 0
  258. }
  259. set black(anunt:counter:$chan) [expr $black(anunt:counter:$chan) + 1]
  260. if {$black(anunt:counter:$chan) > $black(anunt:$chan:timer_start)} {
  261. set black(anunt:counter:$chan) 0
  262. } elseif {$black(anunt:$chan:timer_start) < $black(anunt:counter:$chan)} {
  263. set black(anunt:counter:$chan) 0
  264. } elseif {$black(anunt:counter:$chan) == $black(anunt:$chan:timer_start)} {
  265. lappend anunt_channels $chan
  266. set black(anunt:counter:$chan) 0
  267. }
  268. }
  269. }
  270. #end
  271. #Quote
  272. if {[info exists black(quote:$chan:timer_start)]} {
  273. if {[setting:get $chan quoteofday]} {
  274. if {$black(quote:$chan:timer_start) == "0"} {
  275. if {[setting:get $chan quote-showtime] != ""} {
  276. set time [setting:get $chan quote-showtime]
  277. } else {
  278. set time $black(quote:msgtime)
  279. }
  280. set scan_time [time_return_minute $time]
  281. set black(quote:$chan:timer_start) $scan_time
  282. }
  283. if {![info exists black(quote:counter:$chan)]} {
  284. set black(quote:counter:$chan) 0
  285. }
  286. set black(quote:counter:$chan) [expr $black(quote:counter:$chan) + 1]
  287. if {$black(quote:counter:$chan) > $black(quote:$chan:timer_start)} {
  288. set black(quote:counter:$chan) 0
  289. } elseif {$black(quote:$chan:timer_start) < $black(quote:counter:$chan)} {
  290. set black(quote:counter:$chan) 0
  291. } elseif {$black(quote:counter:$chan) == $black(quote:$chan:timer_start)} {
  292. lappend quote_channels $chan
  293. set black(quote:counter:$chan) 0
  294. }
  295. }
  296. }
  297. #end
  298. #voiceme
  299. if {[info exists black(voiceme:$chan:timer_start)]} {
  300. if {$black(voiceme:$chan:timer_start) == "0"} {
  301. if {[setting:get $chan voiceme-showtime] != ""} {
  302. set time [setting:get $chan voiceme-showtime]
  303. } else {
  304. set time $black(voiceme:msgtime)
  305. }
  306. set scan_time [time_return_minute $time]
  307. set black(voiceme:$chan:timer_start) $scan_time
  308. }
  309. if {![info exists black(voiceme:counter:$chan)]} {
  310. set black(voiceme:counter:$chan) 0
  311. }
  312. set black(voiceme:counter:$chan) [expr $black(voiceme:counter:$chan) + 1]
  313. if {$black(voiceme:counter:$chan) > $black(voiceme:$chan:timer_start)} {
  314. set black(voiceme:counter:$chan) 0
  315. } elseif {$black(voiceme:$chan:timer_start) < $black(voiceme:counter:$chan)} {
  316. set black(voiceme:counter:$chan) 0
  317. } elseif {$black(voiceme:counter:$chan) == $black(voiceme:$chan:timer_start)} {
  318. lappend voiceme_channels $chan
  319. set black(voiceme:counter:$chan) 0
  320. }
  321. }
  322. #
  323. #VoiceOnMsg
  324. if {[info exists black(voiceonmsg:$chan:timer_start)]} {
  325. if {[setting:get $chan voiceonmsg]} {
  326. lappend voiceonmsg_channels $chan
  327. }
  328. }
  329. #end
  330. #Limit
  331. if {[info exists black(limit:$chan:timer_start)]} {
  332. if {[setting:get $chan limit]} {
  333. lappend limit_channels $chan
  334. }
  335. }
  336. #end
  337. #TopWOrds
  338. if {[info exists black(topwords:$chan:timer_start)]} {
  339. if {[setting:get $chan topwords]} {
  340. lappend topwords_channels $chan
  341. }
  342. }
  343. #end
  344. #idle
  345. if {[info exists black(idle:$chan:timer_start)]} {
  346. set options {idleop idlevoice idlehalfop}
  347. set idle_activ 0
  348. foreach option $options {
  349. if {[setting:get $chan $option]} {
  350. set idle_activ 1
  351. }
  352. }
  353. if {$idle_activ == "1"} {
  354. if {$black(idle:$chan:timer_start) == "0"} {
  355. if {[setting:get $chan idle-scantime] != ""} {
  356. set time [setting:get $chan idle-scantime]
  357. } else {
  358. set time $black(idleinterval)
  359. }
  360. set scan_time [time_return_minute $time]
  361. set black(idle:$chan:timer_start) $scan_time
  362. }
  363. if {![info exists black(idle:counter:$chan)]} {
  364. set black(idle:counter:$chan) 0
  365. }
  366. set black(idle:counter:$chan) [expr $black(idle:counter:$chan) + 1]
  367. if {$black(idle:counter:$chan) > $black(idle:$chan:timer_start)} {
  368. set black(idle:counter:$chan) 0
  369. } elseif {$black(idle:$chan:timer_start) < $black(idle:counter:$chan)} {
  370. set black(idle:counter:$chan) 0
  371. } elseif {$black(idle:counter:$chan) == $black(idle:$chan:timer_start)} {
  372. lappend idle_channels $chan
  373. set black(idle:counter:$chan) 0
  374. }
  375. }
  376. }
  377. #end
  378. }
  379. #banmethod remove
  380. if {[info exists black(banmethod_rem:timer_start)]} {
  381. if {![info exists black(banmethod_rem:counter)]} {
  382. set black(banmethod_rem:counter) 0
  383. }
  384. set black(banmethod_rem:counter) [expr $black(banmethod_rem:counter) + 1]
  385. if {$black(banmethod_rem:counter) > $black(banmethod_rem:timer_start)} {
  386. set black(banmethod_rem:counter) 0
  387. } elseif {$black(banmethod_rem:timer_start) < $black(banmethod_rem:counter)} {
  388. set black(broadcast:counter) 0
  389. } elseif {$black(banmethod_rem:counter) == $black(banmethod_rem:timer_start)} {
  390. set black(banmethod_rem:counter) 0
  391. banmethod_memory:autoremove
  392. }
  393. }
  394. #end
  395. #Auto Unsuspend
  396. if {[info exists black(s:timer_start)]} {
  397. s:process:timer
  398. }
  399. #end
  400. #AutoBroadcast
  401. if {[info exists black(broadcast:timer_start)]} {
  402. if {![info exists black(broadcast:counter)]} {
  403. set black(broadcast:counter) 0
  404. }
  405. set black(broadcast:counter) [expr $black(broadcast:counter) + 1]
  406. if {$black(broadcast:counter) > $black(broadcast:timer_start)} {
  407. set black(broadcast:counter) 0
  408. } elseif {$black(broadcast:timer_start) < $black(broadcast:counter)} {
  409. set black(broadcast:counter) 0
  410. } elseif {$black(broadcast:counter) == $black(broadcast:timer_start)} {
  411. set black(broadcast:counter) 0
  412. broadcastpublic:show
  413. }
  414. }
  415. #Away Check
  416. if {![info exists black(away:timer_start)]} {
  417. set black(away:timer_start) 720
  418. }
  419. if {![info exists black(counter:away)]} {
  420. set black(counter:away) 0
  421. }
  422. set black(counter:away) [expr $black(counter:away) + 1]
  423. if {$black(counter:away) > $black(away:timer_start)} {
  424. set black(counter:away) 0
  425. } elseif {$black(away:timer_start) < $black(counter:away)} {
  426. set black(counter:away) 0
  427. } elseif {$black(counter:away) == $black(away:timer_start)} {
  428. set black(counter:away) 0
  429. away:timer
  430. }
  431. #end
  432. if {$badchan_channels != ""} {
  433. badchan:scantimer [join $badchan_channels]
  434. }
  435. if {$clonescan_channels != ""} {
  436. clonescan:timer [join $clonescan_channels]
  437. }
  438. if {$antispam_channels != ""} {
  439. antispam:protect:cycle [join $antispam_channels]
  440. }
  441. if {$anunt_channels != ""} {
  442. anuntpublic:show [join $anunt_channels]
  443. }
  444. if {$idle_channels != ""} {
  445. antidle:module [join $idle_channels]
  446. }
  447. if {$voiceonmsg_channels != ""} {
  448. voiceonmsg:timer [join $voiceonmsg_channels]
  449. }
  450. if {$limit_channels != ""} {
  451. limit:timer [join $limit_channels]
  452. }
  453. if {$quote_channels != ""} {
  454. quote:announce [join $quote_channels]
  455. }
  456. if {$voiceme_channels != ""} {
  457. voiceme:showmsg_timer [join $voiceme_channels]
  458. }
  459. if {$topwords_channels != ""} {
  460. topwords:save:channels [join $topwords_channels]
  461. }
  462. timer 1 blacktools:timers:runtime
  463. }
  464. #################
  465. ###########################################################################
  466. ## END ##
  467. ###########################################################################