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: use stdClass;
  6: 
  7: /**
  8:  * Authors: 
  9:  *  - Tyrence (RK2)
 10:  *
 11:  * @Instance
 12:  *
 13:  * Commands this controller contains:
 14:  *  @DefineCommand(
 15:  *      command     = 'whompah',
 16:  *      accessLevel = 'all', 
 17:  *      description = 'Shows the whompah route from one city to another', 
 18:  *      help        = 'whompah.txt'
 19:  *  )
 20:  */
 21: class WhompahController {
 22: 
 23:     /**
 24:      * Name of the module.
 25:      * Set automatically by module loader.
 26:      */
 27:     public $moduleName;
 28:     
 29:     /** @Inject */
 30:     public $db;
 31:     
 32:     /** @Inject */
 33:     public $text;
 34:     
 35:     /** @Inject */
 36:     public $commandAlias;
 37:     
 38:     /**
 39:      * This handler is called on bot startup.
 40:      * @Setup
 41:      */
 42:     public function setup() {
 43:         $this->db->loadSQLFile($this->moduleName, 'whompah_cities');
 44:         
 45:         $this->commandAlias->register($this->moduleName, 'whompah', 'whompahs');
 46:         $this->commandAlias->register($this->moduleName, 'whompah', 'whompa');
 47:         $this->commandAlias->register($this->moduleName, 'whompah', 'whompas');
 48:     }
 49:     
 50:     /**
 51:      * @HandlesCommand("whompah")
 52:      * @Matches("/^whompah$/i")
 53:      */
 54:     public function whompahListCommand($message, $channel, $sender, $sendto, $args) {
 55:         $sql = "SELECT * FROM `whompah_cities` ORDER BY city_name ASC";
 56:         $data = $this->db->query($sql);
 57: 
 58:         $blob = '';
 59:         forEach ($data as $row) {
 60:             $cityLink = $this->text->makeChatcmd($row->short_name, "/tell <myname> whompah {$row->short_name}");
 61:             $blob .= "{$row->city_name} ({$cityLink})\n";
 62:         }
 63:         $blob .= "\nWritten By Tyrence (RK2)\nDatabase from a Bebot module written by POD13";
 64: 
 65:         $msg = $this->text->makeBlob('Whompah Cities', $blob);
 66: 
 67:         $sendto->reply($msg);
 68:     }
 69: 
 70:     /**
 71:      * @HandlesCommand("whompah")
 72:      * @Matches("/^whompah (.+) (.+)$/i")
 73:      */
 74:     public function whompahTravelCommand($message, $channel, $sender, $sendto, $args) {
 75:         $startCity = $this->findCity($args[1]);
 76:         $endCity = $this->findCity($args[2]);
 77: 
 78:         if ($startCity === null) {
 79:             $msg = "Error! Could not find city '$args[1]'!";
 80:             $sendto->reply($msg);
 81:             return;
 82:         }
 83:         if ($endCity === null) {
 84:             $msg = "Error! Could not find city '$args[2]'!";
 85:             $sendto->reply($msg);
 86:             return;
 87:         }
 88: 
 89:         $whompahs = $this->buildWhompahNetwork();
 90: 
 91:         $whompah = new stdClass;
 92:         $whompah->id = $endCity->id;
 93:         $whompah->city_name = $whompahs[$endCity->id]->city_name;
 94:         $whompah->previous = null;
 95:         $whompah->visited = true;
 96:         $obj = $this->findWhompahPath($q = array($whompah), $whompahs, $startCity->id);
 97: 
 98:         if ($obj === false) {
 99:             $msg = "There was an error while trying to find the whompah path.";
100:         } else {
101:             while ($obj->previous !== null) {
102:                 $msg .= "$obj->city_name -> ";
103:                 $obj = $obj->previous;
104:             }
105:             $msg .= "$obj->city_name";
106:         }
107: 
108:         $sendto->reply($msg);
109:     }
110:     
111:     /**
112:      * @HandlesCommand("whompah")
113:      * @Matches("/^whompah (.+)$/i")
114:      */
115:     public function whompahDestinationsCommand($message, $channel, $sender, $sendto, $args) {
116:         $city = $this->findCity($args[1]);
117: 
118:         if ($city === null) {
119:             $msg = "Error! Could not find city '$args[1]'!";
120:             $sendto->reply($msg);
121:             return;
122:         }
123: 
124:         $sql = "SELECT w2.* FROM whompah_cities_rel w1 JOIN whompah_cities w2 ON w1.city2_id = w2.id WHERE w1.city1_id = ?";
125:         $data = $this->db->query($sql, $city->id);
126: 
127:         $msg = "From {$city->city_name} you can get to: " .
128:             implode(", ", array_map(function($row) { return "<highlight>{$row->city_name}<end> ({$row->short_name})"; }, $data));
129: 
130:         $sendto->reply($msg);
131:     }
132: 
133:     public function findWhompahPath($queue, $whompahs, $endCity) {
134:         $currentWhompah = array_shift($queue);
135: 
136:         if ($currentWhompah == false) {
137:             return false;
138:         }
139: 
140:         if ($currentWhompah->id == $endCity) {
141:             return $currentWhompah;
142:         }
143: 
144:         forEach ($whompahs[$currentWhompah->id]->connections as $city2Id) {
145:             if ($whompahs[$city2Id]->visited !== true) {
146:                 $whompahs[$city2Id]->visited = true;
147:                 $nextWhompah = new stdClass;
148:                 $nextWhompah->id = $city2Id;
149:                 $nextWhompah->city_name = $whompahs[$city2Id]->city_name;
150:                 $nextWhompah->previous = $currentWhompah;
151:                 $queue []= $nextWhompah;
152:             }
153:         }
154: 
155:         return $this->findWhompahPath($queue, $whompahs, $endCity);
156:     }
157: 
158:     public function findCity($search) {
159:         $sql = "SELECT * FROM whompah_cities WHERE city_name LIKE ? OR short_name LIKE ?";
160:         return $this->db->queryRow($sql, $search, $search);
161:     }
162: 
163:     public function buildWhompahNetwork() {
164:         $whompahs = array();
165: 
166:         $sql = "SELECT * FROM `whompah_cities`";
167:         $data = $this->db->query($sql);
168:         forEach ($data as $row) {
169:             $whompahs[$row->id] = $row;
170:             $whompahs[$row->id]->connections = array();
171:             $whompahs[$row->id]->visited = false;
172:         }
173: 
174:         $sql = "SELECT city1_id, city2_id FROM whompah_cities_rel";
175:         $data = $this->db->query($sql);
176:         forEach ($data as $row) {
177:             $whompahs[$row->city1_id]->connections[] = $row->city2_id;
178:         }
179: 
180:         return $whompahs;
181:     }
182: }
183: 
Budabot 4 Docs API documentation generated by ApiGen