BT.Timers.tcl 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  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 {$black(update_on) != 0} {
  143. if {![info exists black(update_check_start)]} {
  144. timer $black(update_time_check) blacktools:update:timer
  145. set black(update_check_start) 1
  146. }
  147. }
  148. #run by minute
  149. proc blacktools:timers:runtime {} {
  150. global black botnick
  151. set badchan_channels ""
  152. set clonescan_channels ""
  153. set antispam_channels ""
  154. set anunt_channels ""
  155. set idle_channels ""
  156. set voiceonmsg_channels ""
  157. set limit_channels ""
  158. set quote_channels ""
  159. set voiceme_channels ""
  160. set topwords_channels ""
  161. if {$black(antibotidle_status) == 1} {
  162. putserv "PRIVMSG ${botnick}\:X :none"
  163. }
  164. foreach chan [channels] {
  165. #badchan
  166. if {[info exists black(badchan:$chan:timer_start)]} {
  167. if {[setting:get $chan antibadchan]} {
  168. if {$black(badchan:$chan:timer_start) == "0"} {
  169. if {[setting:get $chan badchan-scantime] != ""} {
  170. set time [setting:get $chan badchan-scantime]
  171. } else {
  172. set time $black(badchan:scantime)
  173. }
  174. set scan_time [time_return_minute $time]
  175. set black(badchan:$chan:timer_start) $scan_time
  176. }
  177. if {![info exists black(badchan:counter:$chan)]} {
  178. set black(badchan:counter:$chan) 0
  179. }
  180. set black(badchan:counter:$chan) [expr $black(badchan:counter:$chan) + 1]
  181. if {$black(badchan:counter:$chan) > $black(badchan:$chan:timer_start)} {
  182. set black(badchan:counter:$chan) 0
  183. } elseif {$black(badchan:$chan:timer_start) < $black(badchan:counter:$chan)} {
  184. set black(badchan:counter:$chan) 0
  185. } elseif {$black(badchan:counter:$chan) == $black(badchan:$chan:timer_start)} {
  186. lappend badchan_channels $chan
  187. set black(badchan:counter:$chan) 0
  188. }
  189. }
  190. }
  191. #end
  192. #clonescan
  193. if {[info exists black(clonescan:$chan:timer_start)]} {
  194. if {[setting:get $chan clonescan]} {
  195. if {$black(clonescan:$chan:timer_start) == "0"} {
  196. if {[setting:get $chan clonescan-scantime] != ""} {
  197. set time [setting:get $chan clonescan-scantime]
  198. } else {
  199. set time $black(clonescantime)
  200. }
  201. set scan_time [time_return_minute $time]
  202. set black(clonescan:$chan:timer_start) $scan_time
  203. }
  204. if {![info exists black(clonescan:counter:$chan)]} {
  205. set black(clonescan:counter:$chan) 0
  206. }
  207. set black(clonescan:counter:$chan) [expr $black(clonescan:counter:$chan) + 1]
  208. if {$black(clonescan:counter:$chan) > $black(clonescan:$chan:timer_start)} {
  209. set black(clonescan:counter:$chan) 0
  210. } elseif {$black(clonescan:$chan:timer_start) < $black(clonescan:counter:$chan)} {
  211. set black(clonescan:counter:$chan) 0
  212. } elseif {$black(clonescan:counter:$chan) == $black(clonescan:$chan:timer_start)} {
  213. lappend clonescan_channels $chan
  214. set black(clonescan:counter:$chan) 0
  215. }
  216. }
  217. }
  218. #end
  219. #antispam
  220. if {[info exists black(antispam:$chan:timer_start)]} {
  221. if {[setting:get $chan antispam]} {
  222. if {$black(antispam:$chan:timer_start) == "0"} {
  223. if {[setting:get $chan antispam-scantime] != ""} {
  224. set time [setting:get $chan antispam-scantime]
  225. } else {
  226. set time $black(spamcycle)
  227. }
  228. set scan_time [time_return_minute $time]
  229. set black(antispam:$chan:timer_start) $scan_time
  230. }
  231. if {![info exists black(antispam:counter:$chan)]} {
  232. set black(antispam:counter:$chan) 0
  233. }
  234. set black(antispam:counter:$chan) [expr $black(antispam:counter:$chan) + 1]
  235. if {$black(antispam:counter:$chan) > $black(antispam:$chan:timer_start)} {
  236. set black(antispam:counter:$chan) 0
  237. } elseif {$black(antispam:$chan:timer_start) < $black(antispam:counter:$chan)} {
  238. set black(antispam:counter:$chan) 0
  239. } elseif {$black(antispam:counter:$chan) == $black(antispam:$chan:timer_start)} {
  240. lappend antispam_channels $chan
  241. set black(antispam:counter:$chan) 0
  242. }
  243. }
  244. }
  245. #end
  246. #anunt
  247. if {[info exists black(anunt:$chan:timer_start)]} {
  248. if {[setting:get $chan anunt]} {
  249. if {$black(anunt:$chan:timer_start) == "0"} {
  250. if {[setting:get $chan anunt-showtime] != ""} {
  251. set time [setting:get $chan anunt-showtime]
  252. } else {
  253. set time $black(anunttime)
  254. }
  255. set scan_time [time_return_minute $time]
  256. set black(anunt:$chan:timer_start) $scan_time
  257. }
  258. if {![info exists black(anunt:counter:$chan)]} {
  259. set black(anunt:counter:$chan) 0
  260. }
  261. set black(anunt:counter:$chan) [expr $black(anunt:counter:$chan) + 1]
  262. if {$black(anunt:counter:$chan) > $black(anunt:$chan:timer_start)} {
  263. set black(anunt:counter:$chan) 0
  264. } elseif {$black(anunt:$chan:timer_start) < $black(anunt:counter:$chan)} {
  265. set black(anunt:counter:$chan) 0
  266. } elseif {$black(anunt:counter:$chan) == $black(anunt:$chan:timer_start)} {
  267. lappend anunt_channels $chan
  268. set black(anunt:counter:$chan) 0
  269. }
  270. }
  271. }
  272. #end
  273. #Quote
  274. if {[info exists black(quote:$chan:timer_start)]} {
  275. if {[setting:get $chan quoteofday]} {
  276. if {$black(quote:$chan:timer_start) == "0"} {
  277. if {[setting:get $chan quote-showtime] != ""} {
  278. set time [setting:get $chan quote-showtime]
  279. } else {
  280. set time $black(quote:msgtime)
  281. }
  282. set scan_time [time_return_minute $time]
  283. set black(quote:$chan:timer_start) $scan_time
  284. }
  285. if {![info exists black(quote:counter:$chan)]} {
  286. set black(quote:counter:$chan) 0
  287. }
  288. set black(quote:counter:$chan) [expr $black(quote:counter:$chan) + 1]
  289. if {$black(quote:counter:$chan) > $black(quote:$chan:timer_start)} {
  290. set black(quote:counter:$chan) 0
  291. } elseif {$black(quote:$chan:timer_start) < $black(quote:counter:$chan)} {
  292. set black(quote:counter:$chan) 0
  293. } elseif {$black(quote:counter:$chan) == $black(quote:$chan:timer_start)} {
  294. lappend quote_channels $chan
  295. set black(quote:counter:$chan) 0
  296. }
  297. }
  298. }
  299. #end
  300. #voiceme
  301. if {[info exists black(voiceme:$chan:timer_start)]} {
  302. if {$black(voiceme:$chan:timer_start) == "0"} {
  303. if {[setting:get $chan voiceme-showtime] != ""} {
  304. set time [setting:get $chan voiceme-showtime]
  305. } else {
  306. set time $black(voiceme:msgtime)
  307. }
  308. set scan_time [time_return_minute $time]
  309. set black(voiceme:$chan:timer_start) $scan_time
  310. }
  311. if {![info exists black(voiceme:counter:$chan)]} {
  312. set black(voiceme:counter:$chan) 0
  313. }
  314. set black(voiceme:counter:$chan) [expr $black(voiceme:counter:$chan) + 1]
  315. if {$black(voiceme:counter:$chan) > $black(voiceme:$chan:timer_start)} {
  316. set black(voiceme:counter:$chan) 0
  317. } elseif {$black(voiceme:$chan:timer_start) < $black(voiceme:counter:$chan)} {
  318. set black(voiceme:counter:$chan) 0
  319. } elseif {$black(voiceme:counter:$chan) == $black(voiceme:$chan:timer_start)} {
  320. lappend voiceme_channels $chan
  321. set black(voiceme:counter:$chan) 0
  322. }
  323. }
  324. #
  325. #VoiceOnMsg
  326. if {[info exists black(voiceonmsg:$chan:timer_start)]} {
  327. if {[setting:get $chan voiceonmsg]} {
  328. lappend voiceonmsg_channels $chan
  329. }
  330. }
  331. #end
  332. #Limit
  333. if {[info exists black(limit:$chan:timer_start)]} {
  334. if {[setting:get $chan limit]} {
  335. lappend limit_channels $chan
  336. }
  337. }
  338. #end
  339. #TopWOrds
  340. if {[info exists black(topwords:$chan:timer_start)]} {
  341. if {[setting:get $chan topwords]} {
  342. lappend topwords_channels $chan
  343. }
  344. }
  345. #end
  346. #idle
  347. if {[info exists black(idle:$chan:timer_start)]} {
  348. set options {idleop idlevoice idlehalfop}
  349. set idle_activ 0
  350. foreach option $options {
  351. if {[setting:get $chan $option]} {
  352. set idle_activ 1
  353. }
  354. }
  355. if {$idle_activ == "1"} {
  356. if {$black(idle:$chan:timer_start) == "0"} {
  357. if {[setting:get $chan idle-scantime] != ""} {
  358. set time [setting:get $chan idle-scantime]
  359. } else {
  360. set time $black(idleinterval)
  361. }
  362. set scan_time [time_return_minute $time]
  363. set black(idle:$chan:timer_start) $scan_time
  364. }
  365. if {![info exists black(idle:counter:$chan)]} {
  366. set black(idle:counter:$chan) 0
  367. }
  368. set black(idle:counter:$chan) [expr $black(idle:counter:$chan) + 1]
  369. if {$black(idle:counter:$chan) > $black(idle:$chan:timer_start)} {
  370. set black(idle:counter:$chan) 0
  371. } elseif {$black(idle:$chan:timer_start) < $black(idle:counter:$chan)} {
  372. set black(idle:counter:$chan) 0
  373. } elseif {$black(idle:counter:$chan) == $black(idle:$chan:timer_start)} {
  374. lappend idle_channels $chan
  375. set black(idle:counter:$chan) 0
  376. }
  377. }
  378. }
  379. #end
  380. }
  381. #banmethod remove
  382. if {[info exists black(banmethod_rem:timer_start)]} {
  383. if {![info exists black(banmethod_rem:counter)]} {
  384. set black(banmethod_rem:counter) 0
  385. }
  386. set black(banmethod_rem:counter) [expr $black(banmethod_rem:counter) + 1]
  387. if {$black(banmethod_rem:counter) > $black(banmethod_rem:timer_start)} {
  388. set black(banmethod_rem:counter) 0
  389. } elseif {$black(banmethod_rem:timer_start) < $black(banmethod_rem:counter)} {
  390. set black(broadcast:counter) 0
  391. } elseif {$black(banmethod_rem:counter) == $black(banmethod_rem:timer_start)} {
  392. set black(banmethod_rem:counter) 0
  393. banmethod_memory:autoremove
  394. }
  395. }
  396. #end
  397. #Auto Unsuspend
  398. if {[info exists black(s:timer_start)]} {
  399. s:process:timer
  400. }
  401. #end
  402. #AutoBroadcast
  403. if {[info exists black(broadcast:timer_start)]} {
  404. if {![info exists black(broadcast:counter)]} {
  405. set black(broadcast:counter) 0
  406. }
  407. set black(broadcast:counter) [expr $black(broadcast:counter) + 1]
  408. if {$black(broadcast:counter) > $black(broadcast:timer_start)} {
  409. set black(broadcast:counter) 0
  410. } elseif {$black(broadcast:timer_start) < $black(broadcast:counter)} {
  411. set black(broadcast:counter) 0
  412. } elseif {$black(broadcast:counter) == $black(broadcast:timer_start)} {
  413. set black(broadcast:counter) 0
  414. broadcastpublic:show
  415. }
  416. }
  417. #Away Check
  418. if {![info exists black(away:timer_start)]} {
  419. set black(away:timer_start) 720
  420. }
  421. if {![info exists black(counter:away)]} {
  422. set black(counter:away) 0
  423. }
  424. set black(counter:away) [expr $black(counter:away) + 1]
  425. if {$black(counter:away) > $black(away:timer_start)} {
  426. set black(counter:away) 0
  427. } elseif {$black(away:timer_start) < $black(counter:away)} {
  428. set black(counter:away) 0
  429. } elseif {$black(counter:away) == $black(away:timer_start)} {
  430. set black(counter:away) 0
  431. away:timer
  432. }
  433. #end
  434. if {$badchan_channels != ""} {
  435. badchan:scantimer [join $badchan_channels]
  436. }
  437. if {$clonescan_channels != ""} {
  438. clonescan:timer [join $clonescan_channels]
  439. }
  440. if {$antispam_channels != ""} {
  441. antispam:protect:cycle [join $antispam_channels]
  442. }
  443. if {$anunt_channels != ""} {
  444. anuntpublic:show [join $anunt_channels]
  445. }
  446. if {$idle_channels != ""} {
  447. antidle:module [join $idle_channels]
  448. }
  449. if {$voiceonmsg_channels != ""} {
  450. voiceonmsg:timer [join $voiceonmsg_channels]
  451. }
  452. if {$limit_channels != ""} {
  453. limit:timer [join $limit_channels]
  454. }
  455. if {$quote_channels != ""} {
  456. quote:announce [join $quote_channels]
  457. }
  458. if {$voiceme_channels != ""} {
  459. voiceme:showmsg_timer [join $voiceme_channels]
  460. }
  461. if {$topwords_channels != ""} {
  462. topwords:save:channels [join $topwords_channels]
  463. }
  464. timer 1 blacktools:timers:runtime
  465. }
  466. #################
  467. ###########################################################################
  468. ## END ##
  469. ###########################################################################