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:  *
  9:  * @Instance
 10:  *
 11:  * Commands this controller contains:
 12:  *  @DefineCommand(
 13:  *      command     = 'reputation', 
 14:  *      accessLevel = 'guild', 
 15:  *      description = 'Allows people to see and add reputation of other players', 
 16:  *      help        = 'reputation.txt'
 17:  *  )
 18:  */
 19: class ReputationController {
 20: 
 21:     /**
 22:      * Name of the module.
 23:      * Set automatically by module loader.
 24:      */
 25:     public $moduleName;
 26:     
 27:     /** @Inject */
 28:     public $db;
 29:     
 30:     /** @Inject */
 31:     public $chatBot;
 32: 
 33:     /** @Inject */
 34:     public $text;
 35:     
 36:     /** @Inject */
 37:     public $util;
 38:     
 39:     /** @Inject */
 40:     public $settingManager;
 41:     
 42:     /**
 43:      * @Setup
 44:      */
 45:     public function setup() {
 46:         $this->settingManager->add($this->moduleName, "reputation_min_time", "How much time is required for leaving reputation for the same character", "edit", "time", "6h", "1h;6h;24h", '', "mod");
 47:         
 48:         $this->db->loadSQLFile($this->moduleName, 'reputation');
 49:     }
 50: 
 51:     /**
 52:      * @HandlesCommand("reputation")
 53:      * @Matches("/^reputation$/i")
 54:      */
 55:     public function reputationListCommand($message, $channel, $sender, $sendto, $args) {
 56:         $sql = "
 57:             SELECT
 58:                 name,
 59:                 SUM(CASE WHEN reputation = '+1' THEN 1 ELSE 0 END) pos_rep,
 60:                 SUM(CASE WHEN reputation = '-1' THEN 1 ELSE 0 END) neg_rep
 61:             FROM
 62:                 reputation
 63:             GROUP BY
 64:                 name";
 65: 
 66:         $data = $this->db->query($sql);
 67:         $count = count($data);
 68: 
 69:         if ($count == 0) {
 70:             $msg = "There are no characters on the reputation list.";
 71:             $sendto->reply($msg);
 72:             return;
 73:         }
 74: 
 75:         $blob = '';
 76:         forEach ($data as $row) {
 77:             $details_link = $this->text->makeChatcmd('Details', "/tell <myname> reputation $row->name");
 78:             $blob .= "$row->name  <green>+{$row->pos_rep}<end> <orange>-{$row->neg_rep}<end>   {$details_link}\n";
 79:         }
 80:         $msg = $this->text->makeBlob("Reputation List ($count)", $blob);
 81:         $sendto->reply($msg);
 82:     }
 83:     
 84:     /**
 85:      * @HandlesCommand("reputation")
 86:      * @Matches("/^reputation ([a-z0-9-]+) (\+1|\-1) (.+)$/i")
 87:      */
 88:     public function reputationAddCommand($message, $channel, $sender, $sendto, $args) {
 89:         $name = ucfirst(strtolower($args[1]));
 90:         $charid = $this->chatBot->get_uid($name);
 91:         $rep = $args[2];
 92:         $comment = $args[3];
 93: 
 94:         if ($charid == false) {
 95:             $sendto->reply("Character <highlight>$name<end> does not exist.");
 96:             return;
 97:         }
 98: 
 99:         if ($sender == $name) {
100:             $sendto->reply("You cannot give yourself reputation.");
101:             return;
102:         }
103: 
104:         $minTime = $this->settingManager->get('reputation_min_time');
105:         $time = time() - $minTime;
106: 
107:         $sql = "SELECT dt FROM reputation WHERE `by` = ? AND `name` = ? AND `dt` > ? ORDER BY dt DESC LIMIT 1";
108:         $row = $this->db->queryRow($sql, $sender, $name, $time);
109:         if ($row !== null) {
110:             $timeString = $this->util->unixtimeToReadable($row->dt - $time);
111:             $sendto->reply("You must wait $timeString before submitting more reputation for $name.");
112:             return;
113:         }
114: 
115:         $sql = "
116:             INSERT INTO reputation (
117:                 `name`,
118:                 `reputation`,
119:                 `comment`,
120:                 `by`,
121:                 `dt`
122:             ) VALUES (
123:                 ?,
124:                 ?,
125:                 ?,
126:                 ?,
127:                 ?
128:             )";
129: 
130:         $this->db->exec($sql, $name, $rep, $comment, $sender, time());
131:         $sendto->reply("Reputation for $name added successfully.");
132:     }
133:     
134:     /**
135:      * @HandlesCommand("reputation")
136:      * @Matches("/^reputation ([a-z0-9-]+) (all)$/i")
137:      * @Matches("/^reputation ([a-z0-9-]+)$/i")
138:      */
139:     public function reputationViewCommand($message, $channel, $sender, $sendto, $args) {
140:         $name = ucfirst(strtolower($args[1]));
141:         
142:         $limit = 10;
143:         if (count($args) == 3) {
144:             $limit = 1000;
145:         }
146: 
147:         $sql = "
148:             SELECT
149:                 sum(CASE WHEN reputation = '+1' THEN 1 ELSE 0 END) AS positive_rep,
150:                 sum(CASE WHEN reputation = '-1' THEN 1 ELSE 0 END) AS negative_rep
151:             FROM
152:                 reputation
153:             WHERE
154:                 name = ?";
155: 
156:         $row = $this->db->queryRow($sql, $name);
157:         if ($row === null) {
158:             $msg = "<highlight>$name<end> has no reputation.";
159:         } else {
160:             $num_positive = $row->positive_rep;
161:             $num_negative = $row->negative_rep;
162: 
163:             $blob = "Positive reputation: <green>{$num_positive}<end>\n";
164:             $blob .= "Negative reputation: <orange>{$num_negative}<end>\n\n";
165:             if ($limit != 1000) {
166:                 $blob .= "Last $limit comments about this user:\n\n";
167:             } else {
168:                 $blob .= "All comments about this user:\n\n";
169:             }
170: 
171:             $sql = "SELECT * FROM reputation WHERE name = ? ORDER BY `dt` DESC LIMIT ?";
172:             $data = $this->db->query($sql, $name, $limit);
173:             forEach ($data as $row) {
174:                 if ($row->reputation == '-1') {
175:                     $blob .= "<orange>";
176:                 } else {
177:                     $blob .= "<green>";
178:                 }
179: 
180:                 $time = $this->util->unixtimeToReadable(time() - $row->dt);
181:                 $blob .= "({$row->reputation}) $row->comment <end> $row->by <white>{$time} ago<end>\n\n";
182:             }
183:             
184:             if ($limit != 1000) {
185:                 $blob .= $this->text->makeChatcmd("Show all comments", "/tell <myname> reputation $name all");
186:             }
187: 
188:             $msg = $this->text->makeBlob("Reputation for {$name} (+$num_positive -$num_negative)", $blob);
189:         }
190: 
191:         $sendto->reply($msg);
192:     }
193: }
194: 
Budabot 4 Docs API documentation generated by ApiGen