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:  *  - Marebone (RK2)
  9:  *
 10:  * @Instance
 11:  *
 12:  * Commands this controller contains:
 13:  *  @DefineCommand(
 14:  *      command     = 'bank', 
 15:  *      accessLevel = 'guild', 
 16:  *      description = 'Browse and search the bank characters', 
 17:  *      help        = 'bank.txt'
 18:  *  )
 19:  *  @DefineCommand(
 20:  *      command     = 'bank update',
 21:  *      accessLevel = 'admin', 
 22:  *      description = 'Reloads the bank database from the AO Items Assistant file', 
 23:  *      help        = 'bank.txt',
 24:  *      alias       = 'updatebank'
 25:  *  )
 26:  */
 27: class BankController {
 28: 
 29:     /**
 30:      * Name of the module.
 31:      * Set automatically by module loader.
 32:      */
 33:     public $moduleName;
 34: 
 35:     /** @Inject */
 36:     public $db;
 37: 
 38:     /** @Inject */
 39:     public $text;
 40:     
 41:     /** @Inject */
 42:     public $util;
 43:     
 44:     /** @Inject */
 45:     public $settingManager;
 46:     
 47:     /**
 48:      * @Setup
 49:      */
 50:     public function setup() {
 51:         $this->db->loadSQLFile($this->moduleName, 'bank');
 52:         
 53:         $this->settingManager->add($this->moduleName, 'bank_file_location', 'Location of the AO Items Assistant csv dump file', 'edit', 'text', './modules/BANK_MODULE/import.csv');
 54:         $this->settingManager->add($this->moduleName, 'max_bank_items', 'Number of items shown in search results', 'edit', 'number', '50', '20;50;100');
 55:     }
 56: 
 57:     /**
 58:      * @HandlesCommand("bank")
 59:      * @Matches("/^bank browse$/i")
 60:      */
 61:     public function bankBrowseCommand($message, $channel, $sender, $sendto, $args) {
 62:         $blob = '';
 63:         $data = $this->db->query("SELECT DISTINCT player FROM bank ORDER BY player ASC");
 64:         forEach ($data as $row) {
 65:             $character_link = $this->text->makeChatcmd($row->player, "/tell <myname> bank browse {$row->player}");
 66:             $blob .= $character_link . "\n";
 67:         }
 68: 
 69:         $msg = $this->text->makeBlob('Bank Characters', $blob);
 70:         $sendto->reply($msg);
 71:     }
 72: 
 73:     /**
 74:      * @HandlesCommand("bank")
 75:      * @Matches("/^bank browse ([a-z0-9-]+)$/i")
 76:      */
 77:     public function bankBrowsePlayerCommand($message, $channel, $sender, $sendto, $args) {
 78:         $name = ucfirst(strtolower($args[1]));
 79: 
 80:         $blob = '';
 81:         $data = $this->db->query("SELECT DISTINCT container_id, container, player FROM bank WHERE player = ? ORDER BY container ASC", $name);
 82:         if (count($data) > 0) {
 83:             forEach ($data as $row) {
 84:                 $container_link = $this->text->makeChatcmd($row->container, "/tell <myname> bank browse {$row->player} {$row->container_id}");
 85:                 $blob .= "{$container_link}\n";
 86:             }
 87: 
 88:             $msg = $this->text->makeBlob("Containers for $name", $blob);
 89:         } else {
 90:             $msg = "Could not find bank character <highlight>$name<end>.";
 91:         }
 92:         $sendto->reply($msg);
 93:     }
 94: 
 95:     /**
 96:      * @HandlesCommand("bank")
 97:      * @Matches("/^bank browse ([a-z0-9-]+) (\d+)$/i")
 98:      */
 99:     public function bankBrowseContainerCommand($message, $channel, $sender, $sendto, $args) {
100:         $name = ucfirst(strtolower($args[1]));
101:         $containerId = $args[2];
102:         $limit = $this->settingManager->get('max_bank_items');
103: 
104:         $blob = '';
105:         $sql = "SELECT * FROM bank WHERE player = ? AND container_id = ? ORDER BY name ASC, ql ASC LIMIT ?";
106:         $data = $this->db->query($sql, $name, $containerId, intval($limit));
107: 
108:         if (count($data) > 0) {
109:             forEach ($data as $row) {
110:                 $item_link = $this->text->makeItem($row->lowid, $row->highid, $row->ql, $row->name);
111:                 $blob .= "{$item_link} ({$row->ql})\n";
112:             }
113: 
114:             $msg = $this->text->makeBlob("Contents of $row->container", $blob);
115:         } else {
116:             $msg = "Could not find container with id <highlight>{$containerId}</highlight> on bank character <highlight>{$name}<end>.";
117:         }
118:         $sendto->reply($msg);
119:     }
120: 
121:     /**
122:      * @HandlesCommand("bank")
123:      * @Matches("/^bank search (.+)$/i")
124:      */
125:     public function bankSearchCommand($message, $channel, $sender, $sendto, $args) {
126:         $search = htmlspecialchars_decode($args[1]);
127:         $words = explode(' ', $search);
128:         $limit = $this->settingManager->get('max_bank_items');
129:         
130:         list($where_sql, $params) = $this->util->generateQueryFromParams($words, 'name');
131:         array_push($params, intval($limit));
132: 
133:         $blob = '';
134:         $data = $this->db->query("SELECT * FROM bank WHERE {$where_sql} ORDER BY name ASC, ql ASC LIMIT ?", $params);
135: 
136:         if (count($data) > 0) {
137:             forEach ($data as $row) {
138:                 $item_link = $this->text->makeItem($row->lowid, $row->highid, $row->ql, $row->name);
139:                 $blob .= "{$item_link} ({$row->ql}) (<highlight>{$row->player}<end>, {$row->container})\n";
140:             }
141: 
142:             $msg = $this->text->makeBlob("Bank Search Results for {$args[1]}", $blob);
143:         } else {
144:             $msg = "Could not find any search results for <highlight>{$args[1]}<end>.";
145:         }
146:         $sendto->reply($msg);
147:     }
148: 
149:     /**
150:      * @HandlesCommand("bank update")
151:      * @Matches("/^bank update$/i")
152:      */
153:     public function bankUpdateCommand($message, $channel, $sender, $sendto, $args) {
154:         $lines = file($this->settingManager->get('bank_file_location'));
155: 
156:         if ($lines === false) {
157:             $msg = "Could not open file: '" . $this->settingManager->get('bank_file_location') . "'";
158:             $sendto->reply($msg);
159:             return;
160:         }
161: 
162:         //remove the header line
163:         array_shift($lines);
164: 
165:         $this->db->beginTransaction();
166:         $this->db->exec("DELETE FROM bank");
167: 
168:         forEach ($lines as $line) {
169:             // this is the order of columns in the CSV file (AOIA v1.1.3.0):
170:             // Item Name,QL,Character,Backpack,Location,LowID,HighID,ContainerID,Link
171:             list($name, $ql, $player, $container, $location, $lowId, $highId, $containerId) = str_getcsv($line);
172:             if ($location != 'Bank' && $location != 'Inventory') {
173:                 continue;
174:             }
175:             if ($container == '') {
176:                 $container = $location;
177:             }
178: 
179:             $sql = "INSERT INTO bank (name, lowid, highid, ql, player, container, container_id, location) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
180:             $this->db->exec($sql, $name, $lowId, $highId, $ql, $player, $container, $containerId, $location);
181:         }
182:         $this->db->commit();
183: 
184:         $msg = "The bank database has been updated.";
185:         $sendto->reply($msg);
186:     }
187: }
188: 
Budabot 4 Docs API documentation generated by ApiGen