Overview

Namespaces

  • Budabot
    • Core
      • Modules
    • User
      • Modules
  • None
  • Tyrence
    • Modules

Classes

  • AccessLevel
  • Budabot\Core\AccessManager
  • Budabot\Core\AdminManager
  • Budabot\Core\AOChat
  • Budabot\Core\AOChatPacket
  • Budabot\Core\AOChatQueue
  • Budabot\Core\AOExtMsg
  • Budabot\Core\AsyncHttp
  • Budabot\Core\AutoInject
  • Budabot\Core\BotRunner
  • Budabot\Core\Budabot
  • Budabot\Core\BuddylistManager
  • Budabot\Core\CacheManager
  • Budabot\Core\CacheResult
  • Budabot\Core\ClassLoader
  • Budabot\Core\ColorSettingHandler
  • Budabot\Core\CommandAlias
  • Budabot\Core\CommandManager
  • Budabot\Core\ConfigFile
  • Budabot\Core\DB
  • Budabot\Core\DBRow
  • Budabot\Core\EventLoop
  • Budabot\Core\EventManager
  • Budabot\Core\GuildChannelCommandReply
  • Budabot\Core\GuildManager
  • Budabot\Core\HelpManager
  • Budabot\Core\Http
  • Budabot\Core\HttpRequest
  • Budabot\Core\LegacyLogger
  • Budabot\Core\LimitsController
  • Budabot\Core\LoggerWrapper
  • Budabot\Core\MMDBParser
  • Budabot\Core\Modules\AdminController
  • Budabot\Core\Modules\AliasController
  • Budabot\Core\Modules\AltInfo
  • Budabot\Core\Modules\AltsController
  • Budabot\Core\Modules\BanController
  • Budabot\Core\Modules\BuddylistController
  • Budabot\Core\Modules\ColorsController
  • Budabot\Core\Modules\CommandlistController
  • Budabot\Core\Modules\CommandSearchController
  • Budabot\Core\Modules\ConfigController
  • Budabot\Core\Modules\EventlistController
  • Budabot\Core\Modules\HelpController
  • Budabot\Core\Modules\LogsController
  • Budabot\Core\Modules\PlayerLookupController
  • Budabot\Core\Modules\ProfileCommandReply
  • Budabot\Core\Modules\ProfileController
  • Budabot\Core\Modules\SettingsController
  • Budabot\Core\Modules\SQLController
  • Budabot\Core\Modules\SystemController
  • Budabot\Core\Modules\UsageController
  • Budabot\Core\Modules\WhitelistController
  • Budabot\Core\NumberSettingHandler
  • Budabot\Core\OptionsSettingHandler
  • Budabot\Core\PlayerHistory
  • Budabot\Core\PlayerHistoryManager
  • Budabot\Core\PlayerManager
  • Budabot\Core\Preferences
  • Budabot\Core\PrivateChannelCommandReply
  • Budabot\Core\PrivateMessageCommandReply
  • Budabot\Core\Registry
  • Budabot\Core\SettingHandler
  • Budabot\Core\SettingManager
  • Budabot\Core\SettingObject
  • Budabot\Core\SocketManager
  • Budabot\Core\SocketNotifier
  • Budabot\Core\SubcommandManager
  • Budabot\Core\Text
  • Budabot\Core\TextSettingHandler
  • Budabot\Core\Timer
  • Budabot\Core\TimerEvent
  • Budabot\Core\TimeSettingHandler
  • Budabot\Core\Util
  • Budabot\Core\xml
  • Budabot\User\Modules\AlienArmorController
  • Budabot\User\Modules\AlienBioController
  • Budabot\User\Modules\AlienMiscController
  • Budabot\User\Modules\AOSpeakController
  • Budabot\User\Modules\AOUController
  • Budabot\User\Modules\AXPController
  • Budabot\User\Modules\BankController
  • Budabot\User\Modules\BosslootController
  • Budabot\User\Modules\BroadcastController
  • Budabot\User\Modules\BuffPerksController
  • Budabot\User\Modules\CacheController
  • Budabot\User\Modules\ChatAssistController
  • Budabot\User\Modules\ChatCheckController
  • Budabot\User\Modules\ChatLeaderController
  • Budabot\User\Modules\ChatRallyController
  • Budabot\User\Modules\ChatSayController
  • Budabot\User\Modules\ChatTopicController
  • Budabot\User\Modules\CityWaveController
  • Budabot\User\Modules\CloakController
  • Budabot\User\Modules\ClusterController
  • Budabot\User\Modules\CountdownController
  • Budabot\User\Modules\DevController
  • Budabot\User\Modules\DingController
  • Budabot\User\Modules\EventsController
  • Budabot\User\Modules\FightController
  • Budabot\User\Modules\FindOrgController
  • Budabot\User\Modules\FindPlayerController
  • Budabot\User\Modules\FunController
  • Budabot\User\Modules\GitController
  • Budabot\User\Modules\GuideController
  • Budabot\User\Modules\GuildController
  • Budabot\User\Modules\HelpbotController
  • Budabot\User\Modules\HtmlDecodeController
  • Budabot\User\Modules\ImplantController
  • Budabot\User\Modules\ImplantDesignerController
  • Budabot\User\Modules\InactiveMemberController
  • Budabot\User\Modules\ItemsController
  • Budabot\User\Modules\KillOnSightController
  • Budabot\User\Modules\LevelController
  • Budabot\User\Modules\LinksController
  • Budabot\User\Modules\LootListsController
  • Budabot\User\Modules\MdbController
  • Budabot\User\Modules\MessageInfoCommandReply
  • Budabot\User\Modules\MockCommandReply
  • Budabot\User\Modules\NanoController
  • Budabot\User\Modules\NewsController
  • Budabot\User\Modules\NotesController
  • Budabot\User\Modules\OnlineController
  • Budabot\User\Modules\OrgHistoryController
  • Budabot\User\Modules\OrglistController
  • Budabot\User\Modules\OrgMembersController
  • Budabot\User\Modules\OSController
  • Budabot\User\Modules\PlayerHistoryController
  • Budabot\User\Modules\PlayfieldController
  • Budabot\User\Modules\PocketbossController
  • Budabot\User\Modules\PremadeImplantController
  • Budabot\User\Modules\PrivateChannelController
  • Budabot\User\Modules\QuoteController
  • Budabot\User\Modules\RaffleController
  • Budabot\User\Modules\RaidController
  • Budabot\User\Modules\RandomController
  • Budabot\User\Modules\RecipeController
  • Budabot\User\Modules\RelayController
  • Budabot\User\Modules\ReputationController
  • Budabot\User\Modules\ResearchController
  • Budabot\User\Modules\RunAsController
  • Budabot\User\Modules\SendTellController
  • Budabot\User\Modules\ShoppingController
  • Budabot\User\Modules\SilenceController
  • Budabot\User\Modules\SkillsController
  • Budabot\User\Modules\SpiritsController
  • Budabot\User\Modules\StopwatchController
  • Budabot\User\Modules\Teamspeak3
  • Budabot\User\Modules\TeamspeakController
  • Budabot\User\Modules\TestController
  • Budabot\User\Modules\TimeController
  • Budabot\User\Modules\TimerController
  • Budabot\User\Modules\TimezoneController
  • Budabot\User\Modules\TowerController
  • Budabot\User\Modules\TrackerController
  • Budabot\User\Modules\TrickleController
  • Budabot\User\Modules\UnixtimeController
  • Budabot\User\Modules\VoteController
  • Budabot\User\Modules\WeatherController
  • Budabot\User\Modules\WhatBuffsController
  • Budabot\User\Modules\WhereisController
  • Budabot\User\Modules\WhoisController
  • Budabot\User\Modules\WhoisOrgController
  • Budabot\User\Modules\WhompahController
  • Command
  • DefaultStatus
  • DefineCommand
  • Description
  • Event
  • HandlesCommand
  • Help
  • Inject
  • Instance
  • Intoptions
  • Matches
  • Options
  • Setting
  • Setup
  • Type
  • Tyrence\Modules\DemoResponseCommandReply
  • Tyrence\Modules\SameChannelResponseController
  • Visibility

