1: <?php
2:
3: namespace Budabot\User\Modules;
4:
5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19:
20: class CountdownController {
21:
22: 23: 24: 25:
26: public $moduleName;
27:
28:
29: public $db;
30:
31:
32: public $chatBot;
33:
34:
35: public $accessManager;
36:
37:
38: public $text;
39:
40:
41: public $util;
42:
43: private $lastCountdown = 0;
44:
45: 46: 47: 48: 49:
50: public function countdownCommand($message, $channel, $sender, $sendto, $args) {
51: $message = "GO GO GO";
52: if (count($args) == 2) {
53: $message = $args[1];
54: }
55:
56: if ($this->lastCountdown >= (time() - 30)) {
57: $msg = "You can only start a countdown once every 30 seconds.";
58: $sendto->reply($msg);
59: return;
60: }
61:
62: $this->lastCountdown = time();
63:
64: for ($i = 5; $i > 0; $i--) {
65: if ($i == 5) {
66: $color = "<red>";
67: } else if ($i == 4) {
68: $color = "<red>";
69: } else if ($i == 3) {
70: $color = "<orange>";
71: } else if ($i == 2) {
72: $color = "<orange>";
73: } else if ($i == 1) {
74: $color = "<orange>";
75: }
76: $msg = "$color-------> $i <-------<end>";
77: $sendto->reply($msg);
78: sleep(1);
79: }
80:
81: $msg = "<green>------> $message <-------<end>";
82: $sendto->reply($msg);
83: }
84: }
85: