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: class MdbController {
22:
23: 24: 25: 26:
27: public $moduleName;
28:
29:
30: public $chatBot;
31:
32:
33: public $util;
34:
35:
36: public $text;
37:
38:
39: public function setup() {
40:
41: }
42:
43: 44: 45: 46:
47: public function mdbCommand($message, $channel, $sender, $sendto, $args) {
48: $categories = $this->chatBot->mmdbParser->getCategories();
49:
50: $blob = '';
51: forEach ($categories as $category) {
52: $blob .= $this->text->makeChatcmd($category['id'], "/tell <myname> mdb " . $category['id']) . "\n";
53: }
54:
55: $msg = $this->text->makeBlob("MDB Categories", $blob);
56:
57: $sendto->reply($msg);
58: }
59:
60: 61: 62: 63:
64: public function mdbCategoryCommand($message, $channel, $sender, $sendto, $args) {
65: $categoryId = $args[1];
66:
67: $instances = $this->chatBot->mmdbParser->findAllInstancesInCategory($categoryId);
68:
69: $blob = '';
70: forEach ($instances as $instance) {
71: $blob .= $this->text->makeChatcmd($instance['id'], "/tell <myname> mdb $categoryId " . $instance['id']) . "\n";
72: }
73:
74: $msg = $this->text->makeBlob("MDB Instances for Category $categoryId", $blob);
75:
76: $sendto->reply($msg);
77: }
78:
79: 80: 81: 82:
83: public function mdbInstanceCommand($message, $channel, $sender, $sendto, $args) {
84: $categoryId = $args[1];
85: $instanceId = $args[2];
86:
87: $messageString = $this->chatBot->mmdbParser->getMessageString($categoryId, $instanceId);
88:
89: $msg = "[$categoryId : $instanceId] $messageString";
90: $sendto->reply($msg);
91: }
92: }
93:
94: