1: <?php
2:
3: namespace Tyrence\Modules;
4:
5: use Budabot\Core\CommandReply;
6:
7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17:
18: class SameChannelResponseController {
19:
20: 21: 22: 23:
24: public $moduleName;
25:
26:
27: public $commandManager;
28:
29:
30: public $chatBot;
31:
32: 33: 34: 35:
36: public function demoCommand($message, $channel, $sender, $sendto, $args) {
37: $commandString = $args[1];
38: $customSendto = new DemoResponseCommandReply($channel, $sendto, $this->chatBot->vars["name"]);
39: $this->commandManager->process($channel, $commandString, $sender, $customSendto);
40: }
41: }
42:
43: class DemoResponseCommandReply implements CommandReply {
44: private $sendto;
45: private $channel;
46: private $botname;
47:
48: public function __construct($channel, $sendto, $botname) {
49: $this->channel = $channel;
50: $this->sendto = $sendto;
51: $this->botname = $botname;
52: }
53:
54: public function reply($msg) {
55: if ($this->channel == 'priv') {
56: $msg = str_replace("chatcmd:///tell {$this->botname} ", "chatcmd:///g {$this->botname} <symbol>demo ", $msg);
57: } else if ($this->channel == 'guild') {
58: $msg = str_replace("chatcmd:///tell {$this->botname} ", "chatcmd:///o <symbol>demo ", $msg);
59: }
60: $this->sendto->reply($msg);
61: }
62: }
63: