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\AutoInject;
  6: use ReflectionAnnotatedMethod;
  7: use Budabot\Core\Registry;
  8: 
  9: /**
 10:  * Authors: 
 11:  *  - Tyrence (RK2)
 12:  *
 13:  * @Instance
 14:  *
 15:  * Commands this controller contains:
 16:  *  @DefineCommand(
 17:  *      command     = 'showcmdregex',
 18:  *      accessLevel = 'admin',
 19:  *      description = "Test the bot commands",
 20:  *      help        = 'test.txt'
 21:  *  )
 22:  *  @DefineCommand(
 23:  *      command     = 'intransaction',
 24:  *      accessLevel = 'admin',
 25:  *      description = "Test the bot commands",
 26:  *      help        = 'test.txt'
 27:  *  )
 28:  *  @DefineCommand(
 29:  *      command     = 'rollbacktransaction',
 30:  *      accessLevel = 'admin',
 31:  *      description = "Test the bot commands",
 32:  *      help        = 'test.txt'
 33:  *  )
 34:  *  @DefineCommand(
 35:  *      command     = 'stacktrace',
 36:  *      accessLevel = 'admin',
 37:  *      description = "Test the bot commands",
 38:  *      help        = 'test.txt'
 39:  *  )
 40:  *  @DefineCommand(
 41:  *      command     = 'cmdhandlers',
 42:  *      accessLevel = 'admin',
 43:  *      description = "Show command handlers for a command",
 44:  *      help        = 'cmdhandlers.txt'
 45:  *  )
 46:  *  @DefineCommand(
 47:  *      command     = 'createblob',
 48:  *      accessLevel = 'admin',
 49:  *      description = "Creates a blob of random characters",
 50:  *      help        = 'createblob.txt'
 51:  *  )
 52:  *  @DefineCommand(
 53:  *      command     = 'makeitem',
 54:  *      accessLevel = 'admin',
 55:  *      description = "Creates an item link",
 56:  *      help        = 'makeitem.txt'
 57:  *  )
 58:  */
 59: class DevController extends AutoInject {
 60: 
 61:     /**
 62:      * Name of the module.
 63:      * Set automatically by module loader.
 64:      */
 65:     public $moduleName;
 66: 
 67:     /**
 68:      * @Setup
 69:      */
 70:     public function setup() {
 71:         $this->commandAlias->register($this->moduleName, "querysql select", "select");
 72:     }
 73:     
 74:     /**
 75:      * @HandlesCommand("showcmdregex")
 76:      * @Matches("/^showcmdregex (.+)$/i")
 77:      */
 78:     public function showcmdregexCommand($message, $channel, $sender, $sendto, $args) {
 79:         $cmd = $args[1];
 80:         
 81:         // get all command handlers
 82:         $handlers = $this->getAllCommandHandlers($cmd, $channel);
 83:         
 84:         // filter command handlers by access level
 85:         $accessManager = $this->accessManager;
 86:         $handlers = array_filter($handlers, function ($handler) use ($sender, $accessManager) {
 87:             return $accessManager->checkAccess($sender, $handler->admin);
 88:         });
 89:         
 90:         // get calls for handlers
 91:         $calls = array_reduce($handlers, function ($handlers, $handler) {
 92:             return array_merge($handlers, explode(',', $handler->file));
 93:         }, array());
 94: 
 95:         // get regexes for calls
 96:         $regexes = array();
 97:         forEach ($calls as $call) {
 98:             list($name, $method) = explode(".", $call);
 99:             $instance = Registry::getInstance($name);
100:             try {
101:                 $reflectedMethod = new ReflectionAnnotatedMethod($instance, $method);
102:                 $regexes = array_merge($regexes, $this->commandManager->retrieveRegexes($reflectedMethod));
103:             } catch (ReflectionException $e) {
104:                 continue;
105:             }
106:         }
107: 
108:         $count = count($regexes);
109:         if ($count > 0) {
110:             $blob = '';
111:             forEach ($regexes as $regex) {
112:                 $blob .= $regex . "\n";
113:             }
114:             $msg = $this->text->makeBlob("Regexes for $cmd ($count)", $blob);
115:         } else {
116:             $msg = "No regexes found for command <highlight>$cmd<end>.";
117:         }
118:         $sendto->reply($msg);
119:     }
120:     
121:     public function getAllCommandHandlers($cmd, $channel) {
122:         $handlers = array();
123:         if (isset($this->commandManager->commands[$channel][$cmd])) {
124:             $handlers []= $this->commandManager->commands[$channel][$cmd];
125:         }
126:         if (isset($this->subcommandManager->subcommands[$cmd])) {
127:             forEach ($this->subcommandManager->subcommands[$cmd] as $handler) {
128:                 if ($handler->type == $channel) {
129:                     $handlers []= $handler;
130:                 }
131:             }
132:         }
133:         return $handlers;
134:     }
135:     
136:     /**
137:      * @HandlesCommand("intransaction")
138:      * @Matches("/^intransaction$/i")
139:      */
140:     public function intransactionCommand($message, $channel, $sender, $sendto, $args) {
141:         if ($this->db->inTransaction()) {
142:             $msg = "There is an active transaction.";
143:         } else {
144:             $msg = "There is no active transaction.";
145:         }
146:         $sendto->reply($msg);
147:     }
148:     
149:     /**
150:      * @HandlesCommand("rollbacktransaction")
151:      * @Matches("/^rollbacktransaction$/i")
152:      */
153:     public function rollbacktransactionCommand($message, $channel, $sender, $sendto, $args) {
154:         $this->db->rollback();
155:         
156:         $msg = "The active transaction has been rolled back.";
157:         $sendto->reply($msg);
158:     }
159:     
160:     /**
161:      * @HandlesCommand("stacktrace")
162:      * @Matches("/^stacktrace$/i")
163:      */
164:     public function stacktraceCommand($message, $channel, $sender, $sendto, $args) {
165:         $stacktrace = $this->util->getStackTrace();
166:         $count = substr_count($stacktrace, "\n");
167:         $msg = $this->text->makeBlob("Current Stacktrace ($count)", $stacktrace);
168:         $sendto->reply($msg);
169:     }
170:     
171:     /**
172:      * @HandlesCommand("cmdhandlers")
173:      * @Matches("/^cmdhandlers (.*)$/i")
174:      */
175:     public function cmdhandlersCommand($message, $channel, $sender, $sendto, $args) {
176:         $cmdArray = explode(" ", $args[1], 2);
177:         $cmd = $cmdArray[0];
178:         
179:         $blob = '';
180: 
181:         // command
182:         forEach ($this->commandManager->commands as $channelName => $channel) {
183:             if (isset($channel[$cmd])) {
184:                 $blob .= "<header2>$channelName ($cmd)<end>\n";
185:                 $blob .= $channel[$cmd]->file . "\n\n";
186:             }
187:         }
188: 
189:         // subcommand
190:         forEach ($this->subcommandManager->subcommands[$cmd] as $row) {
191:             $blob .= "<header2>$row->type ($row->cmd)<end>\n";
192:             $blob .= $row->file . "\n\n";
193:         }
194: 
195:         $msg = $this->text->makeBlob("Command Handlers for '$cmd'", $blob);
196:         
197:         $sendto->reply($msg);
198:     }
199: 
200:     /**
201:      * @HandlesCommand("makeitem")
202:      * @Matches("/^makeitem (\d+) (\d+) (\d+) (.+)$/i")
203:      */
204:     public function makeitemCommand($message, $channel, $sender, $sendto, $args) {
205:         $lowId = $args[1];
206:         $highId = $args[2];
207:         $ql = $args[3];
208:         $name = $args[4];
209:         $sendto->reply($this->text->makeItem($lowId, $highId, $ql, $name));
210:     }
211:     
212:     /**
213:      * @HandlesCommand("createblob")
214:      * @Matches("/^createblob (\d+)$/i")
215:      * @Matches("/^createblob (\d+) (\d+)$/i")
216:      */
217:     public function createblobCommand($message, $channel, $sender, $sendto, $args) {
218:         $length = $args[1];
219:         if (isset($args[2])) {
220:             $numBlobs = $args[2];
221:         } else {
222:             $numBlobs = 1;
223:         }
224:         
225:         for ($i = 0; $i < $numBlobs; $i++) {
226:             $blob = $this->randString($length);
227:             $msg = $this->text->makeBlob("Blob $i", $blob);
228:             $sendto->reply($msg);
229:         }
230:     }
231:     
232:     public function randString($length, $charset='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 \n') {
233:         $str = '';
234:         $count = strlen($charset);
235:         while ($length--) {
236:             $str .= $charset[mt_rand(0, $count-1)];
237:         }
238:         return $str;
239:     }
240: }
241: 
Budabot 4 Docs API documentation generated by ApiGen