BT.Timer.tcl 4.2 KB

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