1: <?php
2:
3: namespace Budabot\Core\Modules;
4:
5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17: class EventlistController {
18:
19:
20: public $text;
21:
22:
23: public $db;
24:
25: 26: 27: 28: 29: 30: 31: 32:
33: public function eventlistCommand($message, $channel, $sender, $sendto, $args) {
34: $params = array();
35: if (isset($args[1])) {
36: $params []= $args[1];
37: $cmdSearchSql = "WHERE type LIKE ?";
38: }
39:
40: $sql = "
41: SELECT
42: type,
43: description,
44: module,
45: file,
46: status
47: FROM
48: eventcfg_<myname>
49: $cmdSearchSql
50: ORDER BY
51: type ASC";
52: $data = $this->db->query($sql, $params);
53: $count = count($data);
54:
55: if ($count > 0) {
56: $blob = '';
57: forEach ($data as $row) {
58: $on = $this->text->makeChatcmd('ON', "/tell <myname> config event $row->type $row->file enable all");
59: $off = $this->text->makeChatcmd('OFF', "/tell <myname> config event $row->type $row->file disable all");
60:
61: if ($row->status == 1) {
62: $status = "<green>Enabled<end>";
63: } else {
64: $status = "<red>Disabled<end>";
65: }
66:
67: if ($row->description != '') {
68: $blob .= "$row->type [$row->module] ($status): $on $off - $row->description\n";
69: } else {
70: $blob .= "$row->type [$row->module] ($status): $on $off\n";
71: }
72: }
73:
74: $msg = $this->text->makeBlob("Event List ($count)", $blob);
75: } else {
76: $msg = "No events were found.";
77: }
78: $sendto->reply($msg);
79: }
80: }
81: