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:  *  - Healnjoo (RK2)
  9:  *  - Mdkdoc420 (RK2)
 10:  *
 11:  * @Instance
 12:  *
 13:  * Commands this controller contains:
 14:  *  @DefineCommand(
 15:  *      command     = 'nano', 
 16:  *      accessLevel = 'all', 
 17:  *      description = 'Searches for a nano and tells you were to get it', 
 18:  *      help        = 'nano.txt'
 19:  *  )
 20:  *  @DefineCommand(
 21:  *      command     = 'nanolines', 
 22:  *      accessLevel = 'all', 
 23:  *      description = 'Shows nanos based on nanoline', 
 24:  *      help        = 'nanolines.txt',
 25:  *      alias       = 'nl'
 26:  *  )
 27:  *  @DefineCommand(
 28:  *      command     = 'nanoloc', 
 29:  *      accessLevel = 'all', 
 30:  *      description = 'Browse nanos by location', 
 31:  *      help        = 'nano.txt'
 32:  *  )
 33:  */
 34: class NanoController {
 35: 
 36:     /**
 37:      * Name of the module.
 38:      * Set automatically by module loader.
 39:      */
 40:     public $moduleName;
 41:     
 42:     /** @Inject */
 43:     public $db;
 44:     
 45:     /** @Inject */
 46:     public $settingManager;
 47:     
 48:     /** @Inject */
 49:     public $text;
 50:     
 51:     /** @Inject */
 52:     public $util;
 53:     
 54:     /**
 55:      * This handler is called on bot startup.
 56:      * @Setup
 57:      */
 58:     public function setup() {
 59:         $this->db->loadSQLFile($this->moduleName, 'nanos');
 60:         $this->db->loadSQLFile($this->moduleName, 'nanolines');
 61:         $this->db->loadSQLFile($this->moduleName, 'nanos_nanolines_ref');
 62:         
 63:         $this->settingManager->add($this->moduleName, 'maxnano', 'Number of Nanos shown on the list', 'edit', "number", '40', '30;40;50;60', "", "mod");
 64:         $this->settingManager->add($this->moduleName, "shownanolineicons", "Show icons for the nanolines", "edit", "options", "0", "true;false", "1;0");
 65:     }
 66: 
 67:     /**
 68:      * @HandlesCommand("nano")
 69:      * @Matches("/^nano (.+)$/i")
 70:      */
 71:     public function nanoCommand($message, $channel, $sender, $sendto, $args) {
 72:         $search = $args[1];
 73: 
 74:         $search = htmlspecialchars_decode($search);
 75:         $tmp = explode(" ", $search);
 76:         list($query, $params) = $this->util->generateQueryFromParams($tmp, 'n1.`name`');
 77:         array_push($params, intval($this->settingManager->get("maxnano")));
 78: 
 79:         $sql =
 80:             "SELECT
 81:                 n1.lowid,
 82:                 n1.lowql,
 83:                 n1.name,
 84:                 n1.location,
 85:                 n1.profession,
 86:                 n3.id AS nanoline_id,
 87:                 n3.name AS nanoline_name
 88:             FROM
 89:                 nanos n1
 90:                 LEFT JOIN nanos_nanolines_ref n2 ON n1.lowid = n2.lowid
 91:                 LEFT JOIN nanolines n3 ON n2.nanolines_id = n3.id
 92:             WHERE
 93:                 $query
 94:             ORDER BY
 95:                 n1.profession, n3.name, n1.lowql DESC, n1.name ASC
 96:             LIMIT
 97:                 ?";
 98: 
 99:         $data = $this->db->query($sql, $params);
100: 
101:         $count = count($data);
102:         if ($count == 0) {
103:             $msg = "No nanos found.";
104:         } else {
105:             $blob = '';
106:             $currentNanoline = -1;
107:             forEach ($data as $row) {
108:                 if ($currentNanoline != $row->nanoline_id) {
109:                     if (!empty($row->nanoline_name)) {
110:                         $nanolineLink = $this->text->makeChatcmd($row->nanoline_name, "/tell <myname> nanolines $row->nanoline_id");
111:                         $blob .= "\n<header2>$row->profession<end> - $nanolineLink\n";
112:                     } else {
113:                         $blob .= "\n<header2>Unknown/General<end>\n";
114:                     }
115:                     $currentNanoline = $row->nanoline_id;
116:                 }
117:                 $blob .= $this->text->makeItem($row->lowid, $row->lowid, $row->lowql, $row->name);
118:                 $blob .= " [$row->lowql] $row->location";
119:                 $blob .= "\n";
120:             }
121:             $blob .= $this->getFooter();
122:             $msg = $this->text->makeBlob("Nano Search Results ($count)", $blob);
123:         }
124: 
125:         $sendto->reply($msg);
126:     }
127:     
128:     /**
129:      * @HandlesCommand("nanolines")
130:      * @Matches("/^nanolines$/i")
131:      */
132:     public function nanolinesListProfsCommand($message, $channel, $sender, $sendto, $args) {
133:         $sql = "SELECT DISTINCT profession FROM nanolines ORDER BY profession ASC";
134:         $data = $this->db->query($sql);
135: 
136:         $blob = '';
137:         forEach ($data as $row) {
138:             $blob .= $this->text->makeChatcmd($row->profession, "/tell <myname> nanolines $row->profession");
139:             $blob .= "\n";
140:         }
141:         $blob .= $this->getFooter();
142:         $msg = $this->text->makeBlob('Nanolines', $blob);
143: 
144:         $sendto->reply($msg);
145:     }
146:     
147:     /**
148:      * @HandlesCommand("nanolines")
149:      * @Matches("/^nanolines (.*)$/i")
150:      */
151:     public function nanolinesListCommand($message, $channel, $sender, $sendto, $args) {
152:         if (preg_match("/^[0-9]+$/", $args[1])) {
153:             $this->nanolinesShow($args[1], $sendto);
154:         } else {
155:             $this->nanolinesList($args[1], $sendto);
156:         }
157:     }   
158:     
159:     private function nanolinesShow($nanolineId, $sendto) {
160:         $sql = "SELECT * FROM nanolines WHERE id = ?";
161:         $nanoline = $this->db->queryRow($sql, $nanolineId);
162: 
163:         $msg = '';
164:         if ($nanoline !== null) {
165:             $blob = '';
166: 
167:             $sql = "
168:                 SELECT
169:                     n1.lowid,
170:                     lowql,
171:                     n1.name,
172:                     location
173:                 FROM
174:                     nanos n1
175:                     JOIN nanos_nanolines_ref n2
176:                         ON (n1.lowid = n2.lowid)
177:                 WHERE
178:                     n2.nanolines_id = ?
179:                 ORDER BY
180:                     lowql DESC, name ASC";
181:             $data = $this->db->query($sql, $nanolineId);
182: 
183:             forEach ($data as $nano) {
184:                 $blob .= $this->text->makeItem($nano->lowid, $nano->lowid, $nano->lowql, $nano->name);
185:                 $blob .= " [$nano->lowql] $nano->location\n";
186:             }
187:             $blob .= $this->getFooter();
188:             $msg = $this->text->makeBlob("$nanoline->profession $nanoline->name Nanos", $blob);
189:         } else {
190:             $msg = "No nanoline found.";
191:         }
192: 
193:         $sendto->reply($msg);
194:     }
195: 
196:     private function nanolinesList($profession, $sendto) {
197:         $profession = $this->util->getProfessionName($profession);
198:         if ($profession == '') {
199:             $msg = "Please choose one of these professions: adv, agent, crat, doc, enf, eng, fix, keep, ma, mp, nt, sol, shade, or trader";
200:             $sendto->reply($msg);
201:             return;
202:         }
203: 
204:         $sql = "SELECT * FROM nanolines WHERE profession LIKE ? ORDER BY name ASC";
205:         $data = $this->db->query($sql, $profession);
206: 
207:         $blob = '';
208:         forEach ($data as $row) {
209:             if ($this->settingManager->get("shownanolineicons") == "1") {
210:                 $blob .= $this->text->makeImage($row->image_id) . "\n";
211:             }
212:             $blob .= $this->text->makeChatcmd("$row->name", "/tell <myname> nanolines $row->id");
213:             $blob .= "\n";
214:         }
215:         $blob .= $this->getFooter();
216:         $msg = $this->text->makeBlob("$profession Nanolines", $blob);
217: 
218:         $sendto->reply($msg);
219:     }
220:     
221:     /**
222:      * @HandlesCommand("nanoloc")
223:      * @Matches("/^nanoloc$/i")
224:      */
225:     public function nanolocListCommand($message, $channel, $sender, $sendto, $args) {
226:         $data = $this->db->query("SELECT location, count(location) AS count FROM nanos GROUP BY location ORDER BY location ASC");
227: 
228:         $blob = '';
229:         forEach ($data as $row) {
230:             $blob .= $this->text->makeChatcmd($row->location, "/tell <myname> nanoloc $row->location") . " ($row->count) \n";
231:         }
232:         $blob .= $this->getFooter();
233:         $msg = $this->text->makeBlob("Nano Locations", $blob);
234:         $sendto->reply($msg);
235:     }
236:     
237:     /**
238:      * @HandlesCommand("nanoloc")
239:      * @Matches("/^nanoloc (.+)$/i")
240:      */
241:     public function nanolocViewCommand($message, $channel, $sender, $sendto, $args) {
242:         $location = $args[1];
243: 
244:         $sql =
245:             "SELECT
246:                 n1.lowid,
247:                 n1.lowql,
248:                 n1.name,
249:                 n1.location,
250:                 n3.profession
251:             FROM
252:                 nanos n1
253:                 LEFT JOIN nanos_nanolines_ref n2 ON n1.lowid = n2.lowid
254:                 LEFT JOIN nanolines n3 ON n2.nanolines_id = n3.id
255:             WHERE
256:                 n1.location LIKE ?
257:             ORDER BY
258:                 n1.profession ASC,
259:                 n1.name ASC";
260: 
261:         $data = $this->db->query($sql, $location);
262: 
263:         $count = count($data);
264:         if ($count == 0) {
265:             $msg = "No nanos found.";
266:         } else {
267:             $blob = '';
268:             forEach ($data as $row) {
269:                 $blob .= $this->text->makeItem($row->lowid, $row->lowid, $row->lowql, $row->name);
270:                 $blob .= " [$row->lowql] $row->location";
271:                 if ($row->profession) {
272:                     $blob .= " - <highlight>$row->profession<end>";
273:                 }
274:                 $blob .= "\n";
275:             }
276: 
277:             $msg = $this->text->makeBlob("Nanos for Location '$location' ($count)", $blob);
278:         }
279: 
280:         $sendto->reply($msg);
281:     }
282: 
283:     private function getFooter() {
284:         return "\n\nNanos DB provided by Saavick & Lucier";
285:     }
286: }
287: 
Budabot 4 Docs API documentation generated by ApiGen