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     = 'findorg', 
 16:  *      accessLevel = 'all', 
 17:  *      description = 'Find orgs by name', 
 18:  *      help        = 'findorg.txt'
 19:  *  )
 20:  */
 21: class FindOrgController {
 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 $chatBot;
 34:     
 35:     /** @Inject */
 36:     public $text;
 37:     
 38:     /** @Inject */
 39:     public $util;
 40:     
 41:     /** @Inject */
 42:     public $http;
 43:     
 44:     /** @Logger */
 45:     public $logger;
 46:     
 47:     private $searches = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'others');
 48: 
 49:     /** @Setup */
 50:     public function setup() {
 51:         $this->db->loadSQLFile($this->moduleName, "organizations");
 52:     }
 53:     
 54:     /**
 55:      * @HandlesCommand("findorg")
 56:      * @Matches("/^findorg (.+)$/i")
 57:      */
 58:     public function findOrgCommand($message, $channel, $sender, $sendto, $args) {
 59:         $search = $args[1];
 60:         
 61:         $orgs = $this->lookupOrg($search);
 62:         $count = count($orgs);
 63: 
 64:         if ($count > 0) {
 65:             $blob = $this->formatResults($orgs);
 66:             $msg = $this->text->makeBlob("Org Search Results for '{$search}' ($count)", $blob);
 67:         } else {
 68:             $msg = "No matches found.";
 69:         }
 70:         $sendto->reply($msg);
 71:     }
 72:     
 73:     public function lookupOrg($search, $limit = 50) {
 74:         $tmp = explode(" ", $search);
 75:         list($query, $params) = $this->util->generateQueryFromParams($tmp, 'name');
 76:         
 77:         $sql = "SELECT id, name, faction, num_members FROM organizations WHERE $query LIMIT 50";
 78:         
 79:         $orgs = $this->db->query($sql, $params);
 80:         
 81:         return $orgs;
 82:     }
 83:     
 84:     public function formatResults($orgs) {
 85:         $blob = '';
 86:         forEach ($orgs as $row) {
 87:             $whoisorg = $this->text->makeChatcmd('Whoisorg', "/tell <myname> whoisorg {$row->id}");
 88:             $orglist = $this->text->makeChatcmd('Orglist', "/tell <myname> orglist {$row->id}");
 89:             $orgmembers = $this->text->makeChatcmd('Orgmembers', "/tell <myname> orgmembers {$row->id}");
 90:             $blob .= "<{$row->faction}>{$row->name}<end> ({$row->id}) - {$row->num_members} members [$orglist] [$whoisorg] [$orgmembers]\n\n";
 91:         }
 92:         return $blob;
 93:     }
 94:     
 95:     /**
 96:      * @Event("timer(24hrs)")
 97:      * @Description("Parses all orgs from People of Rubi Ka")
 98:      */
 99:     public function parseAllOrgsEvent($eventObj) {
100:         $url = "http://people.anarchy-online.com/people/lookup/orgs.html";
101:         
102:         $this->logger->log("DEBUG", "Downloading all orgs from '$url'");
103:         try {
104:             $this->db->beginTransaction();
105:             $this->db->exec("DELETE FROM organizations");
106:             forEach ($this->searches as $search) {
107:                 $response = $this->http->get($url)->withQueryParams(array('l' => $search))->waitAndReturnResponse();
108:             
109:                 $pattern = '@<tr>\s*<td align="left">\s*<a href="http://people.anarchy-online.com/org/stats/d/(\d+)/name/(\d+)">\s*([^<]+)</a></td>\s*<td align="right">(\d+)</td>\s*<td align="right">(\d+)</td>\s*<td align="left">([^<]+)</td>\s*<td align="left">([^<]+)</td>\s*<td align="left" class="dim">RK5</td>\s*</tr>@s';
110: 
111:                 preg_match_all($pattern, $response->body, $arr, PREG_SET_ORDER);
112:                 forEach ($arr as $match) {
113:                     $obj = new stdClass;
114:                     //$obj->server = $match[1]; unused
115:                     $obj->id = $match[2];
116:                     $obj->name = trim($match[3]);
117:                     $obj->num_members = $match[4];
118:                     $obj->faction = $match[6];
119:                     //$obj->governingForm = $match[7]; unused
120:                 
121:                     $this->db->exec("INSERT INTO organizations (id, name, faction, num_members) VALUES (?, ?, ?, ?)", $obj->id, $obj->name, $obj->faction, $obj->num_members);
122:                 }
123:             }
124:             $this->db->commit();
125:         } catch (Exception $e) {
126:             $this->logger->log("ERROR", "Error downloading orgs");
127:             $this->db->rollback();
128:         }
129:         $this->logger->log("DEBUG", "Finished downloading orgs");
130:     }
131: }
132: 
133: 
Budabot 4 Docs API documentation generated by ApiGen