Interfaces

  • Budabot\Core\CommandReply

Exceptions

  • Budabot\Core\InvalidHttpRequest
  • Budabot\Core\SQLException
  • Budabot\Core\StopExecutionException

Functions

  • Budabot\Core\isWindows
  • Budabot\Core\Modules\read_input
  • Overview
  • Namespace
  • Class
  1: <?php
  2: 
  3: namespace Budabot\User\Modules;
  4: 
  5: use Budabot\Core\StopExecutionException;
  6: 
  7: /**
  8:  * Authors: 
  9:  *  - Tyrence (RK2)
 10:  *  - Mindrila (RK1)
 11:  *  - Naturarum (Paradise, RK2)
 12:  *
 13:  * @Instance
 14:  *
 15:  * Commands this class contains:
 16:  *  @DefineCommand(
 17:  *      command     = 'online',
 18:  *      accessLevel = 'member',
 19:  *      description = 'Shows who is online',
 20:  *      help        = 'online.txt'
 21:  *  )
 22:  */
 23: class OnlineController {
 24: 
 25:     /**
 26:      * Name of the module.
 27:      * Set automatically by module loader.
 28:      */
 29:     public $moduleName;
 30:     
 31:     /** @Inject */
 32:     public $db;
 33:     
 34:     /** @Inject */
 35:     public $chatBot;
 36:     
 37:     /** @Inject */
 38:     public $settingManager;
 39:     
 40:     /** @Inject */
 41:     public $accessManager;
 42:     
 43:     /** @Inject */
 44:     public $buddylistManager;
 45:     
 46:     /** @Inject */
 47:     public $altsController;
 48: 
 49:     /** @Inject */
 50:     public $text;
 51:     
 52:     /** @Inject */
 53:     public $util;
 54: 
 55:     /** @Inject */
 56:     public $commandAlias;
 57:     
 58:     /** @Logger */
 59:     public $logger;
 60:     
 61:     /**
 62:      * @Setup
 63:      */
 64:     public function setup() {
 65:         $this->db->loadSQLFile($this->moduleName, "online");
 66:         
 67:         $this->settingManager->add($this->moduleName, "online_expire", "How long to wait before clearing online list", "edit", "time", "15m", "2m;5m;10m;15m;20m", '', "mod");
 68:         $this->settingManager->add($this->moduleName, "online_show_org_guild", "Show org/rank for players in guild channel", "edit", "options", "1", "Show org and rank;Show rank only;Show org only;Show no org info", "2;1;3;0");
 69:         $this->settingManager->add($this->moduleName, "online_show_org_priv", "Show org/rank for players in private channel", "edit", "options", "2", "Show org and rank;Show rank only;Show org only;Show no org info", "2;1;3;0");
 70:         $this->settingManager->add($this->moduleName, "online_admin", "Show admin levels in online list", "edit", "options", "0", "true;false", "1;0");
 71: 
 72:         $this->commandAlias->register($this->moduleName, "online", "o");
 73:         $this->commandAlias->register($this->moduleName, "online", "sm");
 74:     }
 75:     
 76:     /**
 77:      * @HandlesCommand("online")
 78:      * @Matches("/^online$/i")
 79:      */
 80:     public function onlineCommand($message, $channel, $sender, $sendto, $args) {
 81:         $msg = $this->getOnlineList();
 82:         $sendto->reply($msg);
 83:     }
 84: 
 85:     /**
 86:      * @HandlesCommand("online")
 87:      * @Matches("/^online (.+)$/i")
 88:      */
 89:     public function onlineProfCommand($message, $channel, $sender, $sendto, $args) {
 90:         $profession = $this->util->getProfessionName($args[1]);
 91:         if (empty($profession)) {
 92:             return false;
 93:         }
 94: 
 95:         $sql = "
 96:             SELECT DISTINCT p.*, o.afk, COALESCE(a.main, o.name) AS pmain, (CASE WHEN o2.name IS NULL THEN 0 ELSE 1 END) AS online
 97:             FROM online o
 98:             LEFT JOIN alts a ON o.name = a.alt
 99:             LEFT JOIN alts a2 ON a2.main = COALESCE(a.main, o.name)
100:             LEFT JOIN players p ON a2.alt = p.name OR COALESCE(a.main, o.name) = p.name
101:             LEFT JOIN online o2 ON p.name = o2.name
102:             WHERE p.profession = ?
103:             ORDER BY COALESCE(a.main, o.name) ASC";
104:         $data = $this->db->query($sql, $profession);
105:         $count = count($data);
106:         $mainCount = 0;
107:         $currentMain = "";
108: 
109:         if ($count > 0) {
110:             forEach ($data as $row) {
111:                 if ($currentMain != $row->pmain) {
112:                     $mainCount++;
113:                     $blob .= "\n<highlight>$row->pmain<end> has\n";
114:                     $currentMain = $row->pmain;
115:                 }
116: 
117:                 if ($row->profession === null) {
118:                     $blob .= "| ($row->name)\n";
119:                 } else {
120:                     $prof = $this->util->getProfessionAbbreviation($row->profession);
121:                     $blob.= "| $row->name - $row->level/<green>$row->ai_level<end> $prof";
122:                 }
123:                 if ($row->online == 1) {
124:                     $blob .= " <green>Online<end>";
125:                 }
126:                 $blob .= "\n";
127:             }
128:             $blob .= "\nWritten by Naturarum (RK2)";
129:             $msg = $this->text->makeBlob("$profession Search Results ($mainCount)", $blob);
130:         } else {
131:             $msg = "$profession Search Results (0)";
132:         }
133: 
134:         $sendto->reply($msg);
135:     }
136:     
137:     /**
138:      * @Event("logOn")
139:      * @Description("Records an org member login in db")
140:      */
141:     public function recordLogonEvent($eventObj) {
142:         $sender = $eventObj->sender;
143:         if (isset($this->chatBot->guildmembers[$sender])) {
144:             $this->addPlayerToOnlineList($sender, $this->chatBot->vars['guild'], 'guild');
145:         }
146:     }
147:     
148:     /**
149:      * @Event("logOff")
150:      * @Description("Records an org member logoff in db")
151:      */
152:     public function recordLogoffEvent($eventObj) {
153:         $sender = $eventObj->sender;
154:         if (isset($this->chatBot->guildmembers[$sender])) {
155:             $this->removePlayerFromOnlineList($sender, 'guild');
156:         }
157:     }
158:     
159:     /**
160:      * @Event("logOn")
161:      * @Description("Sends a tell to players on logon showing who is online in org")
162:      */
163:     public function showOnlineOnLogonEvent($eventObj) {
164:         $sender = $eventObj->sender;
165:         if (isset($this->chatBot->guildmembers[$sender]) && $this->chatBot->isReady()) {
166:             $msg = $this->getOnlineList();
167:             $this->chatBot->sendTell($msg, $sender);
168:         }
169:     }
170:     
171:     /**
172:      * @Event("timer(10mins)")
173:      * @Description("Online check")
174:      */
175:     public function onlineCheckEvent($eventObj) {
176:         if ($this->chatBot->isReady()) {
177:             //$this->db->beginTransaction();
178:             $data = $this->db->query("SELECT name, channel_type FROM `online`");
179: 
180:             $guildArray = array();
181:             $privArray = array();
182: 
183:             forEach ($data as $row) {
184:                 switch ($row->channel_type) {
185:                     case 'guild':
186:                         $guildArray []= $row->name;
187:                         break;
188:                     case 'priv':
189:                         $privArray []= $row->name;
190:                         break;
191:                     default:
192:                         $this->logger->log("WARN", "ONLINE_MODULE", "Unknown channel type: '$row->channel_type'. Expected: 'guild' or 'priv'");
193:                 }
194:             }
195: 
196:             $time = time();
197: 
198:             forEach ($this->chatBot->guildmembers as $name => $rank) {
199:                 if ($this->buddylistManager->isOnline($name)) {
200:                     if (in_array($name, $guildArray)) {
201:                         $sql = "UPDATE `online` SET `dt` = ? WHERE `name` = ? AND added_by = '<myname>' AND channel_type = 'guild'";
202:                         $this->db->exec($sql, $time, $name);
203:                     } else {
204:                         $sql = "INSERT INTO `online` (`name`, `channel`,  `channel_type`, `added_by`, `dt`) VALUES (?, '<myguild>', 'guild', '<myname>', ?)";
205:                         $this->db->exec($sql, $name, $time);
206:                     }
207:                 }
208:             }
209: 
210:             forEach ($this->chatBot->chatlist as $name => $value) {
211:                 if (in_array($name, $privArray)) {
212:                     $sql = "UPDATE `online` SET `dt` = ? WHERE `name` = ? AND added_by = '<myname>' AND channel_type = 'priv'";
213:                     $this->db->exec($sql, $time, $name);
214:                 } else {
215:                     $sql = "INSERT INTO `online` (`name`, `channel`,  `channel_type`, `added_by`, `dt`) VALUES (?, '<myguild> Guest', 'priv', '<myname>', ?)";
216:                     $this->db->exec($sql, $name, $time);
217:                 }
218:             }
219: 
220:             $sql = "DELETE FROM `online` WHERE (`dt` < ? AND added_by = '<myname>') OR (`dt` < ?)";
221:             $this->db->exec($sql, $time, ($time - $this->settingManager->get('online_expire')));
222:             //$this->db->commit();
223:         }
224:     }
225:     
226:     /**
227:      * @Event("priv")
228:      * @Description("Afk check")
229:      * @Help("afk")
230:      */
231:     public function afkCheckPrivateChannelEvent($eventObj) {
232:         $this->afkCheck($eventObj->sender, $eventObj->message, $eventObj->type);
233:     }
234:     
235:     /**
236:      * @Event("guild")
237:      * @Description("Afk check")
238:      * @Help("afk")
239:      */
240:     public function afkCheckGuildChannelEvent($eventObj) {
241:         $this->afkCheck($eventObj->sender, $eventObj->message, $eventObj->type);
242:     }
243:     
244:     /**
245:      * @Event("priv")
246:      * @Description("Sets a member afk")
247:      * @Help("afk")
248:      */
249:     public function afkPrivateChannelEvent($eventObj) {
250:         $this->afk($eventObj->sender, $eventObj->message, $eventObj->type);
251:     }
252:     
253:     /**
254:      * @Event("guild")
255:      * @Description("Sets a member afk")
256:      * @Help("afk")
257:      */
258:     public function afkGuildChannelEvent($eventObj) {
259:         $this->afk($eventObj->sender, $eventObj->message, $eventObj->type);
260:     }
261:     
262:     public function afkCheck($sender, $message, $type) {
263:         // to stop raising and lowering the cloak messages from triggering afk check
264:         if (!$this->util->isValidSender($sender)) {
265:             return;
266:         }
267: 
268:         if (!preg_match("/^.?afk(.*)$/i", $message)) {
269:             $row = $this->db->queryRow("SELECT afk FROM online WHERE `name` = ? AND added_by = '<myname>' AND channel_type = ?", $sender, $type);
270: 
271:             if ($row !== null && $row->afk != '') {
272:                 list($time, $reason) = explode('|', $row->afk);
273:                 $timeString = $this->util->unixtimeToReadable(time() - $time);
274:                 // $sender is back
275:                 $this->db->exec("UPDATE online SET `afk` = '' WHERE `name` = ? AND added_by = '<myname>' AND channel_type = ?", $sender, $type);
276:                 $msg = "<highlight>{$sender}<end> is back after $timeString.";
277:                 
278:                 if ('priv' == $type) {
279:                     $this->chatBot->sendPrivate($msg);
280:                 } else if ('guild' == $type) {
281:                     $this->chatBot->sendGuild($msg);
282:                 }
283:             }
284:         }
285:     }
286:     
287:     public function afk($sender, $message, $type) {
288:         if (preg_match("/^.?afk$/i", $message)) {
289:             $reason = time();
290:             $this->db->exec("UPDATE online SET `afk` = ? WHERE `name` = ? AND added_by = '<myname>' AND channel_type = ?", $reason, $sender, $type);
291:             $msg = "<highlight>$sender<end> is now AFK.";
292:         } else if (preg_match("/^.?brb(.*)$/i", $message, $arr)) {
293:             $msg = trim($arr[1]);
294:             $reason = time() . '|brb ' . $msg;
295:             $this->db->exec("UPDATE online SET `afk` = ? WHERE `name` = ? AND added_by = '<myname>' AND channel_type = ?", $reason, $sender, $type);
296:             $msg = "<highlight>$sender<end> is now AFK.";
297:         } else if (preg_match("/^.?afk (.*)$/i", $message, $arr)) {
298:             $reason = time() . '|' . $arr[1];
299:             $this->db->exec("UPDATE online SET `afk` = ? WHERE `name` = ? AND added_by = '<myname>' AND channel_type = ?", $reason, $sender, $type);
300:             $msg = "<highlight>$sender<end> is now AFK.";
301:         }
302: 
303:         if ('' != $msg) {
304:             if ('priv' == $type) {
305:                 $this->chatBot->sendPrivate($msg);
306:             } else if ('guild' == $type) {
307:                 $this->chatBot->sendGuild($msg);
308:             }
309:             
310:             // if 'afk' was used as a command, throw StopExecutionException to prevent
311:             // normal command handling from occurring
312:             if ($message[0] == $this->settingManager->get('symbol')) {
313:                 throw new StopExecutionException();
314:             }
315:         }
316:     }
317:     
318:     public function addPlayerToOnlineList($sender, $channel, $channelType) {
319:         $sql = "SELECT name FROM `online` WHERE `name` = ? AND `channel_type` = ? AND added_by = '<myname>'";
320:         $data = $this->db->query($sql, $sender, $channelType);
321:         if (count($data) == 0) {
322:             $sql = "INSERT INTO `online` (`name`, `channel`,  `channel_type`, `added_by`, `dt`) VALUES (?, ?, ?, '<myname>', ?)";
323:             $this->db->exec($sql, $sender, $channel, $channelType, time());
324:         }
325:     }
326:     
327:     public function removePlayerFromOnlineList($sender, $channelType) {
328:         $sql = "DELETE FROM `online` WHERE `name` = ? AND `channel_type` = ? AND added_by = '<myname>'";
329:         $this->db->exec($sql, $sender, $channelType);
330:     }
331:     
332:     public function getOnlineList() {
333:         $orgData = $this->getPlayers('guild');
334:         list($orgCount, $orgMain, $orgBlob) = $this->formatData($orgData, $this->settingManager->get("online_show_org_guild"));
335: 
336:         $privData = $this->getPlayers('priv');
337:         list($privCount, $privMain, $privBlob) = $this->formatData($privData, $this->settingManager->get("online_show_org_priv"));
338: 
339:         $totalCount = $orgCount + $privCount;
340:         $totalMain = $orgMain + $privMain;
341: 
342:         $blob = "\n";
343:         if ($orgCount > 0) {
344:             $blob .= "<header2>Org Channel ($orgMain)<end>\n";
345:             $blob .= $orgBlob;
346:             $blob .= "\n\n";
347:         }
348:         if ($privCount > 0) {
349:             $blob .= "<header2>Private Channel ($privMain)<end>\n";
350:             $blob .= $privBlob;
351:             $blob .= "\n\n";
352:         }
353: 
354:         if ($totalCount > 0) {
355:             $blob .= "Written by Naturarum (RK2)";
356:             $msg = $this->text->makeBlob("Players Online ($totalMain)", $blob);
357:         } else {
358:             $msg = "Players Online (0)";
359:         }
360:         return $msg;
361:     }
362: 
363:     public function getOrgInfo($show_org_info, $fancyColon, $guild, $guild_rank) {
364:         switch ($show_org_info) {
365:             case  3: return $guild != "" ? " $fancyColon {$guild}":" $fancyColon Not in an org";
366:             case  2: return $guild != "" ? " $fancyColon {$guild} ({$guild_rank})":" $fancyColon Not in an org";
367:             case  1: return $guild != "" ? " $fancyColon {$guild_rank}":"";
368:             default: return "";
369:         }
370:     }
371: 
372:     public function getAdminInfo($name, $fancyColon) {
373:         if ($this->settingManager->get("online_admin") != 1) {
374:             return "";
375:         }
376: 
377:         switch ($this->accessManager->getAccessLevelForCharacter($name)) {
378:             case 'superadmin': return " $fancyColon <red>SuperAdmin<end>";
379:             case 'admin'     : return " $fancyColon <red>Admin<end>";
380:             case 'mod'       : return " $fancyColon <green>Mod<end>";
381:             case 'rl'        : return " $fancyColon <orange>RL<end>";
382:         }
383:     }
384: 
385:     public function getAfkInfo($afk, $fancyColon) {
386:         list($time, $reason) = explode("|", $afk);
387:         if (empty($afk)) {
388:             return '';
389:         } else if (empty($reason)) {
390:             $timeString = $this->util->unixtimeToReadable(time() - $time, false);
391:             return " $fancyColon <highlight>AFK for $timeString<end>";
392:         } else {
393:             $timeString = $this->util->unixtimeToReadable(time() - $time, false);
394:             return " $fancyColon <highlight>AFK for $timeString: {$reason}<end>";
395:         }
396:     }
397: 
398:     public function formatData($data, $showOrgInfo) {
399:         $count = count($data);
400:         $mainCount = 0;
401:         $currentMain = "";
402:         $blob = "";
403:         $separator = "-";
404: 
405:         if ($count > 0) {
406:             forEach ($data as $row) {
407:                 if ($currentMain != $row->pmain) {
408:                     $mainCount++;
409:                     $blob .= "\n<pagebreak><highlight>$row->pmain<end> on\n";
410:                     $currentMain = $row->pmain;
411:                 }
412: 
413:                 $admin = $this->getAdminInfo($row->name, $separator);
414:                 $afk = $this->getAfkInfo($row->afk, $separator);
415: 
416:                 if ($row->profession === null) {
417:                     $blob .= "| $row->name$admin$afk\n";
418:                 } else {
419:                     $prof = $this->util->getProfessionAbbreviation($row->profession);
420:                     $orgRank = $this->getOrgInfo($showOrgInfo, $separator, $row->guild, $row->guild_rank);
421:                     $blob.= "| $row->name - $row->level/<green>$row->ai_level<end> $prof$orgRank$admin$afk\n";
422:                 }
423:             }
424:         }
425:         
426:         return [$count, $mainCount, $blob];
427:     }
428: 
429:     public function getPlayers($channelType) {
430:         $sql = "
431:             SELECT p.*, o.name, o.afk, COALESCE(a.main, o.name) AS pmain
432:             FROM online o
433:             LEFT JOIN alts a ON o.name = a.alt
434:             LEFT JOIN players p ON o.name = p.name
435:             WHERE o.channel_type = ?
436:             ORDER BY COALESCE(a.main, o.name) ASC";
437:         return $this->db->query($sql, $channelType);
438:     }
439: }
440: 
Budabot 4 Docs API documentation generated by ApiGen