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: class InactiveMemberController {
21:
22: 23: 24: 25:
26: public $moduleName;
27:
28:
29: public $db;
30:
31:
32: public $text;
33:
34:
35: public $util;
36:
37: 38: 39:
40: public function setup() {
41:
42: }
43:
44: 45: 46: 47:
48: public function inactivememCommand($message, $channel, $sender, $sendto, $args) {
49: $time = $this->util->parseTime($args[1]);
50: if ($time < 1) {
51: $msg = "You must enter a valid time parameter.";
52: $sendto->reply($msg);
53: return;
54: }
55:
56: $timeString = $this->util->unixtimeToReadable($time, false);
57: $time = time() - $time;
58:
59: $data = $this->db->query("SELECT * FROM org_members_<myname> o LEFT JOIN alts a ON o.name = a.alt WHERE `mode` != 'del' AND `logged_off` < ? ORDER BY o.name", $time);
60:
61: if (count($data) == 0) {
62: $sendto->reply("There are no members in the org roster.");
63: return;
64: }
65:
66: $numinactive = 0;
67: $highlight = 0;
68:
69: $blob = "Org members who have not logged off since <highlight>{$timeString}<end> ago.\n\n";
70:
71: forEach ($data as $row) {
72: $logged = 0;
73: $main = $row->main;
74: if ($row->main != "") {
75: $data1 = $this->db->query("SELECT * FROM alts a JOIN org_members_<myname> o ON a.alt = o.name WHERE `main` = ?", $row->main);
76: forEach ($data1 as $row1) {
77: if ($row1->logged_off > $time) {
78: continue 2;
79: }
80:
81: if ($row1->logged_off > $logged) {
82: $logged = $row1->logged_off;
83: $lasttoon = $row1->name;
84: }
85: }
86: }
87:
88: $numinactive++;
89: $alts = $this->text->makeChatcmd("Alts", "/tell <myname> alts {$row->name}");
90: $logged = $row->logged_off;
91: $lasttoon = $row->name;
92: $lastseen = ($row->logged_off == 0) ? "never" : $this->util->date($logged);
93:
94: $player = "<pagebreak>" . $row->name . "; Main: $main; [{$alts}]\nLast seen on [$lasttoon] on " . $lastseen . "\n\n";
95: if ($highlight == 1) {
96: $blob .= "<highlight>$player<end>";
97: $highlight = 0;
98: } else {
99: $blob .= $player;
100: $highlight = 1;
101: }
102: }
103: $msg = $this->text->makeBlob("$numinactive Inactive Org Members", $blob);
104: $sendto->reply($msg);
105: }
106: }
107:
108: