1: <?php
2:
3: namespace Budabot\User\Modules;
4:
5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
19: class AOSpeakController {
20:
21: 22: 23: 24:
25: public $moduleName;
26:
27:
28: public $chatBot;
29:
30:
31: public $http;
32:
33:
34: public $text;
35:
36:
37: public $util;
38:
39: 40: 41: 42:
43: public function aospeakOrgCommand($message, $channel, $sender, $sendto, $args) {
44: $url = "http://api.aospeak.com/org/" . $this->chatBot->vars['dimension'] . "/" . $this->chatBot->vars['my_guild_id'];
45: $results = $this->http->get($url)->waitAndReturnResponse()->body;
46:
47: if ($results == "ORG_NOT_FOUND") {
48: $msg = "Your org is not currently set up on AOSpeak. Please have your org president set up a channel first.";
49: $sendto->reply($msg);
50: return;
51: }
52:
53: $users = json_decode($results);
54: $count = count($users);
55: if ($count == 0) {
56: $msg = "No org members currently connected to AOSpeak.";
57: } else {
58: $blob = "Server: <highlight>voice.aospeak.com<end>";
59: $blob .= "\n\nUsers:\n";
60: forEach ($users as $user) {
61: if ($user->idleTime >= 300000) {
62:
63: $blob .= "<highlight>{$user->name}<end> ({$user->country}, idle for " . $this->util->unixtimeToReadable($user->idleTime / 1000, false) . ")\n";
64: } else {
65: $blob .= "<highlight>{$user->name}<end> ({$user->country})\n";
66: }
67: }
68: $blob .= "\n\nProvided by " . $this->text->makeChatcmd("AOSpeak.com", "/start http://www.aospeak.com");
69: $msg = $this->text->makeBlob("AOSpeak Org ($count)", $blob);
70: }
71:
72: $sendto->reply($msg);
73: }
74:
75: 76: 77: 78: 79:
80: public function aospeakCommand($message, $channel, $sender, $sendto, $args) {
81: if (count($args) == 2) {
82: $title = "AOSpeak Online RK" . $args[1];
83: $url = "http://api.aospeak.com/online/" . $args[1];
84: } else {
85: $title = "AOSpeak Online";
86: $url = "http://api.aospeak.com/online/";
87: }
88: $results = $this->http->get($url)->waitAndReturnResponse()->body;
89:
90: $users = json_decode($results);
91: $count = count($users);
92: if ($count == 0) {
93: $msg = "No players currently connected to AOSpeak.";
94: } else {
95: $blob = "Server: <highlight>voice.aospeak.com<end>\n";
96:
97: $channels = array();
98: forEach ($users as $user) {
99: $channels[$user->channelName] []= $user;
100: }
101:
102: forEach ($channels as $name => $users) {
103: $blob .= "\n<header2>$name<end>\n";
104: forEach ($users as $user) {
105: $country = empty($user->country) ? "Unknown" : $user->country;
106: if ($user->idleTime >= 300000) {
107:
108: $blob .= "<tab><highlight>{$user->name}<end> ($country, idle for " . $this->util->unixtimeToReadable($user->idleTime / 1000, false) . ")\n";
109: } else {
110: $blob .= "<tab><highlight>{$user->name}<end> ($country)\n";
111: }
112: }
113: }
114: $blob .= "\n\nProvided by " . $this->text->makeChatcmd("AOSpeak.com", "/start http://www.aospeak.com");
115: $msg = $this->text->makeBlob("$title ($count)", $blob);
116: }
117:
118: $sendto->reply($msg);
119: }
120: }
121: