BT.Timers.tcl 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  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. ## BlackTools - The Ultimate Channel Control Script ##
  20. ## One TCL. One smart Eggdrop ##
  21. #########################################################################
  22. ########################### LOCAL TIMERS ##############################
  23. #########################################################################
  24. ## ##
  25. ## BlackTools : http://blacktools.tclscripts.net ##
  26. ## Bugs report : http://www.tclscripts.net/ ##
  27. ## GitHub page : https://github.com/tclscripts/BlackToolS-TCL ##
  28. ## Online Help : irc://irc.undernet.org/tcl-help ##
  29. ## #TCL-HELP / UnderNet ##
  30. ## You can ask in english or romanian ##
  31. ## ##
  32. #########################################################################
  33. proc blacktools:timers:load {chan} {
  34. global black
  35. if {[validchan $chan]} {
  36. #badchan
  37. if {[setting:get $chan antibadchan]} {
  38. if {![info exists black(badchan:$chan:timer_start)]} {
  39. if {[setting:get $chan badchan-scantime] != ""} {
  40. set time [setting:get $chan badchan-scantime]
  41. } else {
  42. set time $black(badchan:scantime)
  43. }
  44. set scan_time [time_return_minute $time]
  45. set black(badchan:$chan:timer_start) $scan_time
  46. }
  47. }
  48. #end
  49. #clonescan
  50. if {[setting:get $chan clonescan]} {
  51. if {![info exists black(clonescan:$chan:timer_start)]} {
  52. if {[setting:get $chan clonescan-scantime] != ""} {
  53. set time [setting:get $chan clonescan-scantime]
  54. } else {
  55. set time $black(clonescantime)
  56. }
  57. set scan_time [time_return_minute $time]
  58. set black(clonescan:$chan:timer_start) $scan_time
  59. }
  60. }
  61. #end
  62. #antispam
  63. if {[setting:get $chan antispam]} {
  64. if {![info exists black(antispam:$chan:timer_start)]} {
  65. if {[setting:get $chan antispam-scantime] != ""} {
  66. set time [setting:get $chan antispam-scantime]
  67. } else {
  68. set time $black(spamcycle)
  69. }
  70. set scan_time [time_return_minute $time]
  71. set black(antispam:$chan:timer_start) $scan_time
  72. }
  73. }
  74. #end
  75. #anunt
  76. if {[setting:get $chan anunt]} {
  77. if {![info exists black(anunt:$chan:timer_start)]} {
  78. if {[setting:get $chan anunt-showtime] != ""} {
  79. set time [setting:get $chan anunt-showtime]
  80. } else {
  81. set time $black(anunttime)
  82. }
  83. set scan_time [time_return_minute $time]
  84. set black(anunt:$chan:timer_start) $scan_time
  85. }
  86. }
  87. #end
  88. #idle
  89. if {[setting:get $chan idleop] || [setting:get $chan idlevoice] || [setting:get $chan idlehalfop] || [setting:get $chan idleban]} {
  90. if {![info exists black(idle:$chan:timer_start)]} {
  91. if {[setting:get $chan idle-scantime] != ""} {
  92. set time [setting:get $chan idle-scantime]
  93. } else {
  94. set time $black(idleinterval)
  95. }
  96. set scan_time [time_return_minute $time]
  97. set black(idle:$chan:timer_start) $scan_time
  98. }
  99. }
  100. #end
  101. #VoiceOnMsg
  102. if {[setting:get $chan voiceonmsg]} {
  103. if {![info exists black(voiceonmsg:$chan:timer_start)]} {
  104. set black(voiceonmsg:$chan:timer_start) 1
  105. }
  106. }
  107. #end
  108. #Limit
  109. if {[setting:get $chan limit]} {
  110. if {![info exists black(limit:$chan:timer_start)]} {
  111. set black(limit:$chan:timer_start) 1
  112. }
  113. }
  114. #end
  115. #TopWords
  116. if {[setting:get $chan topwords]} {
  117. if {![info exists black(topwords:$chan:timer_start)]} {
  118. set black(topwords:$chan:timer_start) 1
  119. }
  120. }
  121. #end
  122. #quote
  123. if {[setting:get $chan quoteofday]} {
  124. if {![info exists black(quote:$chan:timer_start)]} {
  125. if {[setting:get $chan quote-showtime] != ""} {
  126. set time [setting:get $chan quote-showtime]
  127. } else {
  128. set time $black(quote:msgtime)
  129. }
  130. set scan_time [time_return_minute $time]
  131. set black(quote:$chan:timer_start) $scan_time
  132. }
  133. }
  134. #end
  135. }
  136. #Auto Unsuspend
  137. set status [s:status]
  138. if {$status == "1"} {
  139. if {![info exists black(s:timer_start)]} {
  140. set black(s:timer_start) 1
  141. }
  142. }
  143. #end
  144. #BanMethod Remove
  145. if {![info exists black(banmethod_rem:timer_start)]} {
  146. set black(banmethod_rem:timer_start) [time_return_minute $black(banmethod_memory_time)]
  147. }
  148. #end
  149. #AutoBroadcast
  150. if {[broadcast:check]} {
  151. if {![info exists black(broadcast:timer_start)]} {
  152. set scan_time [time_return_minute $black(bttime)]
  153. set black(broadcast:timer_start) $scan_time
  154. }
  155. }
  156. #end
  157. }
  158. #AutoUpdate Check
  159. if {$black(update_on) != 0} {
  160. if {![info exists black(update_check_start)]} {
  161. timer $black(update_time_check) blacktools:update:timer
  162. set black(update_check_start) 1
  163. }
  164. }
  165. #run by minute
  166. proc blacktools:timers:runtime {} {
  167. global black botnick
  168. set badchan_channels ""
  169. set clonescan_channels ""
  170. set antispam_channels ""
  171. set anunt_channels ""
  172. set idle_channels ""
  173. set voiceonmsg_channels ""
  174. set limit_channels ""
  175. set quote_channels ""
  176. set voiceme_channels ""
  177. set topwords_channels ""
  178. if {$black(antibotidle_status) == 1} {
  179. putserv "PRIVMSG ${botnick}\:X :none"
  180. }
  181. foreach chan [channels] {
  182. #badchan
  183. if {[info exists black(badchan:$chan:timer_start)]} {
  184. if {[setting:get $chan antibadchan]} {
  185. if {$black(badchan:$chan:timer_start) == "0"} {
  186. if {[setting:get $chan badchan-scantime] != ""} {
  187. set time [setting:get $chan badchan-scantime]
  188. } else {
  189. set time $black(badchan:scantime)
  190. }
  191. set scan_time [time_return_minute $time]
  192. set black(badchan:$chan:timer_start) $scan_time
  193. }
  194. if {![info exists black(badchan:counter:$chan)]} {
  195. set black(badchan:counter:$chan) 0
  196. }
  197. set black(badchan:counter:$chan) [expr $black(badchan:counter:$chan) + 1]
  198. if {$black(badchan:counter:$chan) > $black(badchan:$chan:timer_start)} {
  199. set black(badchan:counter:$chan) 0
  200. } elseif {$black(badchan:$chan:timer_start) < $black(badchan:counter:$chan)} {
  201. set black(badchan:counter:$chan) 0
  202. } elseif {$black(badchan:counter:$chan) == $black(badchan:$chan:timer_start)} {
  203. lappend badchan_channels $chan
  204. set black(badchan:counter:$chan) 0
  205. }
  206. }
  207. }
  208. #end
  209. #clonescan
  210. if {[info exists black(clonescan:$chan:timer_start)]} {
  211. if {[setting:get $chan clonescan]} {
  212. if {$black(clonescan:$chan:timer_start) == "0"} {
  213. if {[setting:get $chan clonescan-scantime] != ""} {
  214. set time [setting:get $chan clonescan-scantime]
  215. } else {
  216. set time $black(clonescantime)
  217. }
  218. set scan_time [time_return_minute $time]
  219. set black(clonescan:$chan:timer_start) $scan_time
  220. }
  221. if {![info exists black(clonescan:counter:$chan)]} {
  222. set black(clonescan:counter:$chan) 0
  223. }
  224. set black(clonescan:counter:$chan) [expr $black(clonescan:counter:$chan) + 1]
  225. if {$black(clonescan:counter:$chan) > $black(clonescan:$chan:timer_start)} {
  226. set black(clonescan:counter:$chan) 0
  227. } elseif {$black(clonescan:$chan:timer_start) < $black(clonescan:counter:$chan)} {
  228. set black(clonescan:counter:$chan) 0
  229. } elseif {$black(clonescan:counter:$chan) == $black(clonescan:$chan:timer_start)} {
  230. lappend clonescan_channels $chan
  231. set black(clonescan:counter:$chan) 0
  232. }
  233. }
  234. }
  235. #end
  236. #antispam
  237. if {[info exists black(antispam:$chan:timer_start)]} {
  238. if {[setting:get $chan antispam]} {
  239. if {$black(antispam:$chan:timer_start) == "0"} {
  240. if {[setting:get $chan antispam-scantime] != ""} {
  241. set time [setting:get $chan antispam-scantime]
  242. } else {
  243. set time $black(spamcycle)
  244. }
  245. set scan_time [time_return_minute $time]
  246. set black(antispam:$chan:timer_start) $scan_time
  247. }
  248. if {![info exists black(antispam:counter:$chan)]} {
  249. set black(antispam:counter:$chan) 0
  250. }
  251. set black(antispam:counter:$chan) [expr $black(antispam:counter:$chan) + 1]
  252. if {$black(antispam:counter:$chan) > $black(antispam:$chan:timer_start)} {
  253. set black(antispam:counter:$chan) 0
  254. } elseif {$black(antispam:$chan:timer_start) < $black(antispam:counter:$chan)} {
  255. set black(antispam:counter:$chan) 0
  256. } elseif {$black(antispam:counter:$chan) == $black(antispam:$chan:timer_start)} {
  257. lappend antispam_channels $chan
  258. set black(antispam:counter:$chan) 0
  259. }
  260. }
  261. }
  262. #end
  263. #anunt
  264. if {[info exists black(anunt:$chan:timer_start)]} {
  265. if {[setting:get $chan anunt]} {
  266. if {$black(anunt:$chan:timer_start) == "0"} {
  267. if {[setting:get $chan anunt-showtime] != ""} {
  268. set time [setting:get $chan anunt-showtime]
  269. } else {
  270. set time $black(anunttime)
  271. }
  272. set scan_time [time_return_minute $time]
  273. set black(anunt:$chan:timer_start) $scan_time
  274. }
  275. if {![info exists black(anunt:counter:$chan)]} {
  276. set black(anunt:counter:$chan) 0
  277. }
  278. set black(anunt:counter:$chan) [expr $black(anunt:counter:$chan) + 1]
  279. if {$black(anunt:counter:$chan) > $black(anunt:$chan:timer_start)} {
  280. set black(anunt:counter:$chan) 0
  281. } elseif {$black(anunt:$chan:timer_start) < $black(anunt:counter:$chan)} {
  282. set black(anunt:counter:$chan) 0
  283. } elseif {$black(anunt:counter:$chan) == $black(anunt:$chan:timer_start)} {
  284. lappend anunt_channels $chan
  285. set black(anunt:counter:$chan) 0
  286. }
  287. }
  288. }
  289. #end
  290. #Quote
  291. if {[info exists black(quote:$chan:timer_start)]} {
  292. if {[setting:get $chan quoteofday]} {
  293. if {$black(quote:$chan:timer_start) == "0"} {
  294. if {[setting:get $chan quote-showtime] != ""} {
  295. set time [setting:get $chan quote-showtime]
  296. } else {
  297. set time $black(quote:msgtime)
  298. }
  299. set scan_time [time_return_minute $time]
  300. set black(quote:$chan:timer_start) $scan_time
  301. }
  302. if {![info exists black(quote:counter:$chan)]} {
  303. set black(quote:counter:$chan) 0
  304. }
  305. set black(quote:counter:$chan) [expr $black(quote:counter:$chan) + 1]
  306. if {$black(quote:counter:$chan) > $black(quote:$chan:timer_start)} {
  307. set black(quote:counter:$chan) 0
  308. } elseif {$black(quote:$chan:timer_start) < $black(quote:counter:$chan)} {
  309. set black(quote:counter:$chan) 0
  310. } elseif {$black(quote:counter:$chan) == $black(quote:$chan:timer_start)} {
  311. lappend quote_channels $chan
  312. set black(quote:counter:$chan) 0
  313. }
  314. }
  315. }
  316. #end
  317. #voiceme
  318. if {[info exists black(voiceme:$chan:timer_start)]} {
  319. if {$black(voiceme:$chan:timer_start) == "0"} {
  320. if {[setting:get $chan voiceme-showtime] != ""} {
  321. set time [setting:get $chan voiceme-showtime]
  322. } else {
  323. set time $black(voiceme:msgtime)
  324. }
  325. set scan_time [time_return_minute $time]
  326. set black(voiceme:$chan:timer_start) $scan_time
  327. }
  328. if {![info exists black(voiceme:counter:$chan)]} {
  329. set black(voiceme:counter:$chan) 0
  330. }
  331. set black(voiceme:counter:$chan) [expr $black(voiceme:counter:$chan) + 1]
  332. if {$black(voiceme:counter:$chan) > $black(voiceme:$chan:timer_start)} {
  333. set black(voiceme:counter:$chan) 0
  334. } elseif {$black(voiceme:$chan:timer_start) < $black(voiceme:counter:$chan)} {
  335. set black(voiceme:counter:$chan) 0
  336. } elseif {$black(voiceme:counter:$chan) == $black(voiceme:$chan:timer_start)} {
  337. lappend voiceme_channels $chan
  338. set black(voiceme:counter:$chan) 0
  339. }
  340. }
  341. #
  342. #VoiceOnMsg
  343. if {[info exists black(voiceonmsg:$chan:timer_start)]} {
  344. if {[setting:get $chan voiceonmsg]} {
  345. lappend voiceonmsg_channels $chan
  346. }
  347. }
  348. #end
  349. #Limit
  350. if {[info exists black(limit:$chan:timer_start)]} {
  351. if {[setting:get $chan limit]} {
  352. lappend limit_channels $chan
  353. }
  354. }
  355. #end
  356. #TopWOrds
  357. if {[info exists black(topwords:$chan:timer_start)]} {
  358. if {[setting:get $chan topwords]} {
  359. lappend topwords_channels $chan
  360. }
  361. }
  362. #end
  363. #idle
  364. if {[info exists black(idle:$chan:timer_start)]} {
  365. set options {idleop idlevoice idlehalfop idleban}
  366. set idle_activ 0
  367. foreach option $options {
  368. if {[setting:get $chan $option]} {
  369. set idle_activ 1
  370. }
  371. }
  372. if {$idle_activ == "1"} {
  373. if {$black(idle:$chan:timer_start) == "0"} {
  374. if {[setting:get $chan idle-scantime] != ""} {
  375. set time [setting:get $chan idle-scantime]
  376. } else {
  377. set time $black(idleinterval)
  378. }
  379. set scan_time [time_return_minute $time]
  380. set black(idle:$chan:timer_start) $scan_time
  381. }
  382. if {![info exists black(idle:counter:$chan)]} {
  383. set black(idle:counter:$chan) 0
  384. }
  385. set black(idle:counter:$chan) [expr $black(idle:counter:$chan) + 1]
  386. if {$black(idle:counter:$chan) > $black(idle:$chan:timer_start)} {
  387. set black(idle:counter:$chan) 0
  388. } elseif {$black(idle:$chan:timer_start) < $black(idle:counter:$chan)} {
  389. set black(idle:counter:$chan) 0
  390. } elseif {$black(idle:counter:$chan) == $black(idle:$chan:timer_start)} {
  391. lappend idle_channels $chan
  392. set black(idle:counter:$chan) 0
  393. }
  394. }
  395. }
  396. #end
  397. }
  398. #banmethod remove
  399. if {[info exists black(banmethod_rem:timer_start)]} {
  400. if {![info exists black(banmethod_rem:counter)]} {
  401. set black(banmethod_rem:counter) 0
  402. }
  403. set black(banmethod_rem:counter) [expr $black(banmethod_rem:counter) + 1]
  404. if {$black(banmethod_rem:counter) > $black(banmethod_rem:timer_start)} {
  405. set black(banmethod_rem:counter) 0
  406. } elseif {$black(banmethod_rem:timer_start) < $black(banmethod_rem:counter)} {
  407. set black(broadcast:counter) 0
  408. } elseif {$black(banmethod_rem:counter) == $black(banmethod_rem:timer_start)} {
  409. set black(banmethod_rem:counter) 0
  410. banmethod_memory:autoremove
  411. }
  412. }
  413. #end
  414. #Auto Unsuspend
  415. if {[info exists black(s:timer_start)]} {
  416. s:process:timer
  417. }
  418. #end
  419. #AutoBroadcast
  420. if {[info exists black(broadcast:timer_start)]} {
  421. if {![info exists black(broadcast:counter)]} {
  422. set black(broadcast:counter) 0
  423. }
  424. set black(broadcast:counter) [expr $black(broadcast:counter) + 1]
  425. if {$black(broadcast:counter) > $black(broadcast:timer_start)} {
  426. set black(broadcast:counter) 0
  427. } elseif {$black(broadcast:timer_start) < $black(broadcast:counter)} {
  428. set black(broadcast:counter) 0
  429. } elseif {$black(broadcast:counter) == $black(broadcast:timer_start)} {
  430. set black(broadcast:counter) 0
  431. broadcastpublic:show
  432. }
  433. }
  434. #Away Check
  435. if {![info exists black(away:timer_start)]} {
  436. set black(away:timer_start) 720
  437. }
  438. if {![info exists black(counter:away)]} {
  439. set black(counter:away) 0
  440. }
  441. set black(counter:away) [expr $black(counter:away) + 1]
  442. if {$black(counter:away) > $black(away:timer_start)} {
  443. set black(counter:away) 0
  444. } elseif {$black(away:timer_start) < $black(counter:away)} {
  445. set black(counter:away) 0
  446. } elseif {$black(counter:away) == $black(away:timer_start)} {
  447. set black(counter:away) 0
  448. away:timer
  449. }
  450. #end
  451. if {$badchan_channels != ""} {
  452. badchan:scantimer [join $badchan_channels]
  453. }
  454. if {$clonescan_channels != ""} {
  455. clonescan:timer [join $clonescan_channels]
  456. }
  457. if {$antispam_channels != ""} {
  458. antispam:protect:cycle [join $antispam_channels]
  459. }
  460. if {$anunt_channels != ""} {
  461. anuntpublic:show [join $anunt_channels]
  462. }
  463. if {$idle_channels != ""} {
  464. antidle:module [join $idle_channels]
  465. }
  466. if {$voiceonmsg_channels != ""} {
  467. voiceonmsg:timer [join $voiceonmsg_channels]
  468. }
  469. if {$limit_channels != ""} {
  470. limit:timer [join $limit_channels]
  471. }
  472. if {$quote_channels != ""} {
  473. quote:announce [join $quote_channels]
  474. }
  475. if {$voiceme_channels != ""} {
  476. voiceme:showmsg_timer [join $voiceme_channels]
  477. }
  478. if {$topwords_channels != ""} {
  479. topwords:save:channels [join $topwords_channels]
  480. }
  481. timer 1 blacktools:timers:runtime
  482. }
  483. #################
  484. ###########################################################################
  485. ## END ##
  486. ###########################################################################
  487. #badchan
  488. if {[setting:get $chan antibadchan]} {
  489. if {![info exists black(badchan:$chan:timer_start)]} {
  490. if {[setting:get $chan badchan-scantime] != ""} {
  491. set time [setting:get $chan badchan-scantime]
  492. } else {
  493. set time $black(badchan:scantime)
  494. }
  495. set scan_time [time_return_minute $time]
  496. set black(badchan:$chan:timer_start) $scan_time
  497. }
  498. }
  499. #end
  500. #clonescan
  501. if {[setting:get $chan clonescan]} {
  502. if {![info exists black(clonescan:$chan:timer_start)]} {
  503. if {[setting:get $chan clonescan-scantime] != ""} {
  504. set time [setting:get $chan clonescan-scantime]
  505. } else {
  506. set time $black(clonescantime)
  507. }
  508. set scan_time [time_return_minute $time]
  509. set black(clonescan:$chan:timer_start) $scan_time
  510. }
  511. }
  512. #end
  513. #antispam
  514. if {[setting:get $chan antispam]} {
  515. if {![info exists black(antispam:$chan:timer_start)]} {
  516. if {[setting:get $chan antispam-scantime] != ""} {
  517. set time [setting:get $chan antispam-scantime]
  518. } else {
  519. set time $black(spamcycle)
  520. }
  521. set scan_time [time_return_minute $time]
  522. set black(antispam:$chan:timer_start) $scan_time
  523. }
  524. }
  525. #end
  526. #anunt
  527. if {[setting:get $chan anunt]} {
  528. if {![info exists black(anunt:$chan:timer_start)]} {
  529. if {[setting:get $chan anunt-showtime] != ""} {
  530. set time [setting:get $chan anunt-showtime]
  531. } else {
  532. set time $black(anunttime)
  533. }
  534. set scan_time [time_return_minute $time]
  535. set black(anunt:$chan:timer_start) $scan_time
  536. }
  537. }
  538. #end
  539. #idle
  540. if {[setting:get $chan idleop] || [setting:get $chan idlevoice] || [setting:get $chan idlehalfop]} {
  541. if {![info exists black(idle:$chan:timer_start)]} {
  542. if {[setting:get $chan idle-scantime] != ""} {
  543. set time [setting:get $chan idle-scantime]
  544. } else {
  545. set time $black(idleinterval)
  546. }
  547. set scan_time [time_return_minute $time]
  548. set black(idle:$chan:timer_start) $scan_time
  549. }
  550. }
  551. #end
  552. #VoiceOnMsg
  553. if {[setting:get $chan voiceonmsg]} {
  554. if {![info exists black(voiceonmsg:$chan:timer_start)]} {
  555. set black(voiceonmsg:$chan:timer_start) 1
  556. }
  557. }
  558. #end
  559. #Limit
  560. if {[setting:get $chan limit]} {
  561. if {![info exists black(limit:$chan:timer_start)]} {
  562. set black(limit:$chan:timer_start) 1
  563. }
  564. }
  565. #end
  566. #TopWords
  567. if {[setting:get $chan topwords]} {
  568. if {![info exists black(topwords:$chan:timer_start)]} {
  569. set black(topwords:$chan:timer_start) 1
  570. }
  571. }
  572. #end
  573. #quote
  574. if {[setting:get $chan quoteofday]} {
  575. if {![info exists black(quote:$chan:timer_start)]} {
  576. if {[setting:get $chan quote-showtime] != ""} {
  577. set time [setting:get $chan quote-showtime]
  578. } else {
  579. set time $black(quote:msgtime)
  580. }
  581. set scan_time [time_return_minute $time]
  582. set black(quote:$chan:timer_start) $scan_time
  583. }
  584. }
  585. #end
  586. }
  587. #Auto Unsuspend
  588. set status [s:status]
  589. if {$status == "1"} {
  590. if {![info exists black(s:timer_start)]} {
  591. set black(s:timer_start) 1
  592. }
  593. }
  594. #end
  595. #BanMethod Remove
  596. if {![info exists black(banmethod_rem:timer_start)]} {
  597. set black(banmethod_rem:timer_start) [time_return_minute $black(banmethod_memory_time)]
  598. }
  599. #end
  600. #AutoBroadcast
  601. if {[broadcast:check]} {
  602. if {![info exists black(broadcast:timer_start)]} {
  603. set scan_time [time_return_minute $black(bttime)]
  604. set black(broadcast:timer_start) $scan_time
  605. }
  606. }
  607. #end
  608. }
  609. #AutoUpdate Check
  610. if {$black(update_on) != 0} {
  611. if {![info exists black(update_check_start)]} {
  612. timer $black(update_time_check) blacktools:update:timer
  613. set black(update_check_start) 1
  614. }
  615. }
  616. #run by minute
  617. proc blacktools:timers:runtime {} {
  618. global black botnick
  619. set badchan_channels ""
  620. set clonescan_channels ""
  621. set antispam_channels ""
  622. set anunt_channels ""
  623. set idle_channels ""
  624. set voiceonmsg_channels ""
  625. set limit_channels ""
  626. set quote_channels ""
  627. set voiceme_channels ""
  628. set topwords_channels ""
  629. if {$black(antibotidle_status) == 1} {
  630. putserv "PRIVMSG ${botnick}\:X :none"
  631. }
  632. foreach chan [channels] {
  633. #badchan
  634. if {[info exists black(badchan:$chan:timer_start)]} {
  635. if {[setting:get $chan antibadchan]} {
  636. if {$black(badchan:$chan:timer_start) == "0"} {
  637. if {[setting:get $chan badchan-scantime] != ""} {
  638. set time [setting:get $chan badchan-scantime]
  639. } else {
  640. set time $black(badchan:scantime)
  641. }
  642. set scan_time [time_return_minute $time]
  643. set black(badchan:$chan:timer_start) $scan_time
  644. }
  645. if {![info exists black(badchan:counter:$chan)]} {
  646. set black(badchan:counter:$chan) 0
  647. }
  648. set black(badchan:counter:$chan) [expr $black(badchan:counter:$chan) + 1]
  649. if {$black(badchan:counter:$chan) > $black(badchan:$chan:timer_start)} {
  650. set black(badchan:counter:$chan) 0
  651. } elseif {$black(badchan:$chan:timer_start) < $black(badchan:counter:$chan)} {
  652. set black(badchan:counter:$chan) 0
  653. } elseif {$black(badchan:counter:$chan) == $black(badchan:$chan:timer_start)} {
  654. lappend badchan_channels $chan
  655. set black(badchan:counter:$chan) 0
  656. }
  657. }
  658. }
  659. #end
  660. #clonescan
  661. if {[info exists black(clonescan:$chan:timer_start)]} {
  662. if {[setting:get $chan clonescan]} {
  663. if {$black(clonescan:$chan:timer_start) == "0"} {
  664. if {[setting:get $chan clonescan-scantime] != ""} {
  665. set time [setting:get $chan clonescan-scantime]
  666. } else {
  667. set time $black(clonescantime)
  668. }
  669. set scan_time [time_return_minute $time]
  670. set black(clonescan:$chan:timer_start) $scan_time
  671. }
  672. if {![info exists black(clonescan:counter:$chan)]} {
  673. set black(clonescan:counter:$chan) 0
  674. }
  675. set black(clonescan:counter:$chan) [expr $black(clonescan:counter:$chan) + 1]
  676. if {$black(clonescan:counter:$chan) > $black(clonescan:$chan:timer_start)} {
  677. set black(clonescan:counter:$chan) 0
  678. } elseif {$black(clonescan:$chan:timer_start) < $black(clonescan:counter:$chan)} {
  679. set black(clonescan:counter:$chan) 0
  680. } elseif {$black(clonescan:counter:$chan) == $black(clonescan:$chan:timer_start)} {
  681. lappend clonescan_channels $chan
  682. set black(clonescan:counter:$chan) 0
  683. }
  684. }
  685. }
  686. #end
  687. #antispam
  688. if {[info exists black(antispam:$chan:timer_start)]} {
  689. if {[setting:get $chan antispam]} {
  690. if {$black(antispam:$chan:timer_start) == "0"} {
  691. if {[setting:get $chan antispam-scantime] != ""} {
  692. set time [setting:get $chan antispam-scantime]
  693. } else {
  694. set time $black(spamcycle)
  695. }
  696. set scan_time [time_return_minute $time]
  697. set black(antispam:$chan:timer_start) $scan_time
  698. }
  699. if {![info exists black(antispam:counter:$chan)]} {
  700. set black(antispam:counter:$chan) 0
  701. }
  702. set black(antispam:counter:$chan) [expr $black(antispam:counter:$chan) + 1]
  703. if {$black(antispam:counter:$chan) > $black(antispam:$chan:timer_start)} {
  704. set black(antispam:counter:$chan) 0
  705. } elseif {$black(antispam:$chan:timer_start) < $black(antispam:counter:$chan)} {
  706. set black(antispam:counter:$chan) 0
  707. } elseif {$black(antispam:counter:$chan) == $black(antispam:$chan:timer_start)} {
  708. lappend antispam_channels $chan
  709. set black(antispam:counter:$chan) 0
  710. }
  711. }
  712. }
  713. #end
  714. #anunt
  715. if {[info exists black(anunt:$chan:timer_start)]} {
  716. if {[setting:get $chan anunt]} {
  717. if {$black(anunt:$chan:timer_start) == "0"} {
  718. if {[setting:get $chan anunt-showtime] != ""} {
  719. set time [setting:get $chan anunt-showtime]
  720. } else {
  721. set time $black(anunttime)
  722. }
  723. set scan_time [time_return_minute $time]
  724. set black(anunt:$chan:timer_start) $scan_time
  725. }
  726. if {![info exists black(anunt:counter:$chan)]} {
  727. set black(anunt:counter:$chan) 0
  728. }
  729. set black(anunt:counter:$chan) [expr $black(anunt:counter:$chan) + 1]
  730. if {$black(anunt:counter:$chan) > $black(anunt:$chan:timer_start)} {
  731. set black(anunt:counter:$chan) 0
  732. } elseif {$black(anunt:$chan:timer_start) < $black(anunt:counter:$chan)} {
  733. set black(anunt:counter:$chan) 0
  734. } elseif {$black(anunt:counter:$chan) == $black(anunt:$chan:timer_start)} {
  735. lappend anunt_channels $chan
  736. set black(anunt:counter:$chan) 0
  737. }
  738. }
  739. }
  740. #end
  741. #Quote
  742. if {[info exists black(quote:$chan:timer_start)]} {
  743. if {[setting:get $chan quoteofday]} {
  744. if {$black(quote:$chan:timer_start) == "0"} {
  745. if {[setting:get $chan quote-showtime] != ""} {
  746. set time [setting:get $chan quote-showtime]
  747. } else {
  748. set time $black(quote:msgtime)
  749. }
  750. set scan_time [time_return_minute $time]
  751. set black(quote:$chan:timer_start) $scan_time
  752. }
  753. if {![info exists black(quote:counter:$chan)]} {
  754. set black(quote:counter:$chan) 0
  755. }
  756. set black(quote:counter:$chan) [expr $black(quote:counter:$chan) + 1]
  757. if {$black(quote:counter:$chan) > $black(quote:$chan:timer_start)} {
  758. set black(quote:counter:$chan) 0
  759. } elseif {$black(quote:$chan:timer_start) < $black(quote:counter:$chan)} {
  760. set black(quote:counter:$chan) 0
  761. } elseif {$black(quote:counter:$chan) == $black(quote:$chan:timer_start)} {
  762. lappend quote_channels $chan
  763. set black(quote:counter:$chan) 0
  764. }
  765. }
  766. }
  767. #end
  768. #voiceme
  769. if {[info exists black(voiceme:$chan:timer_start)]} {
  770. if {$black(voiceme:$chan:timer_start) == "0"} {
  771. if {[setting:get $chan voiceme-showtime] != ""} {
  772. set time [setting:get $chan voiceme-showtime]
  773. } else {
  774. set time $black(voiceme:msgtime)
  775. }
  776. set scan_time [time_return_minute $time]
  777. set black(voiceme:$chan:timer_start) $scan_time
  778. }
  779. if {![info exists black(voiceme:counter:$chan)]} {
  780. set black(voiceme:counter:$chan) 0
  781. }
  782. set black(voiceme:counter:$chan) [expr $black(voiceme:counter:$chan) + 1]
  783. if {$black(voiceme:counter:$chan) > $black(voiceme:$chan:timer_start)} {
  784. set black(voiceme:counter:$chan) 0
  785. } elseif {$black(voiceme:$chan:timer_start) < $black(voiceme:counter:$chan)} {
  786. set black(voiceme:counter:$chan) 0
  787. } elseif {$black(voiceme:counter:$chan) == $black(voiceme:$chan:timer_start)} {
  788. lappend voiceme_channels $chan
  789. set black(voiceme:counter:$chan) 0
  790. }
  791. }
  792. #
  793. #VoiceOnMsg
  794. if {[info exists black(voiceonmsg:$chan:timer_start)]} {
  795. if {[setting:get $chan voiceonmsg]} {
  796. lappend voiceonmsg_channels $chan
  797. }
  798. }
  799. #end
  800. #Limit
  801. if {[info exists black(limit:$chan:timer_start)]} {
  802. if {[setting:get $chan limit]} {
  803. lappend limit_channels $chan
  804. }
  805. }
  806. #end
  807. #TopWOrds
  808. if {[info exists black(topwords:$chan:timer_start)]} {
  809. if {[setting:get $chan topwords]} {
  810. lappend topwords_channels $chan
  811. }
  812. }
  813. #end
  814. #idle
  815. if {[info exists black(idle:$chan:timer_start)]} {
  816. set options {idleop idlevoice idlehalfop}
  817. set idle_activ 0
  818. foreach option $options {
  819. if {[setting:get $chan $option]} {
  820. set idle_activ 1
  821. }
  822. }
  823. if {$idle_activ == "1"} {
  824. if {$black(idle:$chan:timer_start) == "0"} {
  825. if {[setting:get $chan idle-scantime] != ""} {
  826. set time [setting:get $chan idle-scantime]
  827. } else {
  828. set time $black(idleinterval)
  829. }
  830. set scan_time [time_return_minute $time]
  831. set black(idle:$chan:timer_start) $scan_time
  832. }
  833. if {![info exists black(idle:counter:$chan)]} {
  834. set black(idle:counter:$chan) 0
  835. }
  836. set black(idle:counter:$chan) [expr $black(idle:counter:$chan) + 1]
  837. if {$black(idle:counter:$chan) > $black(idle:$chan:timer_start)} {
  838. set black(idle:counter:$chan) 0
  839. } elseif {$black(idle:$chan:timer_start) < $black(idle:counter:$chan)} {
  840. set black(idle:counter:$chan) 0
  841. } elseif {$black(idle:counter:$chan) == $black(idle:$chan:timer_start)} {
  842. lappend idle_channels $chan
  843. set black(idle:counter:$chan) 0
  844. }
  845. }
  846. }
  847. #end
  848. }
  849. #banmethod remove
  850. if {[info exists black(banmethod_rem:timer_start)]} {
  851. if {![info exists black(banmethod_rem:counter)]} {
  852. set black(banmethod_rem:counter) 0
  853. }
  854. set black(banmethod_rem:counter) [expr $black(banmethod_rem:counter) + 1]
  855. if {$black(banmethod_rem:counter) > $black(banmethod_rem:timer_start)} {
  856. set black(banmethod_rem:counter) 0
  857. } elseif {$black(banmethod_rem:timer_start) < $black(banmethod_rem:counter)} {
  858. set black(broadcast:counter) 0
  859. } elseif {$black(banmethod_rem:counter) == $black(banmethod_rem:timer_start)} {
  860. set black(banmethod_rem:counter) 0
  861. banmethod_memory:autoremove
  862. }
  863. }
  864. #end
  865. #Auto Unsuspend
  866. if {[info exists black(s:timer_start)]} {
  867. s:process:timer
  868. }
  869. #end
  870. #AutoBroadcast
  871. if {[info exists black(broadcast:timer_start)]} {
  872. if {![info exists black(broadcast:counter)]} {
  873. set black(broadcast:counter) 0
  874. }
  875. set black(broadcast:counter) [expr $black(broadcast:counter) + 1]
  876. if {$black(broadcast:counter) > $black(broadcast:timer_start)} {
  877. set black(broadcast:counter) 0
  878. } elseif {$black(broadcast:timer_start) < $black(broadcast:counter)} {
  879. set black(broadcast:counter) 0
  880. } elseif {$black(broadcast:counter) == $black(broadcast:timer_start)} {
  881. set black(broadcast:counter) 0
  882. broadcastpublic:show
  883. }
  884. }
  885. #Away Check
  886. if {![info exists black(away:timer_start)]} {
  887. set black(away:timer_start) 720
  888. }
  889. if {![info exists black(counter:away)]} {
  890. set black(counter:away) 0
  891. }
  892. set black(counter:away) [expr $black(counter:away) + 1]
  893. if {$black(counter:away) > $black(away:timer_start)} {
  894. set black(counter:away) 0
  895. } elseif {$black(away:timer_start) < $black(counter:away)} {
  896. set black(counter:away) 0
  897. } elseif {$black(counter:away) == $black(away:timer_start)} {
  898. set black(counter:away) 0
  899. away:timer
  900. }
  901. #end
  902. if {$badchan_channels != ""} {
  903. badchan:scantimer [join $badchan_channels]
  904. }
  905. if {$clonescan_channels != ""} {
  906. clonescan:timer [join $clonescan_channels]
  907. }
  908. if {$antispam_channels != ""} {
  909. antispam:protect:cycle [join $antispam_channels]
  910. }
  911. if {$anunt_channels != ""} {
  912. anuntpublic:show [join $anunt_channels]
  913. }
  914. if {$idle_channels != ""} {
  915. antidle:module [join $idle_channels]
  916. }
  917. if {$voiceonmsg_channels != ""} {
  918. voiceonmsg:timer [join $voiceonmsg_channels]
  919. }
  920. if {$limit_channels != ""} {
  921. limit:timer [join $limit_channels]
  922. }
  923. if {$quote_channels != ""} {
  924. quote:announce [join $quote_channels]
  925. }
  926. if {$voiceme_channels != ""} {
  927. voiceme:showmsg_timer [join $voiceme_channels]
  928. }
  929. if {$topwords_channels != ""} {
  930. topwords:save:channels [join $topwords_channels]
  931. }
  932. timer 1 blacktools:timers:runtime
  933. }
  934. #################
  935. ###########################################################################
  936. ## END ##
  937. ###########################################################################