1: <?php
2:
3: namespace Budabot\User\Modules;
4:
5: /**
6: * Author:
7: * - Tyrence (RK2)
8: *
9: * @Instance
10: *
11: * Commands this controller contains:
12: * @DefineCommand(
13: * command = 'beer',
14: * accessLevel = 'all',
15: * description = 'Shows a random beer message',
16: * help = 'fun_module.txt'
17: * )
18: * @DefineCommand(
19: * command = 'brain',
20: * accessLevel = 'all',
21: * description = 'Shows a random pinky and the brain quote',
22: * help = 'fun_module.txt',
23: * alias = 'pinky'
24: * )
25: * @DefineCommand(
26: * command = 'chuck',
27: * accessLevel = 'all',
28: * description = 'Shows a random Chuck Norris joke',
29: * help = 'fun_module.txt'
30: * )
31: * @DefineCommand(
32: * command = 'cybor',
33: * accessLevel = 'all',
34: * description = 'Shows a random cybor message',
35: * help = 'fun_module.txt'
36: * )
37: * @DefineCommand(
38: * command = 'dwight',
39: * accessLevel = 'all',
40: * description = 'Shows a random Dwight quote',
41: * help = 'fun_module.txt'
42: * )
43: * @DefineCommand(
44: * command = 'fc',
45: * accessLevel = 'all',
46: * description = 'Shows a random FC quote',
47: * help = 'fun_module.txt'
48: * )
49: * @DefineCommand(
50: * command = 'homer',
51: * accessLevel = 'all',
52: * description = 'Shows a random homer quote',
53: * help = 'fun_module.txt'
54: * )
55: * @DefineCommand(
56: * command = 'pirates',
57: * accessLevel = 'all',
58: * description = 'Shows a random Pirates of the Caribbean quote',
59: * help = 'fun_module.txt'
60: * )
61: */
62: class FunController {
63:
64: /**
65: * Name of the module.
66: * Set automatically by module loader.
67: */
68: public $moduleName;
69:
70: /** @Inject */
71: public $chatBot;
72:
73: /** @Inject */
74: public $db;
75:
76: /** @Inject */
77: public $util;
78:
79: /**
80: * @Setup
81: */
82: public function setup() {
83: $this->db->loadSQLFile($this->moduleName, "fun");
84: $this->db->loadSQLFile($this->moduleName, "beer");
85: $this->db->loadSQLFile($this->moduleName, "brain");
86: $this->db->loadSQLFile($this->moduleName, "chuck");
87: $this->db->loadSQLFile($this->moduleName, "cybor");
88: $this->db->loadSQLFile($this->moduleName, "dwight");
89: $this->db->loadSQLFile($this->moduleName, "fc");
90: $this->db->loadSQLFile($this->moduleName, "homer");
91: $this->db->loadSQLFile($this->moduleName, "pirates");
92: }
93:
94: public function getFunItem($type, $sender, $number = null) {
95: $data = $this->db->query("SELECT * FROM fun WHERE type = ?", $type);
96: if ($number === null) {
97: $row = $this->util->randomArrayValue($data);
98: } else {
99: $row = $data[$number];
100: }
101:
102: if ($row === null) {
103: $msg = "There is no item with that id.";
104: } else {
105: $dmg = rand(100, 999);
106: $cred = rand(10000, 9999999);
107: $msg = $row->content;
108: $msg = str_replace("*name*", $sender, $msg);
109: $msg = str_replace("*dmg*", $dmg, $msg);
110: $msg = str_replace("*creds*", $cred, $msg);
111: }
112:
113: return $msg;
114: }
115:
116: /**
117: * @HandlesCommand("beer")
118: * @Matches("/^beer$/i")
119: * @Matches("/^beer (\d+)$/i")
120: */
121: public function beerCommand($message, $channel, $sender, $sendto, $args) {
122: $msg = $this->getFunItem('beer', $sender, $args[1]);
123: $sendto->reply($msg);
124: }
125:
126: /**
127: * @HandlesCommand("brain")
128: * @Matches("/^brain$/i")
129: * @Matches("/^brain (\d+)$/i")
130: *
131: * aypwip.php - A Social Worrrrrld Domination! Module
132: *
133: * Developed by Mastura (RK2/Rimor) from Shadow Ops
134: * from Anarchy Online.
135: * converted to Budabot by Tyrence (RK2)
136: */
137: public function brainCommand($message, $channel, $sender, $sendto, $args) {
138: $msg = $this->getFunItem('brain', $sender, $args[1]);
139: $sendto->reply($msg);
140: }
141:
142: /**
143: * @HandlesCommand("chuck")
144: * @Matches("/^chuck$/i")
145: * @Matches("/^chuck (\d+)$/i")
146: *
147: * Author: Honge (RK2)
148: *
149: * Additions taken from a module written by Temar for Bebot: http://bebot.shadow-realm.org/0-3-x-customunofficial-modules/chuck-norris/
150: */
151: public function chuckCommand($message, $channel, $sender, $sendto, $args) {
152: $msg = $this->getFunItem('chuck', $sender, $args[1]);
153: $sendto->reply($msg);
154: }
155:
156: /**
157: * @HandlesCommand("cybor")
158: * @Matches("/^cybor$/i")
159: * @Matches("/^cybor (\d+)$/i")
160: *
161: * Author: Derroylo (RK2)
162: *
163: * Ported over from a bebot plugin written by Xenixa (RK1)
164: */
165: public function cyborCommand($message, $channel, $sender, $sendto, $args) {
166: $msg = $this->getFunItem('cybor', $sender, $args[1]);
167: $sendto->reply($msg);
168: }
169:
170: /**
171: * @HandlesCommand("dwight")
172: * @Matches("/^dwight$/i")
173: * @Matches("/^dwight (\d+)$/i")
174: *
175: * Developed by Sicarius Legion of Amra, a Age of Conan Guild on the Hyrkania server
176: * Converted to Budabot by Tyrence (RK2)
177: */
178: public function dwightCommand($message, $channel, $sender, $sendto, $args) {
179: $msg = $this->getFunItem('dwight', $sender, $args[1]);
180: $sendto->reply($msg);
181: }
182:
183: /**
184: * @HandlesCommand("fc")
185: * @Matches("/^fc$/i")
186: * @Matches("/^fc (\d+)$/i")
187: */
188: public function fcCommand($message, $channel, $sender, $sendto, $args) {
189: $msg = $this->getFunItem('fc', $sender, $args[1]);
190: $sendto->reply($msg);
191: }
192:
193: /**
194: * @HandlesCommand("homer")
195: * @Matches("/^homer$/i")
196: * @Matches("/^homer (\d+)$/i")
197: *
198: * Author: Derroylo (RK2)
199: *
200: * Some entries taken from a module developed by MysterF aka Floryn from Band of Brothers - CROM originally for Bebot: http://bebot.shadow-realm.org/generic-custom-modules/homer-social-mod-for-bebot-0-6-2
201: */
202: public function homerCommand($message, $channel, $sender, $sendto, $args) {
203: $msg = $this->getFunItem('homer', $sender, $args[1]);
204: $sendto->reply($msg);
205: }
206:
207: /**
208: * @HandlesCommand("pirates")
209: * @Matches("/^pirates$/i")
210: * @Matches("/^pirates (\d+)$/i")
211: *
212: * Developed by Sicarius Legion of Amra, a Age of Conan Guild on the Hyrkania server
213: * Converted to Budabot by Tyrence (RK2)
214: */
215: public function piratesCommand($message, $channel, $sender, $sendto, $args) {
216: $msg = $this->getFunItem('pirates', $sender, $args[1]);
217: $sendto->reply($msg);
218: }
219: }
220: