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:  * Authors: 
  7:  *  - Tyrence (RK2)
  8:  *
  9:  * @Instance
 10:  *
 11:  * Commands this controller contains:
 12: *   @DefineCommand(
 13:  *      command     = 'buddylist',
 14:  *      accessLevel = 'admin', 
 15:  *      description = 'Shows and manages buddies on the buddylist', 
 16:  *      help        = 'buddylist.txt',
 17:  *      alias       = 'friendlist'
 18:  *  )
 19:  */
 20: class BuddylistController {
 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 $buddylistManager;
 33: 
 34:     /** @Inject */
 35:     public $text;
 36:     
 37:     /**
 38:      * @HandlesCommand("buddylist")
 39:      * @Matches("/^buddylist$/i")
 40:      * @Matches("/^buddylist (clean)$/i")
 41:      */
 42:     public function buddylistShowCommand($message, $channel, $sender, $sendto, $args) {
 43:         if (count($args) == 2) {
 44:             $cleanup = true;
 45:         }
 46: 
 47:         $orphanCount = 0;
 48:         if (count($this->buddylistManager->buddyList) == 0) {
 49:             $msg = "There are no players on the buddy list.";
 50:         } else {
 51:             $count = 0;
 52:             forEach ($this->getSortedBuddyList() as $value) {
 53:                 if (!isset($value['name'])) {
 54:                     // skip the characters that have been added but the server hasn't sent back an update yet
 55:                     continue;
 56:                 }
 57: 
 58:                 $count++;
 59:                 $removed = '';
 60:                 if (count($value['types']) == 0) {
 61:                     $orphanCount++;
 62:                     if ($cleanup) {
 63:                         $this->buddylistManager->remove($value['name']);
 64:                         $removed = "<red>REMOVED<end>";
 65:                         
 66:                         // don't count removed characters
 67:                         $count--;
 68:                     }
 69:                 }
 70: 
 71:                 $blob .= $value['name'] . " $removed " . implode(' ', array_keys($value['types'])) . "\n";
 72:             }
 73: 
 74:             if ($cleanup) {
 75:                 $blob .="\n\nRemoved: ($orphanCount)";
 76:             } else {
 77:                 $blob .= "\n\nUnknown: ($orphanCount) ";
 78:                 if ($orphanCount > 0) {
 79:                     $blob .= $this->text->makeChatcmd('Remove Orphans', '/tell <myname> <symbol>buddylist clean');
 80:                 }
 81:             }
 82: 
 83:             if ($cleanup) {
 84:                 $sendto->reply("Removed $orphanCount characters from the buddy list.");
 85:             }
 86:             $msg = $this->text->makeBlob("Buddy list ($count)", $blob);
 87:         }
 88:         $sendto->reply($msg);
 89:     }
 90:     
 91:     /**
 92:      * @HandlesCommand("buddylist")
 93:      * @Matches("/^buddylist add (.+) (.+)$/i")
 94:      */
 95:     public function buddylistAddCommand($message, $channel, $sender, $sendto, $args) {
 96:         $name = ucfirst(strtolower($args[1]));
 97:         $type = $args[2];
 98: 
 99:         if ($this->buddylistManager->add($name, $type)) {
100:             $msg = "<highlight>$name<end> added to the buddy list successfully.";
101:         } else {
102:             $msg = "Could not add <highlight>$name<end> to the buddy list.";
103:         }
104: 
105:         $sendto->reply($msg);
106:     }
107:     
108:     /**
109:      * @HandlesCommand("buddylist")
110:      * @Matches("/^buddylist rem all$/i")
111:      */
112:     public function buddylistRemAllCommand($message, $channel, $sender, $sendto, $args) {
113:         forEach ($this->buddylistManager->buddyList as $uid => $buddy) {
114:             $this->chatBot->buddy_remove($uid);
115:         }
116: 
117:         $msg = "All characters have been removed from the buddy list.";
118:         $sendto->reply($msg);
119:     }
120: 
121:     /**
122:      * @HandlesCommand("buddylist")
123:      * @Matches("/^buddylist rem (.+) (.+)$/i")
124:      */
125:     public function buddylistRemCommand($message, $channel, $sender, $sendto, $args) {
126:         $name = ucfirst(strtolower($args[1]));
127:         $type = $args[2];
128: 
129:         if ($this->buddylistManager->remove($name, $type)) {
130:             $msg = "<highlight>$name<end> removed from the buddy list successfully.";
131:         } else {
132:             $msg = "Could not remove <highlight>$name<end> from the buddy list.";
133:         }
134: 
135:         $sendto->reply($msg);
136:     }
137: 
138:     /**
139:      * @HandlesCommand("buddylist")
140:      * @Matches("/^buddylist search (.*)$/i")
141:      */
142:     public function buddylistSearchCommand($message, $channel, $sender, $sendto, $args) {
143:         $search = $args[1];
144: 
145:         if (count($this->buddylistManager->buddyList) == 0) {
146:             $msg = "There are no characters on the buddy list.";
147:         } else {
148:             $count = 0;
149:             $blob = "Buddy list Search: '{$search}'\n\n";
150:             forEach ($this->getSortedBuddyList() as $value) {
151:                 $removed = '';
152:                 if (preg_match("/$search/i", $value['name'])) {
153:                     $count++;
154:                     $blob .= $value['name'] . " " . implode(' ', array_keys($value['types'])) . "\n";
155:                 }
156:             }
157: 
158:             if ($count > 0) {
159:                 $msg = $this->text->makeBlob("Buddy List Search ($count)", $blob);
160:             } else {
161:                 $msg = "No characters on the buddy list found containing '$search'";
162:             }
163:         }
164:         $sendto->reply($msg);
165:     }
166: 
167:     public function getSortedBuddyList() {
168:         $buddylist = $this->buddylistManager->buddyList;
169:         usort($buddylist, function ($entry1, $entry2) {
170:             return $entry1['name'] > $entry2['name'];
171:         });
172:         return $buddylist;
173:     }
174: }
175: 
Budabot 4 Docs API documentation generated by ApiGen