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: /**
  6:  * Authors: 
  7:  *  - Tyrence (RK2)
  8:  *
  9:  * @Instance
 10:  *
 11:  * Commands this controller contains:
 12:  *  @DefineCommand(
 13:  *      command     = 'track', 
 14:  *      accessLevel = 'all', 
 15:  *      description = 'Show and manage tracked players', 
 16:  *      help        = 'track.txt'
 17:  *  )
 18:  */
 19: class TrackerController {
 20: 
 21:     /**
 22:      * Name of the module.
 23:      * Set automatically by module loader.
 24:      */
 25:     public $moduleName;
 26: 
 27:     /** @Inject */
 28:     public $text;
 29:     
 30:     /** @Inject */
 31:     public $util;
 32:     
 33:     /** @Inject */
 34:     public $db;
 35:     
 36:     /** @Inject */
 37:     public $chatBot;
 38:     
 39:     /** @Inject */
 40:     public $settingManager;
 41:     
 42:     /** @Inject */
 43:     public $setting;
 44:     
 45:     /** @Inject */
 46:     public $buddylistManager;
 47:     
 48:     /**
 49:      * @Setup
 50:      */
 51:     public function setup() {
 52:         $this->db->loadSQLFile($this->moduleName, 'tracked_users');
 53:         $this->db->loadSQLFile($this->moduleName, 'tracking');
 54:         
 55:         $this->settingManager->add($this->moduleName, 'show_tracker_events', 'Where to show tracker events', 'edit', 'text', 'none', 'org;priv;both;none', '', 'mod');
 56:     }
 57:     
 58:     /**
 59:      * @Event("connect")
 60:      * @Description("Adds all players on the track list to the buddy list")
 61:      */
 62:     public function trackedUsersConnectEvent($eventObj) {
 63:         $sql = "SELECT name FROM tracked_users_<myname>";
 64:         $data = $this->db->query($sql);
 65:         forEach ($data as $row) {
 66:             $this->buddylistManager->add($row->name, 'tracking');
 67:         }
 68:     }
 69:     
 70:     /**
 71:      * @Event("logOn")
 72:      * @Description("Records a tracked user logging on")
 73:      */
 74:     public function trackLogonEvent($eventObj) {
 75:         if ($this->chatBot->isReady()) {
 76:             $uid = $this->chatBot->get_uid($eventObj->sender);
 77:             $data = $this->db->query("SELECT * FROM tracked_users_<myname> WHERE uid = ?", $uid);
 78:             if (count($data) > 0) {
 79:                 $this->db->exec("INSERT INTO tracking_<myname> (uid, dt, event) VALUES (?, ?, ?)", $uid, time(), 'logon');
 80:                 
 81:                 $msg = "TRACK: $eventObj->sender logged <green>on<end>.";
 82:                 
 83:                 if ($this->setting->show_tracker_events == "both" || $this->setting->show_tracker_events == "org") {
 84:                     $this->chatBot->sendGuild($msg, true);
 85:                 }
 86:                 if ($this->setting->show_tracker_events == "both" || $this->setting->show_tracker_events == "priv") {
 87:                     $this->chatBot->sendPrivate($msg, true);
 88:                 }
 89:             }
 90:         }
 91:     }
 92:     
 93:     /**
 94:      * @Event("logOff")
 95:      * @Description("Records a tracked user logging off")
 96:      */
 97:     public function trackLogoffEvent($eventObj) {
 98:         if ($this->chatBot->isReady()) {
 99:             $uid = $this->chatBot->get_uid($eventObj->sender);
100:             $data = $this->db->query("SELECT * FROM tracked_users_<myname> WHERE uid = ?", $uid);
101:             if (count($data) > 0) {
102:                 $this->db->exec("INSERT INTO tracking_<myname> (uid, dt, event) VALUES (?, ?, ?)", $uid, time(), 'logoff');
103:                 
104:                 $msg = "TRACK: $eventObj->sender logged <orange>off<end>.";
105:                 
106:                 if ($this->setting->show_tracker_events == "both" || $this->setting->show_tracker_events == "org") {
107:                     $this->chatBot->sendGuild($msg, true);
108:                 }
109:                 if ($this->setting->show_tracker_events == "both" || $this->setting->show_tracker_events == "priv") {
110:                     $this->chatBot->sendPrivate($msg, true);
111:                 }
112:             }
113:         }
114:     }
115: 
116:     /**
117:      * @HandlesCommand("track")
118:      * @Matches("/^track$/i")
119:      */
120:     public function trackListCommand($message, $channel, $sender, $sendto, $args) {
121:         $data = $this->db->query("SELECT * FROM tracked_users_<myname> ORDER BY `name`");
122:         $numrows = count($data);
123:         if ($numrows != 0) {
124:             $blob = '';
125:             forEach ($data as $row) {
126:                 $row2 = $this->db->queryRow("SELECT `event`, `dt` FROM tracking_<myname> WHERE `uid` = ? ORDER BY `dt` DESC LIMIT 1", $row->uid);
127:                 $last_action = '';
128:                 if ($row2 != null) {
129:                     $last_action = " " . $this->util->date($row2->dt);
130:                 }
131: 
132:                 if ($row2->event == 'logon') {
133:                     $status = "<green>logon<end>";
134:                 } else if ($row2->event == 'logoff') {
135:                     $status = "<orange>logoff<end>";
136:                 } else {
137:                     $status = "<grey>None<end>";
138:                 }
139: 
140:                 $remove = $this->text->makeChatcmd('Remove', "/tell <myname> track rem $row->name");
141: 
142:                 $history = $this->text->makeChatcmd('History', "/tell <myname> track $row->name");
143: 
144:                 $blob .= "<tab>-[{$history}] {$row->name} ({$status}{$last_action}) - {$remove}\n";
145:             }
146: 
147:             $msg = $this->text->makeBlob("Tracklist ({$numrows})", $blob);
148:         } else {
149:             $msg = "No characters are on the track list.";
150:         }
151:         $sendto->reply($msg);
152:     }
153:     
154:     /**
155:      * @HandlesCommand("track")
156:      * @Matches("/^track rem (.+)$/i")
157:      */
158:     public function trackRemoveCommand($message, $channel, $sender, $sendto, $args) {
159:         $name = ucfirst(strtolower($args[1]));
160:         $uid = $this->chatBot->get_uid($name);
161: 
162:         if (!$uid) {
163:             $msg = "Character <highlight>$name<end> does not exist.";
164:         } else {
165:             $data = $this->db->query("SELECT * FROM tracked_users_<myname> WHERE `uid` = ?", $uid);
166:             if (count($data) == 0) {
167:                 $msg = "Character <highlight>$name<end> is not on the track list.";
168:             } else {
169:                 $this->db->exec("DELETE FROM tracked_users_<myname> WHERE `uid` = ?", $uid);
170:                 $msg = "Character <highlight>$name<end> has been removed from the track list.";
171:                 $this->buddylistManager->remove($name, 'tracking');
172:             }
173:         }
174: 
175:         $sendto->reply($msg);
176:     }
177:     
178:     /**
179:      * @HandlesCommand("track")
180:      * @Matches("/^track add (.+)$/i")
181:      */
182:     public function trackAddCommand($message, $channel, $sender, $sendto, $args) {
183:         $name = ucfirst(strtolower($args[1]));
184:         $uid = $this->chatBot->get_uid($name);
185: 
186:         if (!$uid) {
187:             $msg = "Character <highlight>$name<end> does not exist.";
188:         } else {
189:             $data = $this->db->query("SELECT * FROM tracked_users_<myname> WHERE `uid` = ?", $uid);
190:             if (count($data) != 0) {
191:                 $msg = "Character <highlight>$name<end> is already on the track list.";
192:             } else {
193:                 $this->db->exec("INSERT INTO tracked_users_<myname> (`name`, `uid`, `added_by`, `added_dt`) VALUES (?, ?, ?, ?)", $name, $uid, $sender, time());
194:                 $msg = "Character <highlight>$name<end> has been added to the track list.";
195:                 $this->buddylistManager->add($name, 'tracking');
196:             }
197:         }
198: 
199:         $sendto->reply($msg);
200:     }
201:     
202:     /**
203:      * @HandlesCommand("track")
204:      * @Matches("/^track (.+)$/i")
205:      */
206:     public function trackShowCommand($message, $channel, $sender, $sendto, $args) {
207:         $name = ucfirst(strtolower($args[1]));
208:         $uid = $this->chatBot->get_uid($name);
209: 
210:         if (!$uid) {
211:             $msg = "Character <highlight>$name<end> does not exist.";
212:         } else {
213:             $data = $this->db->query("SELECT `event`, `dt` FROM tracking_<myname> WHERE `uid` = $uid ORDER BY `dt` DESC");
214:             if (count($data) > 0) {
215:                 $blob = '';
216:                 forEach ($data as $row) {
217:                     if ($row->event == 'logon') {
218:                         $status = "<green>logon<end>";
219:                     } else if ($row->event == 'logoff') {
220:                         $status = "<orange>logoff<end>";
221:                     } else {
222:                         $status = "<grey>unknown<end>";
223:                     }
224:                     $blob .= "$status " . $this->util->date($row->dt) ."\n";
225:                 }
226: 
227:                 $msg = $this->text->makeBlob("Track History for $name", $blob);
228:             } else {
229:                 $msg = "Character <highlight>$name<end> has never logged on or is not being tracked.";
230:             }
231:         }
232:         $sendto->reply($msg);
233:     }
234: }
235: 
Budabot 4 Docs API documentation generated by ApiGen