BT.Timer.tcl 3.9 KB

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