BT.Timer.tcl 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #########################################################################
  2. ## BlackTools - The Ultimate Channel Control Script ##
  3. ## One TCL. One smart Eggdrop ##
  4. #########################################################################
  5. ############################# TIMER 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 timer:process {nick host hand chan chan1 cmd pid timer_args type} {
  17. global black
  18. set counter 0
  19. if {[matchattr $hand q]} { blacktools:tell $nick $host $hand $chan $chan1 gl.glsuspend none
  20. return
  21. }
  22. if {[matchattr $hand -|q $chan]} { blacktools:tell $nick $host $hand $chan $chan1 gl.suspend none
  23. return
  24. }
  25. if {$cmd == ""} {
  26. switch $type {
  27. 0 {
  28. blacktools:tell $nick $host $hand $chan $chan1 gl.instr "timer"
  29. }
  30. 1 {
  31. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "timer"
  32. }
  33. 2 {
  34. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "timer"
  35. }
  36. }
  37. return
  38. }
  39. switch [string tolower $cmd] {
  40. list {
  41. blacktools:tell $nick $host $hand $chan $chan1 timer.1 none
  42. foreach tmr [timers] {
  43. set counter [expr $counter + 1]
  44. set time [lindex $tmr 0]
  45. set process [join [lindex $tmr 1]]
  46. set pid [lindex $tmr 2]
  47. blacktools:tell $nick $host $hand $chan $chan1 timer.2 "$counter $pid $time $process"
  48. }
  49. foreach tmr [utimers] {
  50. set counter [expr $counter + 1]
  51. set time [lindex $tmr 0]
  52. set process [join [lindex $tmr 1]]
  53. set pid [lindex $tmr 2]
  54. blacktools:tell $nick $host $hand $chan $chan1 timer.3 "$counter $pid $time $process"
  55. }
  56. blacktools:tell $nick $host $hand $chan $chan1 timer.4 none
  57. }
  58. kill {
  59. set found_pid 0
  60. if {$pid == ""} {
  61. switch $type {
  62. 0 {
  63. blacktools:tell $nick $host $hand $chan $chan1 gl.instr "timer"
  64. }
  65. 1 {
  66. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "timer"
  67. }
  68. 2 {
  69. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "timer"
  70. }
  71. }
  72. return
  73. }
  74. foreach tmr [timers] {
  75. set getpid [lindex $tmr 2]
  76. if {[string equal -nocase $getpid $pid]} {
  77. set found_pid 1
  78. killtimer $getpid
  79. break
  80. }
  81. }
  82. foreach tmr [utimers] {
  83. set getpid [lindex $tmr 2]
  84. if {[string equal -nocase $getpid $pid]} {
  85. set found_pid 1
  86. killutimer $getpid
  87. break
  88. }
  89. }
  90. if {$found_pid == "1"} {
  91. blacktools:tell $nick $host $hand $chan $chan1 timer.5 $pid
  92. } else {
  93. blacktools:tell $nick $host $hand $chan $chan1 timer.6 $pid
  94. }
  95. }
  96. start {
  97. set return_time [time_return_minute $pid]
  98. set found_timer 0
  99. if {$timer_args == "" || $return_time == "-1"} {
  100. switch $type {
  101. 0 {
  102. blacktools:tell $nick $host $hand $chan $chan1 gl.instr "timer"
  103. }
  104. 1 {
  105. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_nick "timer"
  106. }
  107. 2 {
  108. blacktools:tell $nick $host $hand $chan $chan1 gl.instr_priv "timer"
  109. }
  110. }
  111. return
  112. }
  113. foreach tm [timers] {
  114. set process [join [lindex $tm 1]]
  115. if {[string equal -nocase $process [lindex [split $timer_args] 0]]} {
  116. set found_timer 1
  117. }
  118. }
  119. if {$found_timer == "1"} {
  120. blacktools:tell $nick $host $hand $chan $chan1 timer.8 none
  121. return
  122. }
  123. set check_timer [timer $return_time $timer_args]
  124. blacktools:tell $nick $host $hand $chan $chan1 timer.7 $check_timer
  125. }
  126. }
  127. }
  128. ##############
  129. #########################################################################
  130. ## END ##
  131. #########################################################################