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 Budabot\Core\AutoInject;
  6: 
  7: /**
  8:  * Authors: 
  9:  *  - Tyrence (RK2)
 10:  *
 11:  * @Instance
 12:  *
 13:  * Commands this controller contains:
 14:  *  @DefineCommand(
 15:  *      command     = 'silence', 
 16:  *      accessLevel = 'mod', 
 17:  *      description = 'Silence commands in a particular channel', 
 18:  *      help        = 'silence.txt'
 19:  *  )
 20:  *  @DefineCommand(
 21:  *      command     = 'unsilence', 
 22:  *      accessLevel = 'mod', 
 23:  *      description = 'Unsilence commands in a particular channel', 
 24:  *      help        = 'silence.txt'
 25:  *  )
 26:  */
 27: class SilenceController extends AutoInject {
 28: 
 29:     /**
 30:      * Name of the module.
 31:      * Set automatically by module loader.
 32:      */
 33:     public $moduleName;
 34:     
 35:     const NULL_COMMAND_HANDLER = "SilenceController.nullCommand";
 36:     
 37:     /**
 38:      * @Setup
 39:      */
 40:     public function setup() {
 41:         $this->db->loadSQLFile($this->moduleName, "silence_cmd");
 42:     }
 43:     
 44:     /**
 45:      * @HandlesCommand("silence")
 46:      * @Matches("/^silence$/i")
 47:      */
 48:     public function silenceCommand($message, $channel, $sender, $sendto, $args) {
 49:         $sql = "SELECT * FROM silence_cmd_<myname> ORDER BY cmd, channel";
 50:         $data = $this->db->query($sql);
 51:         if (count($data) == 0) {
 52:             $msg = "No commands have been silenced.";
 53:         } else {
 54:             $blob = '';
 55:             forEach ($data as $row) {
 56:                 $unsilenceLink = $this->text->makeChatcmd("Unsilence", "/tell <myname> unsilence $row->cmd $row->channel");
 57:                 $blob .= "<highlight>$row->cmd<end> ($row->channel) - $unsilenceLink\n";
 58:             }
 59:             $msg = $this->text->makeBlob("Silenced Commands", $blob);
 60:         }
 61:         $sendto->reply($msg);
 62:     }
 63:     
 64:     /**
 65:      * @HandlesCommand("silence")
 66:      * @Matches("/^silence (.+) (.+)$/i")
 67:      */
 68:     public function silenceAddCommand($message, $channel, $sender, $sendto, $args) {
 69:         $command = strtolower($args[1]);
 70:         $channel = strtolower($args[2]);
 71:         
 72:         $data = $this->commandManager->get($command, $channel);
 73:         if (count($data) == 0) {
 74:             $msg = "Could not find command <highlight>$command<end> for channel <highlight>$channel<end>.";
 75:         } else if ($this->isSilencedCommand($data[0])){
 76:             $msg = "Command <highlight>$command<end> for channel <highlight>$channel<end> has already been silenced.";
 77:         } else {
 78:             $this->addSilencedCommand($data[0]);
 79:             $msg = "Command <highlight>$command<end> for channel <highlight>$channel<end> has been silenced.";
 80:         }
 81:         $sendto->reply($msg);
 82:     }
 83:     
 84:     /**
 85:      * @HandlesCommand("unsilence")
 86:      * @Matches("/^unsilence (.+) (.+)$/i")
 87:      */
 88:     public function unsilenceCommand($message, $channel, $sender, $sendto, $args) {
 89:         $command = strtolower($args[1]);
 90:         $channel = strtolower($args[2]);
 91:         
 92:         $data = $this->commandManager->get($command, $channel);
 93:         if (count($data) == 0) {
 94:             $msg = "Could not find command <highlight>$command<end> for channel <highlight>$channel<end>.";
 95:         } else if (!$this->isSilencedCommand($data[0])){
 96:             $msg = "Command <highlight>$command<end> for channel <highlight>$channel<end> has not been silenced.";
 97:         } else {
 98:             $this->removeSilencedCommand($data[0]);
 99:             $msg = "Command <highlight>$command<end> for channel <highlight>$channel<end> has been unsilenced.";
100:         }
101:         $sendto->reply($msg);
102:     }
103:     
104:     public function nullCommand($message, $channel, $sender, $sendto, $args) {
105:         $this->logger->log('DEBUG', "Silencing command '$message' for channel '$channel'");
106:     }
107:     
108:     public function addSilencedCommand($row) {
109:         $this->commandManager->activate($row->type, self::NULL_COMMAND_HANDLER, $row->cmd, 'all');
110:         $sql = "INSERT INTO silence_cmd_<myname> (cmd, channel) VALUES (?, ?)";
111:         $this->db->exec($sql, $row->cmd, $row->type);
112:     }
113:     
114:     public function isSilencedCommand($row) {
115:         $sql = "SELECT * FROM silence_cmd_<myname> WHERE cmd = ? AND channel = ?";
116:         $row = $this->db->queryRow($sql, $row->cmd, $row->type);
117:         return $row !== null;
118:     }
119:     
120:     public function removeSilencedCommand($row) {
121:         $this->commandManager->activate($row->type, $row->file, $row->cmd, $row->admin);
122:         $sql = "DELETE FROM silence_cmd_<myname> WHERE cmd = ? AND channel = ?";
123:         $this->db->exec($sql, $row->cmd, $row->type);
124:     }
125: 
126:     /**
127:      * @Event("connect")
128:      * @Description("Overwrite command handlers for silenced commands")
129:      */
130:     public function overwriteCommandHandlersEvent($eventObj) {
131:         $sql = "SELECT * FROM silence_cmd_<myname>";
132:         $data = $this->db->query($sql);
133:         forEach ($data as $row) {
134:             $this->commandManager->activate($row->channel, self::NULL_COMMAND_HANDLER, $row->cmd, 'all');
135:         }
136:     }
137: }
138: 
Budabot 4 Docs API documentation generated by ApiGen