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\Core\Modules;
  4: 
  5: use stdClass;
  6: 
  7: /**
  8:  * @Instance
  9:  *
 10:  * Commands this controller contains:
 11:  *  @DefineCommand(
 12:  *      command       = 'alias',
 13:  *      accessLevel   = 'mod',
 14:  *      description   = 'Manage command aliases',
 15:  *      help          = 'alias.txt',
 16:  *      defaultStatus = '1'
 17:  *  )
 18:  */
 19: class AliasController {
 20: 
 21:     /** @Inject */
 22:     public $commandAlias;
 23: 
 24:     /** @Inject */
 25:     public $commandManager;
 26: 
 27:     /** @Inject */
 28:     public $text;
 29:     
 30:     /**
 31:      * @Setup
 32:      * This handler is called on bot startup.
 33:      */
 34:     public function setup() {
 35:         
 36:     }
 37: 
 38:     /**
 39:      * This command handler add a command alias.
 40:      *
 41:      * @HandlesCommand("alias")
 42:      * @Matches("/^alias add ([a-z0-9]+) (.+)/si")
 43:      */
 44:     public function aliasAddCommand($message, $channel, $sender, $sendto, $args) {
 45:         $alias = strtolower($args[1]);
 46:         $cmd = $args[2];
 47:     
 48:         $alias_obj = new stdClass;
 49:         $alias_obj->module = '';
 50:         $alias_obj->cmd = $cmd;
 51:         $alias_obj->alias = $alias;
 52:         $alias_obj->status = 1;
 53:     
 54:         $commands = $this->commandManager->get($alias);
 55:         $enabled = false;
 56:         forEach ($commands as $command) {
 57:             if ($command->status == 1) {
 58:                 $enabled = true;
 59:                 break;
 60:             }
 61:         }
 62:         $row = $this->commandAlias->get($alias);
 63:         if ($enabled) {
 64:             $msg = "Cannot add alias <highlight>{$alias}<end> since there is already an active command with that name.";
 65:         } else if ($row === null) {
 66:             $this->commandAlias->add($alias_obj);
 67:             $this->commandAlias->activate($cmd, $alias);
 68:             $msg = "Alias <highlight>{$alias}<end> for command <highlight>{$cmd}<end> added successfully.";
 69:         } else if ($row->status == 0 || ($row->status == 1 && $row->cmd == $cmd)) {
 70:             $this->commandAlias->update($alias_obj);
 71:             $this->commandAlias->activate($cmd, $alias);
 72:             $msg = "Alias <highlight>{$alias}<end> for command <highlight>{$cmd}<end> added successfully.";
 73:         } else if ($row->status == 1 && $row->cmd != $cmd) {
 74:             $msg = "Cannot add alias <highlight>{$alias}<end> since an alias with that name already exists.";
 75:         }
 76:         $sendto->reply($msg);
 77:     }
 78: 
 79:     /**
 80:      * This command handler list all aliases.
 81:      *
 82:      * @HandlesCommand("alias")
 83:      * @Matches("/^alias list$/i")
 84:      */
 85:     public function aliasListCommand($message, $channel, $sender, $sendto, $args) {
 86:         $paddingSize = 30;
 87:     
 88:         $a = $this->padRow("Alias", $paddingSize);
 89:         $blob = "<header2>{$a}Command<end>\n\n";
 90:         $count = 0;
 91:         forEach ($this->commandAlias->getEnabledAliases() as $alias) {
 92:             if ($count++ % 2 == 0) {
 93:                 $color = "white";
 94:             } else {
 95:                 $color = "highlight";
 96:             }
 97:             $removeLink = $this->text->makeChatcmd('Remove', "/tell <myname> alias rem {$alias->alias}");
 98:             $a = $this->padRow($alias->alias, $paddingSize);
 99:             $blob .= "<{$color}>{$a}{$alias->cmd}<end> $removeLink\n";
100:         }
101:     
102:         $msg = $this->text->makeBlob('Alias List', $blob);
103:         $sendto->reply($msg);
104:     }
105: 
106:     /**
107:      * This command handler remove a command alias.
108:      *
109:      * @HandlesCommand("alias")
110:      * @Matches("/^alias rem ([a-z0-9]+)/i")
111:      */
112:     public function aliasRemCommand($message, $channel, $sender, $sendto, $args) {
113:         $alias = strtolower($args[1]);
114:     
115:         $row = $this->commandAlias->get($alias);
116:         if ($row === null || $row->status != 1) {
117:             $msg = "Could not find alias <highlight>{$alias}<end>!";
118:         } else {
119:             $row->status = 0;
120:             $this->commandAlias->update($row);
121:             $this->commandAlias->deactivate($alias);
122:     
123:             $msg = "Alias <highlight>{$alias}<end> removed successfully.";
124:         }
125:         $sendto->reply($msg);
126:     }
127: 
128:     private function padRow($str, $size) {
129:         return str_pad($str, $size - strlen($str), ".");
130:     }
131: }
132: 
Budabot 4 Docs API documentation generated by ApiGen