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: /**
  6:  * @Instance
  7:  *
  8:  * Commands this controller contains:
  9:  *  @DefineCommand(
 10:  *      command       = 'adminlist',
 11:  *      accessLevel   = 'all',
 12:  *      description   = 'Shows the list of administrators and moderators',
 13:  *      help          = 'adminlist.txt',
 14:  *      alias         = 'admins',
 15:  *      defaultStatus = '1'
 16:  *  )
 17:  *  @DefineCommand(
 18:  *      command       = 'admin',
 19:  *      accessLevel   = 'superadmin',
 20:  *      description   = 'Add or remove an administrator',
 21:  *      help          = 'admin.txt',
 22:  *      defaultStatus = '1'
 23:  *  )
 24:  *  @DefineCommand(
 25:  *      command       = 'mod',
 26:  *      accessLevel   = 'admin',
 27:  *      description   = 'Add or remove a moderator',
 28:  *      help          = 'mod.txt',
 29:  *      defaultStatus = '1'
 30:  *  )
 31:  */
 32: class AdminController {
 33: 
 34:     /**
 35:      * Name of the module.
 36:      * Set automatically by module loader.
 37:      */
 38:     public $moduleName;
 39: 
 40:     /** @Inject */
 41:     public $adminManager;
 42:     
 43:     /** @Inject */
 44:     public $chatBot;
 45:     
 46:     /** @Inject */
 47:     public $buddylistManager;
 48:     
 49:     /** @Inject */
 50:     public $accessManager;
 51: 
 52:     /** @Inject */
 53:     public $commandAlias;
 54:     
 55:     /** @Inject */
 56:     public $text;
 57:     
 58:     /** @Inject */
 59:     public $db;
 60:     
 61:     /** @Inject */
 62:     public $settingManager;
 63:     
 64:     /** @Inject */
 65:     public $altsController;
 66: 
 67:     /**
 68:      * @Setup
 69:      * This handler is called on bot startup.
 70:      */
 71:     public function setup() {
 72:         $this->adminManager->uploadAdmins();
 73: 
 74:         $this->commandAlias->register($this->moduleName, "admin add", "addadmin");
 75:         $this->commandAlias->register($this->moduleName, "admin rem", "remadmin");
 76:         $this->commandAlias->register($this->moduleName, "mod add", "addmod");
 77:         $this->commandAlias->register($this->moduleName, "mod rem", "remmod");
 78:     }
 79:     
 80:     /**
 81:      * @HandlesCommand("admin")
 82:      * @Matches("/^admin add (.+)$/i")
 83:      */
 84:     public function adminAddCommand($message, $channel, $sender, $sendto, $args) {
 85:         $who = ucfirst(strtolower($args[1]));
 86:         $intlevel = 4;
 87:         $rank = 'an administrator';
 88: 
 89:         $this->add($who, $sender, $sendto, $intlevel, $rank);
 90:     }
 91:     
 92:     /**
 93:      * @HandlesCommand("mod")
 94:      * @Matches("/^mod add (.+)$/i")
 95:      */
 96:     public function modAddCommand($message, $channel, $sender, $sendto, $args) {
 97:         $who = ucfirst(strtolower($args[1]));
 98:         $intlevel = 3;
 99:         $rank = 'a moderator';
100: 
101:         $this->add($who, $sender, $sendto, $intlevel, $rank);
102:     }
103:     
104:     /**
105:      * @HandlesCommand("admin")
106:      * @Matches("/^admin rem (.+)$/i")
107:      */
108:     public function adminRemoveCommand($message, $channel, $sender, $sendto, $args) {
109:         $who = ucfirst(strtolower($args[1]));
110:         $intlevel = 4;
111:         $rank = 'an administrator';
112: 
113:         $this->remove($who, $sender, $sendto, $intlevel, $rank);
114:     }
115:     
116:     /**
117:      * @HandlesCommand("mod")
118:      * @Matches("/^mod rem (.+)$/i")
119:      */
120:     public function modRemoveCommand($message, $channel, $sender, $sendto, $args) {
121:         $who = ucfirst(strtolower($args[1]));
122:         $intlevel = 3;
123:         $rank = 'a moderator';
124: 
125:         $this->remove($who, $sender, $sendto, $intlevel, $rank);
126:     }
127:     
128:     /**
129:      * @HandlesCommand("adminlist")
130:      * @Matches("/^adminlist$/i")
131:      * @Matches("/^adminlist all$/i")
132:      */
133:     public function adminlistCommand($message, $channel, $sender, $sendto) {
134:         if (strtolower($message) == "adminlist all") {
135:             $showOfflineAlts = true;
136:         } else {
137:             $showOfflineAlts = false;
138:         }
139: 
140:         $blob .= "<header2>Administrators<end>\n";
141:         forEach ($this->adminManager->admins as $who => $data) {
142:             if ($this->adminManager->admins[$who]["level"] == 4) {
143:                 if ($who != "") {
144:                     $blob .= "<tab>$who";
145:                     if ($this->accessManager->checkAccess($who, 'superadmin')) {
146:                         $blob .= " (<highlight>Super-administrator<end>) ";
147:                     }
148:                     $blob .= $this->getOnlineStatus($who) . "\n" . $this->getAltAdminInfo($who, $showOfflineAlts);
149:                 }
150:             }
151:         }
152: 
153:         $blob .= "<header2>Moderators<end>\n";
154:         forEach ($this->adminManager->admins as $who => $data){
155:             if ($this->adminManager->admins[$who]["level"] == 3){
156:                 if ($who != "") {
157:                     $blob .= "<tab>$who" . $this->getOnlineStatus($who) . "\n" . $this->getAltAdminInfo($who, $showOfflineAlts);
158:                 }
159:             }
160:         }
161: 
162:         $link = $this->text->makeBlob('Bot administrators', $blob);
163:         $sendto->reply($link);
164:     }
165:     
166:     /**
167:      * @Event("connect")
168:      * @Description("Add administrators and moderators to the buddy list")
169:      * @DefaultStatus("1")
170:      */
171:     public function checkAdminsEvent($eventObj) {
172:         $data = $this->db->query("SELECT * FROM admin_<myname>");
173:         forEach ($data as $row) {
174:             $this->buddylistManager->add($row->name, 'admin');
175:         }
176:     }
177:     
178:     private function getOnlineStatus($who) {
179:         if ($this->buddylistManager->isOnline($who) == 1 && isset($this->chatBot->chatlist[$who])) {
180:             return " (<green>Online and in chat<end>)";
181:         } else if ($this->buddylistManager->isOnline($who) == 1) {
182:             return " (<green>Online<end>)";
183:         } else {
184:             return " (<red>Offline<end>)";
185:         }
186:     }
187:     
188:     private function getAltAdminInfo($who, $showOfflineAlts) {
189:         $blob = '';
190:         $altInfo = $this->altsController->getAltInfo($who);
191:         if ($altInfo->main == $who) {
192:             forEach ($altInfo->alts as $alt => $validated) {
193:                 if ($validated == 1 && ($showOfflineAlts || $this->buddylistManager->isOnline($alt))) {
194:                     $blob .= "<tab><tab>$alt" . $this->getOnlineStatus($alt) . "\n";
195:                 }
196:             }
197:         }
198:         return $blob;
199:     }
200:     
201:     public function add($who, $sender, $sendto, $intlevel, $rank) {
202:         if ($this->chatBot->get_uid($who) == null){
203:             $sendto->reply("Character <highlight>$who<end> does not exist.");
204:             return;
205:         }
206: 
207:         if ($this->adminManager->checkExisting($who, $intlevel)) {
208:             $sendto->reply("<highlight>$who<end> is already $rank.");
209:             return;
210:         }
211: 
212:         if (!$this->checkAccessLevel($sender, $who, $sendto)) {
213:             $sendto->reply("You must have a higher access level than <highlight>$who<end> in order to change his access level.");
214:             return;
215:         }
216: 
217:         if (!$this->checkAltsInheritAdmin($who)) {
218:             $msg = "<red>WARNING<end>: $who is not a main.  This command did NOT affect $who's access level and no action was performed.";
219:             $sendto->reply($msg);
220:             return;
221:         }
222: 
223:         $action = $this->adminManager->addToLists($who, $intlevel);
224: 
225:         $sendto->reply("<highlight>$who<end> has been $action to $rank.");
226:         $this->chatBot->sendTell("You have been $action to $rank by <highlight>$sender<end>.", $who);
227:     }
228:     
229:     public function remove($who, $sender, $sendto, $intlevel, $rank) {
230:         if (!$this->adminManager->checkExisting($who, $intlevel)) {
231:             $sendto->reply("<highlight>$who<end> is not $rank.");
232:             return;
233:         }
234: 
235:         if (!$this->checkAccessLevel($sender, $who, $sendto)) {
236:             $sendto->reply("You must have a higher access level than <highlight>$who<end> in order to change his access level.");
237:             return;
238:         }
239: 
240:         $this->adminManager->removeFromLists($who);
241: 
242:         if (!$this->checkAltsInheritAdmin($who)) {
243:             $msg = "<red>WARNING<end>: $who is not a main.  This command did NOT affect $who's access level.";
244:             $sendto->reply($msg);
245:         }
246: 
247:         $sendto->reply("<highlight>$who<end> has been removed as $rank.");
248:         $this->chatBot->sendTell("You have been removed as $rank by <highlight>$sender<end>.", $who);
249:     }
250:     
251:     public function checkAltsInheritAdmin($who) {
252:         $ai = $this->altsController->getAltInfo($who);
253:         if ($ai->main != $who) {
254:             return false;
255:         } else {
256:             return true;
257:         }
258:     }
259:     
260:     public function checkAccessLevel($actor, $actee) {
261:         $senderAccessLevel = $this->accessManager->getAccessLevelForCharacter($actor);
262:         $whoAccessLevel = $this->accessManager->getSingleAccessLevel($actee);
263:         if ($this->accessManager->compareAccessLevels($whoAccessLevel, $senderAccessLevel) >= 0) {
264:             return false;
265:         } else {
266:             return true;
267:         }
268:     }
269: }
270: 
Budabot 4 Docs API documentation generated by ApiGen