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 class contains:
 12:  *  @DefineCommand(
 13:  *      command     = 'cloak',
 14:  *      accessLevel = 'guild',
 15:  *      description = 'Show the status of the city cloak',
 16:  *      help        = 'cloak.txt',
 17:  *      alias       = 'city'
 18:  *  )
 19:  */
 20: class CloakController {
 21: 
 22:     /**
 23:      * Name of the module.
 24:      * Set automatically by module loader.
 25:      */
 26:     public $moduleName;
 27:     
 28:     /** @Inject */
 29:     public $chatBot;
 30:     
 31:     /** @Inject */
 32:     public $settingManager;
 33:     
 34:     /** @Inject */
 35:     public $db;
 36:     
 37:     /** @Inject */
 38:     public $text;
 39:     
 40:     /** @Inject */
 41:     public $util;
 42:     
 43:     /** @Inject */
 44:     public $altsController;
 45:     
 46:     /**
 47:      * @Setup
 48:      */
 49:     public function setup() {
 50:         $this->db->loadSQLFile($this->moduleName, 'org_city');
 51:     
 52:         $this->settingManager->add($this->moduleName, "showcloakstatus", "Show cloak status to players at logon", "edit", "options", "1", "Never;When cloak is down;Always", "0;1;2");
 53:         $this->settingManager->add($this->moduleName, "cloak_reminder_interval", "How often to spam guild channel when cloak is down", "edit", "time", "5m", "2m;5m;10m;15m;20m");
 54:     }
 55:     
 56:     /**
 57:      * @HandlesCommand("cloak")
 58:      * @Matches("/^cloak$/i")
 59:      */
 60:     public function cloakCommand($message, $channel, $sender, $sendto, $args) {
 61:         $data = $this->db->query("SELECT * FROM org_city_<myname> WHERE `action` = 'on' OR `action` = 'off' ORDER BY `time` DESC LIMIT 20");
 62:         if (count($data) == 0) {
 63:             $msg = "Unknown status on cloak!";
 64:         } else {
 65:             $row = array_shift($data);
 66:             $timeSinceChange = time() - $row->time;
 67:             $timeString = $this->util->unixtimeToReadable(3600 - $timeSinceChange, false);
 68: 
 69:             if ($timeSinceChange >= 3600 && $row->action == "off") {
 70:                 $msg = "The cloaking device is <orange>disabled<end>. It is possible to enable it.";
 71:             } else if ($timeSinceChange < 3600 && $row->action == "off") {
 72:                 $msg = "The cloaking device is <orange>disabled<end>. It is possible in $timeString to enable it.";
 73:             } else if ($timeSinceChange >= 3600 && $row->action == "on") {
 74:                 $msg = "The cloaking device is <green>enabled<end>. It is possible to disable it.";
 75:             } else if ($timeSinceChange < 3600 && $row->action == "on") {
 76:                 $msg = "The cloaking device is <green>enabled<end>. It is possible in $timeString to disable it.";
 77:             }
 78: 
 79:             $list = "Time: <highlight>" . $this->util->date($row->time) . "<end>\n";
 80:             $list .= "Action: <highlight>Cloaking device turned " . $row->action . "<end>\n";
 81:             $list .= "Character: <highlight>" . $row->player . "<end>\n\n";
 82: 
 83:             forEach ($data as $row) {
 84:                 $list .= "Time: <highlight>" . $this->util->date($row->time) . "<end>\n";
 85:                 $list .= "Action: <highlight>Cloaking device turned " . $row->action . "<end>\n";
 86:                 $list .= "Character: <highlight>" . $row->player . "<end>\n\n";
 87:             }
 88:             $msg .= " " . $this->text->makeBlob("Cloak History", $list);
 89:         }
 90:         $sendto->reply($msg);
 91:     }
 92: 
 93:     /**
 94:      * @HandlesCommand("cloak")
 95:      * @Matches("/^cloak (raise|on)$/i")
 96:      */
 97:     public function cloakRaiseCommand($message, $channel, $sender, $sendto, $args) {
 98:         $row = $this->db->queryRow("SELECT * FROM org_city_<myname> WHERE `action` = 'on' OR `action` = 'off' ORDER BY `time` DESC LIMIT 1");
 99: 
100:         if ($row->action == "on") {
101:             $msg = "The cloaking device is already <green>enabled<end>.";
102:         } else {
103:             $this->db->exec("INSERT INTO org_city_<myname> (`time`, `action`, `player`) VALUES (?, ?, ?)", time(), 'on', $sender . '*');
104:             $msg = "The cloaking device has been manually enabled in the bot (you must still enable the cloak if it's disabled).";
105:         }
106: 
107:         $sendto->reply($msg);
108:     }
109:     
110:     /**
111:      * @Event("guild")
112:      * @Description("Records when the cloak is raised or lowered")
113:      */
114:     public function recordCloakChangesEvent($eventObj) {
115:         if (!$this->util->isValidSender($eventObj->sender) && preg_match("/^(.+) turned the cloaking device in your city (on|off).$/i", $eventObj->message, $arr)) {
116:             $this->db->exec("INSERT INTO org_city_<myname> (`time`, `action`, `player`) VALUES (?, ?, ?)", time(), $arr[2], $arr[1]);
117:         }
118:     }
119:     
120:     /**
121:      * @Event("timer(1min)")
122:      * @Description("Checks timer to see if cloak can be raised or lowered")
123:      */
124:     public function checkTimerEvent($eventObj) {
125:         $row = $this->db->queryRow("SELECT * FROM org_city_<myname> ORDER BY `time` DESC LIMIT 1");
126:         if ($row !== null) {
127:             $timeSinceChange = time() - $row->time;
128:             if ($row->action == "off") {
129:                 // send message to org chat every 5 minutes that the cloaking device is
130:                 // disabled past the the time that the cloaking device could be enabled.
131:                 $interval = $this->settingManager->get('cloak_reminder_interval');
132:                 if ($timeSinceChange >= 60*60 && ($timeSinceChange % $interval >= 0 && $timeSinceChange % $interval <= 60 )) {
133:                     $timeString = $this->util->unixtimeToReadable(time() - $row->time, false);
134:                     $this->chatBot->sendGuild("The cloaking device was disabled by <highlight>{$row->player}<end> $timeString ago. It is possible to enable it.");
135:                 }
136:             } else if ($row->action == "on") {
137:                 if ($timeSinceChange >= 60*60 && $timeSinceChange < 61*60) {
138:                     $this->chatBot->sendGuild("The cloaking device was enabled one hour ago. Alien attacks can now be initiated.");
139:                 }
140:             }
141:         }
142:     }
143:     
144:     /**
145:      * @Event("timer(1min)")
146:      * @Description("Reminds the player who lowered cloak to raise it")
147:      */
148:     public function cloakReminderEvent($eventObj) {
149:         // valid states for action are: 'on', 'off'
150:         $row = $this->db->queryRow("SELECT * FROM org_city_<myname> WHERE `action` = 'on' OR `action` = 'off' ORDER BY `time` DESC LIMIT 1");
151:         if ($row !== null) {
152:             $msg = "";
153: 
154:             if ($row->action == "off") {
155:                 $timeSinceChange = time() - $row->time;
156:                 $timeString = $this->util->unixtimeToReadable(3600 - $timeSinceChange, false);
157: 
158:                 // 10 minutes before, send tell to player
159:                 if ($timeSinceChange >= 49*60 && $timeSinceChange <= 50*60) {
160:                     $msg = "The cloaking device is <orange>disabled<end>. It is possible in $timeString to enable it.";
161:                 } else if ($timeSinceChange >= 58*60 && $timeSinceChange <= 59*60) {
162:                     // 1 minute before send tell to player
163:                     $msg = "The cloaking device is <orange>disabled<end>. It is possible in $timeString to enable it.";
164:                 } else if ($timeSinceChange >= 59*60 && ($timeSinceChange % (60*5) >= 0 && $timeSinceChange % (60*5) <= 60 )) {
165:                     // when cloak can be raised, send tell to player and
166:                     // every 5 minutes after, send tell to player
167:                     $msg = "The cloaking device is <orange>disabled<end>. Please enable it now.";
168:                 }
169: 
170:                 if ($msg) {
171:                     // send message to all online alts
172:                     $altInfo = $this->altsController->getAltInfo($row->player);
173:                     forEach ($altInfo->getOnlineAlts() as $name) {
174:                         $this->chatBot->sendTell($msg, $name);
175:                     }
176:                 }
177:             }
178:         }
179:     }
180:     
181:     /**
182:      * @Event("logOn")
183:      * @Description("Show cloak status to guild members logging in")
184:      */
185:     public function cityGuildLogonEvent($eventObj) {
186:         if ($this->chatBot->isReady() && isset($this->chatBot->guildmembers[$eventObj->sender])) {
187:             $row = $this->db->queryRow("SELECT * FROM org_city_<myname> WHERE `action` = 'on' OR `action` = 'off' ORDER BY `time` DESC LIMIT 0, 20 ");
188: 
189:             $case = 0;
190:             if ($row !== null) {
191:                 $timeSinceChange = time() - $row->time;
192:                 $timeString = $this->util->unixtimeToReadable(3600 - $timeSinceChange, false);
193: 
194:                 if ($timeSinceChange >= 60*60 && $row->action == "off") {
195:                     $case = 1;
196:                     $msg = "The cloaking device is <orange>disabled<end>. It is possible to enable it.";
197:                 } else if ($timeSinceChange < 60*30 && $row->action == "off") {
198:                     $case = 1;
199:                     $msg = "<red>RAID IN PROGRESS!  DO NOT ENTER CITY!</red>";
200:                 } else if ($timeSinceChange < 60*60 && $row->action == "off") {
201:                     $msg = "Cloaking device is <orange>disabled<end>. It is possible in $timeString to enable it.";
202:                     $case = 1;
203:                 } else if ($timeSinceChange >= 60*60 && $row->action == "on") {
204:                     $msg = "The cloaking device is <green>enabled<end>. It is possible to disable it.";
205:                     $case = 2;
206:                 } else if ($timeSinceChange < 60*60 && $row->action == "on") {
207:                     $msg = "The cloaking device is <green>enabled<end>. It is possible in $timeString to disable it.";
208:                     $case = 2;
209:                 } else {
210:                     $msg = "Unknown status on city cloak!";
211:                     $case = 1;
212:                 }
213: 
214:                 if ($case <= $this->settingManager->get("showcloakstatus")) {
215:                     $this->chatBot->sendTell($msg, $eventObj->sender);
216:                 }
217:             }
218:         }
219:     }
220: }
221: 
Budabot 4 Docs API documentation generated by ApiGen