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: 21: 22:
23: class ChatAssistController {
24:
25: 26: 27: 28:
29: public $moduleName;
30:
31:
32: public $chatBot;
33:
34:
35: public $text;
36:
37:
38: public $chatLeaderController;
39:
40: 41: 42:
43: private $assistMessage;
44:
45: 46: 47: 48:
49: public function assistCommand($message, $channel, $sender, $sendto, $args) {
50: if (!isset($this->assistMessage)) {
51: $msg = "No assist set.";
52: $sendto->reply($msg);
53: return;
54: } else {
55: $sendto->reply($this->assistMessage);
56: }
57: }
58:
59: 60: 61: 62:
63: public function assistClearCommand($message, $channel, $sender, $sendto, $args) {
64: if (!$this->chatLeaderController->checkLeaderAccess($sender)) {
65: $sendto->reply("You must be Raid Leader to use this command.");
66: return;
67: }
68:
69: $this->assistMessage = null;
70: $sendto->reply("Assist has been cleared.");
71: }
72:
73: 74: 75: 76:
77: public function assistSetCommand($message, $channel, $sender, $sendto, $args) {
78: if (!$this->chatLeaderController->checkLeaderAccess($sender)) {
79: $sendto->reply("You must be Raid Leader to use this command.");
80: return;
81: }
82:
83: $nameArray = explode(' ', $args[1]);
84:
85: if (count($nameArray) == 1) {
86: $name = ucfirst(strtolower($args[1]));
87: $uid = $this->chatBot->get_uid($name);
88: if (!$uid) {
89: $msg = "Character <highlight>$name<end> does not exist.";
90: $sendto->reply($msg);
91: } else if ($channel == "priv" && !isset($this->chatBot->chatlist[$name])) {
92: $msg = "Character <highlight>$name<end> is not in this bot.";
93: $sendto->reply($msg);
94: }
95:
96: $link = $this->text->makeChatcmd("Click here to make an assist $name macro", "/macro $name /assist $name");
97: $this->assistMessage = $this->text->makeBlob("Assist $name Macro", $link);
98: } else {
99: forEach ($nameArray as $key => $name) {
100: $name = ucfirst(strtolower($name));
101: $uid = $this->chatBot->get_uid($name);
102: if (!$uid) {
103: $msg = "Character <highlight>$name<end> does not exist.";
104: $sendto->reply($msg);
105: } else if ($channel == "priv" && !isset($this->chatBot->chatlist[$name])) {
106: $msg = "Character <highlight>$name<end> is not in this bot.";
107: $sendto->reply($msg);
108: }
109:
110: $nameArray[$key] = "/assist $name";
111: }
112:
113:
114: $nameArray = array_reverse($nameArray);
115: $this->assistMessage = '/macro assist ' . implode(" \\n ", $nameArray);
116: }
117:
118: $sendto->reply($this->assistMessage);
119: }
120: }
121: