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
  8:  *
  9:  * @Instance
 10:  *
 11:  * Commands this controller contains:
 12:  *  @DefineCommand(
 13:  *      command     = 'grc',
 14:  *      accessLevel = 'all',
 15:  *      description = 'Relays incoming messages to guildchat'
 16:  *  )
 17:  */
 18: class RelayController {
 19: 
 20:     /**
 21:      * Name of the module.
 22:      * Set automatically by module loader.
 23:      */
 24:     public $moduleName;
 25: 
 26:     /** @Inject */
 27:     public $db;
 28:     
 29:     /** @Inject */
 30:     public $chatBot;
 31:     
 32:     /** @Inject */
 33:     public $settingManager;
 34: 
 35:     /** @Inject */
 36:     public $text;
 37:     
 38:     /** @Inject */
 39:     public $util;
 40:     
 41:     /** @Inject */
 42:     public $altsController;
 43:     
 44:     /** @Inject */
 45:     public $preferences;
 46:     
 47:     /** @Inject */
 48:     public $playerManager;
 49:     
 50:     /** @Inject */
 51:     public $commandAlias;
 52:     
 53:     /** @Logger */
 54:     public $logger;
 55: 
 56:     /** @Setup */
 57:     public function setup() {
 58:         $this->settingManager->add($this->moduleName, 'relaytype', "Type of relay", "edit", "options", "1", "tell;private channel", '1;2');
 59:         $this->settingManager->add($this->moduleName, 'relaysymbol', "Symbol for external relay", "edit", "options", "@", "!;#;*;@;$;+;-");
 60:         $this->settingManager->add($this->moduleName, 'relay_symbol_method', "When to relay messages", "edit", "options", "0", "Always relay;Relay when symbol;Relay unless symbol", '0;1;2');
 61:         $this->settingManager->add($this->moduleName, 'relaybot', "Bot for Guildrelay", "edit", "text", "Off", "Off", '', "mod", "relaybot.txt");
 62:         $this->settingManager->add($this->moduleName, 'bot_relay_commands', "Relay commands and results over the bot relay", "edit", "options", "1", "true;false", "1;0");
 63:         $this->settingManager->add($this->moduleName, 'relay_color_guild', "Color of messages from relay to guild channel", 'edit', "color", "<font color='#C3C3C3'>");
 64:         $this->settingManager->add($this->moduleName, 'relay_color_priv', "Color of messages from relay to private channel", 'edit', "color", "<font color='#C3C3C3'>");
 65:         $this->settingManager->add($this->moduleName, 'relay_guild_abbreviation', 'Abbreviation to use for org name', 'edit', 'text', 'none', 'none');
 66:         
 67:         $this->commandAlias->register($this->moduleName, "macro settings save relaytype 1|settings save relaysymbol Always relay|settings save relaybot", "tellrelay");
 68:     }
 69:     
 70:     /**
 71:      * @HandlesCommand("grc")
 72:      */
 73:     public function grcCommand($message, $channel, $sender, $sendto, $args) {
 74:         $this->processIncomingRelayMessage($sender, $message);
 75:     }
 76:     
 77:     /**
 78:      * @Event("extPriv")
 79:      * @Description("Receive relay messages from other bots in the relay bot private channel")
 80:      */
 81:     public function receiveRelayMessageExtPrivEvent($eventObj) {
 82:         $this->processIncomingRelayMessage($eventObj->channel, $eventObj->message);
 83:     }
 84:     
 85:     /**
 86:      * @Event("priv")
 87:      * @Description("Receive relay messages from other bots in this bot's own private channel")
 88:      */
 89:     public function receiveRelayMessagePrivEvent($eventObj) {
 90:         $this->processIncomingRelayMessage($eventObj->sender, $eventObj->message);
 91:     }
 92:     
 93:     public function processIncomingRelayMessage($sender, $message) {
 94:         if ($sender == ucfirst(strtolower($this->settingManager->get('relaybot'))) && preg_match("/^grc (.+)$/s", $message, $arr)) {
 95:             $msg = $arr[1];
 96:             $this->chatBot->sendGuild($this->settingManager->get('relay_color_guild') . $msg, true);
 97: 
 98:             if ($this->settingManager->get("guest_relay") == 1) {
 99:                 $this->chatBot->sendPrivate($this->settingManager->get('relay_color_priv') . $msg, true);
100:             }
101:         }
102:     }
103:     
104:     /**
105:      * @Event("guild")
106:      * @Description("Sends org chat to relay")
107:      */
108:     public function orgChatToRelayEvent($eventObj) {
109:         $this->processOutgoingRelayMessage($eventObj->sender, $eventObj->message, $eventObj->type);
110:     }
111:     
112:     /**
113:      * @Event("priv")
114:      * @Description("Sends private channel chat to relay")
115:      */
116:     public function privChatToRelayEvent($eventObj) {
117:         $this->processOutgoingRelayMessage($eventObj->sender, $eventObj->message, $eventObj->type);
118:     }
119:     
120:     public function processOutgoingRelayMessage($sender, $message, $type) {
121:         if (($this->settingManager->get("relaybot") != "Off") && ($this->settingManager->get("bot_relay_commands") == 1 || $message[0] != $this->settingManager->get("symbol"))) {
122:             $relayMessage = '';
123:             if ($this->settingManager->get('relay_symbol_method') == '0') {
124:                 $relayMessage = $message;
125:             } else if ($this->settingManager->get('relay_symbol_method') == '1' && $message[0] == $this->settingManager->get('relaysymbol')) {
126:                 $relayMessage = substr($message, 1);
127:             } else if ($this->settingManager->get('relay_symbol_method') == '2' && $message[0] != $this->settingManager->get('relaysymbol')) {
128:                 $relayMessage = $message;
129:             } else {
130:                 return;
131:             }
132: 
133:             if (!$this->util->isValidSender($sender)) {
134:                 $sender_link = '';
135:             } else {
136:                 $sender_link = ' ' . $this->text->makeUserlink($sender) . ':';
137:             }
138: 
139:             if ($type == "guild") {
140:                 $msg = "grc [<myguild>]{$sender_link} {$relayMessage}";
141:             } else if ($type == "priv") {
142:                 $msg = "grc [<myguild>] [Guest]{$sender_link} {$relayMessage}";
143:             } else {
144:                 $this->logger->log('WARN', "Invalid type; expecting 'guild' or 'priv'.  Actual: '$type'");
145:                 return;
146:             }
147:             $this->sendMessageToRelay($msg);
148:         }
149:     }
150:     
151:     /**
152:      * @Event("extJoinPrivRequest")
153:      * @Description("Accept private channel join invitation from the relay bot")
154:      */
155:     public function acceptPrivJoinEvent($eventObj) {
156:         $sender = $eventObj->sender;
157:         if ($this->settingManager->get("relaytype") == 2 && strtolower($sender) == strtolower($this->settingManager->get("relaybot"))) {
158:             $this->chatBot->privategroup_join($sender);
159:         }
160:     }
161:     
162:     /**
163:      * @Event("orgmsg")
164:      * @Description("Relay Org Messages")
165:      */
166:     public function relayOrgMessagesEvent($eventObj) {
167:         if ($this->settingManager->get("relaybot") != "Off") {
168:             $msg = "grc [<myguild>] {$eventObj->message}<end>";
169:             $this->sendMessageToRelay($msg);
170:         }
171:     }
172:     
173:     /**
174:      * @Event("logOn")
175:      * @Description("Sends Logon messages over the relay")
176:      */
177:     public function relayLogonMessagesEvent($eventObj) {
178:         $sender = $eventObj->sender;
179:         if ($this->settingManager->get("relaybot") != "Off" && isset($this->chatBot->guildmembers[$sender]) && $this->chatBot->isReady()) {
180:             $whois = $this->playerManager->getByName($sender);
181: 
182:             $msg = '';
183:             if ($whois === null) {
184:                 $msg = "$sender logged on.";
185:             } else {
186:                 $msg = $this->playerManager->getInfo($whois);
187: 
188:                 $msg .= " logged on.";
189: 
190:                 $altInfo = $this->altsController->getAltInfo($sender);
191:                 if (count($altInfo->alts) > 0) {
192:                     $msg .= " " . $altInfo->getAltsBlob(false, true);
193:                 }
194: 
195:                 $logon_msg = $this->preferences->get($sender, 'logon_msg');
196:                 if ($logon_msg !== false && $logon_msg != '') {
197:                     $msg .= " - " . $logon_msg;
198:                 }
199:             }
200: 
201:             $this->sendMessageToRelay("grc [<myguild>] ".$msg);
202:         }
203:     }
204:     
205:     /**
206:      * @Event("logOff")
207:      * @Description("Sends Logoff messages over the relay")
208:      */
209:     public function relayLogoffMessagesEvent($eventObj) {
210:         $sender = $eventObj->sender;
211:         if ($this->settingManager->get("relaybot") != "Off" && isset($this->chatBot->guildmembers[$sender]) && $this->chatBot->isReady()) {
212:             $this->sendMessageToRelay("grc [<myguild>] <highlight>{$sender}<end> logged off");
213:         }
214:     }
215:     
216:     /**
217:      * @Event("joinPriv")
218:      * @Description("Sends a message to the relay when someone joins the private channel")
219:      */
220:     public function relayJoinPrivMessagesEvent($eventObj) {
221:         $sender = $eventObj->sender;
222:         if ($this->settingManager->get('relaybot') != 'Off') {
223:             $whois = $this->playerManager->getByName($sender);
224:             $altInfo = $this->altsController->getAltInfo($sender);
225: 
226:             if ($whois !== null) {
227:                 if (count($altInfo->alts) > 0) {
228:                     $msg = $this->playerManager->getInfo($whois) . " has joined the private channel. " . $altInfo->getAltsBlob(false, true);
229:                 } else {
230:                     $msg = $this->playerManager->getInfo($whois) . " has joined the private channel.";
231:                 }
232:             } else {
233:                 if (count($altInfo->alts) > 0) {
234:                     $msg .= "$sender has joined the private channel. " . $altInfo->getAltsBlob(false, true);
235:                 } else {
236:                     $msg = "$sender has joined the private channel.";
237:                 }
238:             }
239: 
240:             $this->sendMessageToRelay("grc [<myguild>] " . $msg);
241:         }
242:     }
243:     
244:     /**
245:      * @Event("leavePriv")
246:      * @Description("Sends a message to the relay when someone leaves the private channel")
247:      */
248:     public function relayLeavePrivMessagesEvent($eventObj) {
249:         $sender = $eventObj->sender;
250:         if ($this->settingManager->get('relaybot') != 'Off') {
251:             $msg = "<highlight>{$sender}<end> has left the private channel.";
252:             $this->sendMessageToRelay("grc [<myguild>] " . $msg);
253:         }
254:     }
255:     
256:     function sendMessageToRelay($message) {
257:         $relayBot = $this->settingManager->get('relaybot');
258:         $message = str_ireplace("<myguild>", $this->getGuildAbbreviation(), $message);
259: 
260:         // since we are using the aochat methods, we have to call formatMessage manually to handle colors and bot name replacement
261:         $message = $this->text->formatMessage($message);
262: 
263:         // we use the aochat methods so the bot doesn't prepend default colors
264:         if ($this->settingManager->get('relaytype') == 2) {
265:             $this->chatBot->send_privgroup($relayBot, $message);
266:         } else if ($this->settingManager->get('relaytype') == 1) {
267:             $this->chatBot->send_tell($relayBot, $message);
268: 
269:             // manual logging is only needed for tell relay
270:             $this->logger->logChat("Out. Msg.", $relayBot, $message);
271:         }
272:     }
273: 
274:     function getGuildAbbreviation() {
275:         if ($this->settingManager->get('relay_guild_abbreviation') != 'none') {
276:             return $this->settingManager->get('relay_guild_abbreviation');
277:         } else {
278:             return $this->chatBot->vars["my_guild"];
279:         }
280:     }
281: }
282: 
283: 
Budabot 4 Docs API documentation generated by ApiGen