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:  *
  9:  * Originally Written for Budabot By Jaqueme
 10:  * Database Adapted From One Originally Compiled by Wolfbiter For BeBot
 11:  *
 12:  * @Instance
 13:  *
 14:  * Commands this controller contains:
 15:  *  @DefineCommand(
 16:  *      command     = 'spirits', 
 17:  *      accessLevel = 'all', 
 18:  *      description = 'Search for spirits', 
 19:  *      help        = 'spirits.txt'
 20:  *  )
 21:  */
 22: class SpiritsController {
 23: 
 24:     /**
 25:      * Name of the module.
 26:      * Set automatically by module loader.
 27:      */
 28:     public $moduleName;
 29:     
 30:     /** @Inject */
 31:     public $db;
 32:     
 33:     /** @Inject */
 34:     public $text;
 35:     
 36:     /**
 37:      * @Setup
 38:      */
 39:     public function setup() {
 40:         $this->db->loadSQLFile($this->moduleName, 'spirits');
 41:     }
 42: 
 43:     /**
 44:      * @HandlesCommand("spirits")
 45:      * @Matches("/^spirits (.+)$/i")
 46:      */
 47:     public function spiritsCommand($message, $channel, $sender, $sendto, $args) {
 48:         if (preg_match("/^spirits ([^0-9,]+)$/i", $message, $arr)) {
 49:             $name = $arr[1];
 50:             $name = ucwords(strtolower($name));
 51:             $title = "Spirits Database for $name";
 52:             $data = $this->db->query("SELECT * FROM spiritsdb WHERE name LIKE ? OR spot LIKE ? ORDER BY level", '%'.$name.'%', '%'.$name.'%');
 53:             if (count($data) == 0) {
 54:                 $spirits .= "There were no matches found for $name.\nTry putting a comma between search values.\n\n";
 55:                 $spirits .= $this->getValidSlotTypes();
 56:             } else {
 57:                 $spirits .= $this->formatSpiritOutput($data);
 58:             }
 59:         }
 60:             //If searched by name and slot
 61:         else if (preg_match("/^spirits ([^0-9]+),([^0-9]+)$/i", $message, $arr)) {
 62:             if (preg_match("/(chest|ear|eye|feet|head|larm|legs|lhand|lwrist|rarm|rhand|rwrist|waist)/i", $arr[1])) {
 63:                 $slot = $arr[1];
 64:                 $name = $arr[2];
 65:                 $title = "Spirits Database for $name $slot";
 66:             } else if (preg_match("/(chest|ear|eye|feet|head|larm|legs|lhand|lwrist|rarm|rhand|rwrist|waist)/i", $arr[2])) {
 67:                 $name = $arr[1];
 68:                 $slot = $arr[2];
 69:                 $title = "Spirits Database for $name $slot";
 70:             } else {
 71:                 $spirits .= "No matches were found for $name $slot\n\n";
 72:                 $spirits .= $this->getValidSlotTypes();
 73:             }
 74:             $name = ucwords(strtolower($name));
 75:             $name = trim($name);
 76:             $slot = ucwords(strtolower($slot));
 77:             $slot = trim($slot);
 78:             $data = $this->db->query("SELECT * FROM spiritsdb WHERE name LIKE ? AND spot = ? ORDER BY level", '%'.$name.'%', $slot);
 79:             $spirits .= $this->formatSpiritOutput($data);
 80:         }
 81:             // If searched by ql
 82:         else if (preg_match("/^spirits ([0-9]+)$/i", $message, $arr)) {
 83:             $ql = $arr[1];
 84:             if ($ql <= 1 OR $ql >= 300) {
 85:                 $msg = "Invalid Ql specified.";
 86:                 $sendto->reply($msg);
 87:                 return;
 88:             }
 89:             $title = "Spirits QL $ql";
 90:             $data = $this->db->query("SELECT * FROM spiritsdb where ql = ? ORDER BY ql", $ql);
 91:             $spirits .= $this->formatSpiritOutput($data);
 92:         }
 93:             // If searched by ql range
 94:         else if (preg_match("/^spirits ([0-9]+)-([0-9]+)$/i", $message, $arr)) {
 95:             $qllorange = $arr[1];
 96:             $qlhirange = $arr[2];
 97:             if ($qllorange < 1 OR $qlhirange > 219 OR $qllorange >= $qlhirange) {
 98:                 $msg = "Invalid Ql range specified.";
 99:                 $sendto->reply($msg);
100:                 return;
101:             }
102:             $title = "Spirits QL $qllorange to $qlhirange";
103:             $data = $this->db->query("SELECT * FROM spiritsdb where ql >= ? AND ql <= ? ORDER BY ql", $qllorange, $qlhirange);
104:             $spirits .= $this->formatSpiritOutput($data);
105:         }
106:             // If searched by ql and slot
107:         else if (preg_match("/^spirits ([0-9]+) (.+)$/i", $message, $arr)) {
108:             $ql = $arr[1];
109:             $slot = ucwords(strtolower($arr[2]));
110:             $title = "$slot Spirits QL $ql";
111:             if ($ql < 1 OR $ql > 300) {
112:                 $msg = "Invalid Ql specified.";
113:                 $sendto->reply($msg);
114:                 return;
115:             } else if (preg_match("/[^chest|ear|eye|feet|head|larm|legs|lhand|lwrist|rarm|rhand|rwrist|waist]/i", $slot)) {
116:                 $spirits .= "Invalid Input\n\n";
117:                 $spirits .= $this->getValidSlotTypes();
118:             } else {
119:                 $data = $this->db->query("SELECT * FROM spiritsdb where spot = ? AND ql = ? ORDER BY ql", $slot, $ql);
120:                 $spirits .= $this->formatSpiritOutput($data);
121:             }
122:         }
123:             // If searched by ql range and slot
124:         else if (preg_match("/^spirits ([0-9]+)-([0-9]+) (.+)$/i", $message, $arr)) {
125:             $qllorange = $arr[1];
126:             $qlhirange = $arr[2];
127:             $slot = ucwords(strtolower($arr[3]));
128:             $title = "$slot Spirits QL $qllorange to $qlhirange";
129:             if ($qllorange < 1 OR $qlhirange > 300 OR $qllorange >= $qlhirange) {
130:                 $msg = "Invalid Ql range specified.";
131:                 $sendto->reply($msg);
132:                 return;
133:             } else if (preg_match("/[^chest|ear|eye|feet|head|larm|legs|lhand|lwrist|rarm|rhand|rwrist|waist]/i", $slot)) {
134:                 $spirits .= "Invalid Input\n\n";
135:                 $spirits .= $this->getValidSlotTypes();
136:             } else {
137:                 $data = $this->db->query("SELECT * FROM spiritsdb where spot = ? AND ql >= ? AND ql <= ? ORDER BY ql", $slot, $qllorange, $qlhirange);
138:                 $spirits .= $this->formatSpiritOutput($data);
139:             }
140:         }
141:         if ($spirits) {
142:             $spirits = $this->text->makeBlob("Spirits", $spirits, $title);
143:             $sendto->reply($spirits);
144:         } else {
145:             return false;
146:         }
147:     }
148: 
149:     public function formatSpiritOutput($data) {
150:         if (count($data) == 0) {
151:             return "No matches found.";
152:         }
153: 
154:         $msg = '';
155:         forEach ($data as $row) {
156:             $slot = $row->spot;
157:             $lvl = $row->level;
158:             $lowid = $row->id;
159:             $agi = $row->agility;
160: 
161:             $data2 = $this->db->query("SELECT * FROM aodb WHERE lowid = ?", $lowid);
162:             forEach ($data2 as $row); {
163:                 $highid = $row->highid;
164:                 $icon = $row->icon;
165:                 $name = $row->name;
166:                 $ql = $row->highql;
167:             }
168:             $msg .= $this->text->makeImage($icon) . ' ';
169:             $msg .= $this->text->makeItem($lowid, $highid, $ql, $name) . "\n";
170:             $msg .= "Minimum Level=$lvl   Slot=$slot   Agility/Sense Needed=$agi\n\n";
171:         }
172:         return $msg;
173:     }
174: 
175:     public function getValidSlotTypes() {
176:         $output = "Valid slot types are:\n";
177:         $output .= "Head\n";
178:         $output .= "Eye\n";
179:         $output .= "Ear\n";
180:         $output .= "Chest\n";
181:         $output .= "Larm\n";
182:         $output .= "Rarm\n";
183:         $output .= "Waist\n";
184:         $output .= "Lwrist\n";
185:         $output .= "Rwrist\n";
186:         $output .= "Legs\n";
187:         $output .= "Lhand\n";
188:         $output .= "Rhand\n";
189:         $output .= "Feet\n";
190: 
191:         return $output;
192:     }
193: }
194: 
Budabot 4 Docs API documentation generated by ApiGen