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:  *  - Mindrila (RK1)
  9:  *
 10:  * @Instance
 11:  *
 12:  * Commands this controller contains:
 13:  *  @DefineCommand(
 14:  *      command     = 'members', 
 15:  *      accessLevel = 'all', 
 16:  *      description = "Member list", 
 17:  *      help        = 'private_channel.txt'
 18:  *  )
 19:  *  @DefineCommand(
 20:  *      command     = 'adduser', 
 21:  *      accessLevel = 'guild', 
 22:  *      description = "Adds a player to the members list", 
 23:  *      help        = 'private_channel.txt'
 24:  *  )
 25:  *  @DefineCommand(
 26:  *      command     = 'remuser', 
 27:  *      accessLevel = 'guild', 
 28:  *      description = "Removes a player from the members list", 
 29:  *      help        = 'private_channel.txt'
 30:  *  )
 31:  *  @DefineCommand(
 32:  *      command     = 'invite', 
 33:  *      accessLevel = 'guild', 
 34:  *      description = "Invite players to the private channel", 
 35:  *      help        = 'private_channel.txt',
 36:  *      alias       = 'inviteuser'
 37:  *  )
 38:  *  @DefineCommand(
 39:  *      command     = 'kick', 
 40:  *      accessLevel = 'guild', 
 41:  *      description = "Kick players from the private channel", 
 42:  *      help        = 'private_channel.txt',
 43:  *      alias       = 'kickuser'
 44:  *  )
 45:  *  @DefineCommand(
 46:  *      command     = 'autoinvite', 
 47:  *      accessLevel = 'member', 
 48:  *      description = "Enable or disable autoinvite", 
 49:  *      help        = 'autoinvite.txt'
 50:  *  )
 51:  *  @DefineCommand(
 52:  *      command     = 'count', 
 53:  *      accessLevel = 'all', 
 54:  *      description = "Shows how many characters are in the private channel", 
 55:  *      help        = 'count.txt'
 56:  *  )
 57:  *  @DefineCommand(
 58:  *      command     = 'kickall', 
 59:  *      accessLevel = 'guild', 
 60:  *      description = "Kicks all from the private channel", 
 61:  *      help        = 'kickall.txt'
 62:  *  )
 63:  *  @DefineCommand(
 64:  *      command     = 'join', 
 65:  *      accessLevel = 'member', 
 66:  *      description = "Join command for characters who want to join the private channel", 
 67:  *      help        = 'private_channel.txt'
 68:  *  )
 69:  *  @DefineCommand(
 70:  *      command     = 'leave', 
 71:  *      accessLevel = 'all', 
 72:  *      description = "Leave command for characters in private channel", 
 73:  *      help        = 'private_channel.txt'
 74:  *  )
 75:  */
 76: class PrivateChannelController {
 77: 
 78:     /**
 79:      * Name of the module.
 80:      * Set automatically by module loader.
 81:      */
 82:     public $moduleName;
 83:     
 84:     /** @Inject */
 85:     public $db;
 86: 
 87:     /** @Inject */
 88:     public $chatBot;
 89:     
 90:     /** @Inject */
 91:     public $settingManager;
 92:     
 93:     /** @Inject */
 94:     public $buddylistManager;
 95:     
 96:     /** @Inject */
 97:     public $text;
 98:     
 99:     /** @Inject */
100:     public $util;
101:     
102:     /** @Inject */
103:     public $altsController;
104:     
105:     /** @Inject */
106:     public $accessManager;
107:     
108:     /** @Inject */
109:     public $onlineController;
110:     
111:     /** @Inject */
112:     public $relayController;
113:     
114:     /** @Inject */
115:     public $timer;
116:     
117:     /** @Inject */
118:     public $playerManager;
119:     
120:     /**
121:      * @Setup
122:      */
123:     public function setup() {
124:         $this->db->loadSQLFile($this->moduleName, "private_chat");
125:         
126:         $this->settingManager->add($this->moduleName, "guest_color_channel", "Color for Private Channel relay(ChannelName)", "edit", "color", "<font color=#C3C3C3>");
127:         $this->settingManager->add($this->moduleName, "guest_color_guild", "Private Channel relay color in guild channel", "edit", "color", "<font color=#C3C3C3>");
128:         $this->settingManager->add($this->moduleName, "guest_color_guest", "Private Channel relay color in private channel", "edit", "color", "<font color=#C3C3C3>");
129:         $this->settingManager->add($this->moduleName, "guest_relay", "Relay the Private Channel with the Guild Channel", "edit", "options", "1", "true;false", "1;0");
130:         $this->settingManager->add($this->moduleName, "guest_relay_commands", "Relay commands and results from/to Private Channel", "edit", "options", "1", "true;false", "1;0");
131:         $this->settingManager->add($this->moduleName, "add_member_on_join", "Automatically add player as member when they join", "edit", "options", "0", "true;false", "1;0");
132:     }
133: 
134:     /**
135:      * @HandlesCommand("members")
136:      * @Matches("/^members$/i")
137:      */
138:     public function membersCommand($message, $channel, $sender, $sendto, $args) {
139:         $data = $this->db->query("SELECT * FROM members_<myname> ORDER BY `name`");
140:         $count = count($data);
141:         if ($count != 0) {
142:             $list = '';
143:             forEach ($data as $row) {
144:                 $online = $this->buddylistManager->isOnline($row->name);
145:                 if (isset($this->chatBot->chatlist[$row->name])) {
146:                     $status = "(<green>Online and in channel<end>)";
147:                 } else if ($online === 1) {
148:                     $status = "(<green>Online<end>)";
149:                 } else if ($online === 0) {
150:                     $status = "(<red>Offline<end>)";
151:                 } else {
152:                     $status = "(<orange>Unknown<end>)";
153:                 }
154: 
155:                 $list .= "$row->name {$status}\n";
156:             }
157: 
158:             $msg = $this->text->makeBlob("Members ($count)", $list);
159:             $sendto->reply($msg);
160:         } else {
161:             $sendto->reply("There are no members of this bot.");
162:         }
163:     }
164:     
165:     /**
166:      * @HandlesCommand("adduser")
167:      * @Matches("/^adduser (.+)$/i")
168:      */
169:     public function adduserCommand($message, $channel, $sender, $sendto, $args) {
170:         $msg = $this->addUser($args[1]);
171: 
172:         $sendto->reply($msg);
173:     }
174:     
175:     /**
176:      * @HandlesCommand("remuser")
177:      * @Matches("/^remuser (.+)$/i")
178:      */
179:     public function remuserCommand($message, $channel, $sender, $sendto, $args) {
180:         $msg = $this->removeUser($args[1]);
181: 
182:         $sendto->reply($msg);
183:     }
184:     
185:     /**
186:      * @HandlesCommand("invite")
187:      * @Matches("/^invite (.+)$/i")
188:      */
189:     public function inviteCommand($message, $channel, $sender, $sendto, $args) {
190:         $name = ucfirst(strtolower($args[1]));
191:         $uid = $this->chatBot->get_uid($name);
192:         if ($this->chatBot->vars["name"] == $name) {
193:             $msg = "You cannot invite the bot to its own private channel.";
194:         } else if ($uid) {
195:             if (isset($this->chatBot->chatlist[$name])) {
196:                 $msg = "<highlight>$name<end> is already in the private channel.";
197:             } else {
198:                 $msg = "Invited <highlight>$name<end> to this channel.";
199:                 //$this->chatBot->privategroup_kick($name);
200:                 $this->chatBot->privategroup_invite($name);
201:                 $msg2 = "You have been invited to the <highlight><myname><end> channel by <highlight>$sender<end>.";
202:                 $this->chatBot->sendTell($msg2, $name);
203:             }
204:         } else {
205:             $msg = "Character <highlight>{$name}<end> does not exist.";
206:         }
207: 
208:         $sendto->reply($msg);
209:     }
210:     
211:     /**
212:      * @HandlesCommand("kick")
213:      * @Matches("/^kick (.+)$/i")
214:      */
215:     public function kickCommand($message, $channel, $sender, $sendto, $args) {
216:         $name = ucfirst(strtolower($args[1]));
217:         $uid = $this->chatBot->get_uid($name);
218:         if (!$uid) {
219:             $msg = "Character <highlight>{$name}<end> does not exist.";
220:         } else if (!isset($this->chatBot->chatlist[$name])) {
221:             $msg = "Character <highlight>{$name}<end> is not in the private channel.";
222:         } else {
223:             if ($this->accessManager->compareCharacterAccessLevels($sender, $name) > 0) {
224:                 $msg = "<highlight>$name<end> has been kicked from the private channel.";
225:                 $this->chatBot->privategroup_kick($name);
226:             } else {
227:                 $msg = "You do not have the required access level to kick <highlight>$name<end>.";
228:             }
229:         }
230:         $sendto->reply($msg);
231:     }
232:     
233:     /**
234:      * @HandlesCommand("autoinvite")
235:      * @Matches("/^autoinvite (on|off)$/i")
236:      */
237:     public function autoinviteCommand($message, $channel, $sender, $sendto, $args) {
238:         if ($args[1] == 'on') {
239:             $onOrOff = 1;
240:             $this->buddylistManager->add($sender, 'member');
241:         } else {
242:             $onOrOff = 0;
243:             $this->buddylistManager->remove($sender, 'member');
244:         }
245: 
246:         $data = $this->db->query("SELECT * FROM members_<myname> WHERE `name` = ?", $sender);
247:         if (count($data) == 0) {
248:             $this->db->exec("INSERT INTO members_<myname> (`name`, `autoinv`) VALUES (?, ?)", $sender, $onOrOff);
249:             $msg = "You have been added as a member of this bot.  Use <highlight><symbol>autoinvite<end> to control your auto invite preference.";
250:         } else {
251:             $this->db->exec("UPDATE members_<myname> SET autoinv = ? WHERE name = ?", $onOrOff, $sender);
252:             $msg = "Your auto invite preference has been updated.";
253:         }
254: 
255:         $sendto->reply($msg);
256:     }
257:     
258:     /**
259:      * @HandlesCommand("count")
260:      * @Matches("/^count (level|lvl)$/i")
261:      */
262:     public function countLevelCommand($message, $channel, $sender, $sendto, $args) {
263:         $tl1 = 0;
264:         $tl2 = 0;
265:         $tl3 = 0;
266:         $tl4 = 0;
267:         $tl5 = 0;
268:         $tl6 = 0;
269:         $tl7 = 0;
270: 
271:         $data = $this->db->query("SELECT * FROM online o LEFT JOIN players p ON (o.name = p.name AND p.dimension = '<dim>') WHERE added_by = '<myname>' AND channel_type = 'priv'");
272:         $numonline = count($data);
273:         forEach ($data as $row) {
274:             if ($row->level > 1 && $row->level <= 14) {
275:                 $tl1++;
276:             } else if ($row->level >= 15 && $row->level <= 49) {
277:                 $tl2++;
278:             } else if ($row->level >= 50 && $row->level <= 99) {
279:                 $tl3++;
280:             } else if ($row->level >= 100 && $row->level <= 149) {
281:                 $tl4++;
282:             } else if ($row->level >= 150 && $row->level <= 189) {
283:                 $tl5++;
284:             } else if ($row->level >= 190 && $row->level <= 204) {
285:                 $tl6++;
286:             } else if ($row->level >= 205 && $row->level <= 220) {
287:                 $tl7++;
288:             }
289:         }
290:         $msg = "<highlight>$numonline<end> in total: TL1 <highlight>$tl1<end>, TL2 <highlight>$tl2<end>, TL3 <highlight>$tl3<end>, TL4 <highlight>$tl4<end>, TL5 <highlight>$tl5<end>, TL6 <highlight>$tl6<end>, TL7 <highlight>$tl7<end>";
291:         $sendto->reply($msg);
292:     }
293:     
294:     /**
295:      * @HandlesCommand("count")
296:      * @Matches("/^count (all|prof)$/i")
297:      */
298:     public function countProfessionCommand($message, $channel, $sender, $sendto, $args) {
299:         $online["Adventurer"] = 0;
300:         $online["Agent"] = 0;
301:         $online["Bureaucrat"] = 0;
302:         $online["Doctor"] = 0;
303:         $online["Enforcer"] = 0;
304:         $online["Engineer"] = 0;
305:         $online["Fixer"] = 0;
306:         $online["Keeper"] = 0;
307:         $online["Martial Artist"] = 0;
308:         $online["Meta-Physicist"] = 0;
309:         $online["Nano-Technician"] = 0;
310:         $online["Soldier"] = 0;
311:         $online["Trader"] = 0;
312:         $online["Shade"] = 0;
313: 
314:         $data = $this->db->query("SELECT count(*) AS count, profession FROM online o LEFT JOIN players p ON (o.name = p.name AND p.dimension = '<dim>') WHERE added_by = '<myname>' AND channel_type = 'priv' GROUP BY `profession`");
315:         $numonline = count($data);
316:         $msg = "<highlight>$numonline<end> in total: ";
317: 
318:         forEach ($data as $row) {
319:             $online[$row->profession] = $row->count;
320:         }
321: 
322:         $msg .= "<highlight>".$online['Adventurer']."<end> Adv, "
323:             . "<highlight>".$online['Agent']."<end> Agent, "
324:             . "<highlight>".$online['Bureaucrat']."<end> Crat, "
325:             . "<highlight>".$online['Doctor']."<end> Doc, "
326:             . "<highlight>".$online['Enforcer']."<end> Enf, "
327:             . "<highlight>".$online['Engineer']."<end> Eng, "
328:             . "<highlight>".$online['Fixer']."<end> Fix, "
329:             . "<highlight>".$online['Keeper']."<end> Keeper, "
330:             . "<highlight>".$online['Martial Artist']."<end> MA, "
331:             . "<highlight>".$online['Meta-Physicist']."<end> MP, "
332:             . "<highlight>".$online['Nano-Technician']."<end> NT, "
333:             . "<highlight>".$online['Soldier']."<end> Sol, "
334:             . "<highlight>".$online['Shade']."<end> Shade, "
335:             . "<highlight>".$online['Trader']."<end> Trader";
336: 
337:         $sendto->reply($msg);
338:     }
339:     
340:     /**
341:      * @HandlesCommand("count")
342:      * @Matches("/^count org$/i")
343:      */
344:     public function countOrganizationCommand($message, $channel, $sender, $sendto, $args) {
345:         $sql = "SELECT * FROM online WHERE added_by = '<myname>' AND channel_type = 'priv'";
346:         $data = $this->db->query($sql);
347:         $numonline = count($data);
348: 
349:         if ($numonline == 0) {
350:             $msg = "No characters in channel.";
351:         } else {
352:             $sql = "SELECT `guild`, count(*) AS cnt, AVG(level) AS avg_level FROM online o LEFT JOIN players p ON (o.name = p.name AND p.dimension = '<dim>') WHERE added_by = '<myname>' AND channel_type = 'priv' GROUP BY `guild` ORDER BY `cnt` DESC, `avg_level` DESC";
353:             $data = $this->db->query($sql);
354:             $numorgs = count($data);
355: 
356:             $blob = '';
357:             forEach ($data as $row) {
358:                 $guild = '(none)';
359:                 if ($row->guild != '') {
360:                     $guild = $row->guild;
361:                 }
362:                 $percent = round($row->cnt / $numonline, 2) * 100;
363:                 $avg_level = round($row->avg_level, 1);
364:                 $blob .= "{$percent}% {$guild} - {$row->cnt} member(s), average level {$avg_level}\n";
365:             }
366: 
367:             $msg = $this->text->makeBlob("Organizations ($numorgs)", $blob);
368:         }
369:         $sendto->reply($msg);
370:     }
371:     
372:     /**
373:      * @HandlesCommand("count")
374:      * @Matches("/^count (.*)$/i")
375:      */
376:     public function countCommand($message, $channel, $sender, $sendto, $args) {
377:         $prof = $this->util->getProfessionName($args[1]);
378:         if ($prof == '') {
379:             $msg = "Please choose one of these professions: adv, agent, crat, doc, enf, eng, fix, keep, ma, mp, nt, sol, shade, trader or all";
380:         } else {
381:             $data = $this->db->query("SELECT * FROM online o LEFT JOIN players p ON (o.name = p.name AND p.dimension = '<dim>') WHERE added_by = '<myname>' AND channel_type = 'priv' AND `profession` = ? ORDER BY `level`", $prof);
382:             $numonline = count($data);
383:             $msg = "<highlight>$numonline<end> $prof:";
384: 
385:             forEach ($data as $row) {
386:                 if ($row->afk != "") {
387:                     $afk = "<red>*AFK*<end>";
388:                 } else {
389:                     $afk = "";
390:                 }
391:                 $msg .= " [<highlight>$row->name<end> - ".$row->level.$afk."]";
392:             }
393:         }
394:         $sendto->reply($msg);
395:     }
396:     
397:     /**
398:      * @HandlesCommand("kickall")
399:      * @Matches("/^kickall$/i")
400:      */
401:     public function kickallCommand($message, $channel, $sender, $sendto, $args) {
402:         $msg = "Everyone will be kicked from this channel in 10 seconds. [by <highlight>$sender<end>]";
403:         $this->chatBot->sendPrivate($msg);
404:         $this->timer->callLater(10, array($this->chatBot, 'privategroup_kick_all'));
405:     }
406:     
407:     /**
408:      * @HandlesCommand("join")
409:      * @Matches("/^join$/i")
410:      */
411:     public function joinCommand($message, $channel, $sender, $sendto, $args) {
412:         if (isset($this->chatBot->chatlist[$sender])) {
413:             $msg = "You are already in the private channel.";
414:         } else {
415:             if ($this->settingManager->get('add_member_on_join') == 1) {
416:                 $row = $this->db->queryRow("SELECT * FROM members_<myname> WHERE `name` = ?", $sender);
417:                 if ($row === null) {
418:                     $this->db->exec("INSERT INTO members_<myname> (`name`, `autoinv`) VALUES (?, ?)", $sender, '1');
419:                     $msg = "You have been added as a member of this bot.  Use <highlight><symbol>autoinvite<end> to control your auto invite preference.";
420:                 }
421:             }
422:             $this->chatBot->privategroup_invite($sender);
423:         }
424:         
425:         if (isset($msg)) {
426:             $sendto->reply($msg);
427:         }
428:     }
429:     
430:     /**
431:      * @HandlesCommand("leave")
432:      * @Matches("/^leave$/i")
433:      */
434:     public function leaveCommand($message, $channel, $sender, $sendto, $args) {
435:         $this->chatBot->privategroup_kick($sender);
436:     }
437:     
438:     /**
439:      * @Event("connect")
440:      * @Description("Adds all members as buddies who have auto-invite enabled")
441:      */
442:     public function connectEvent($eventObj) {
443:         $sql = "SELECT name FROM members_<myname> WHERE autoinv = 1";
444:         $data = $this->db->query($sql);
445:         forEach ($data as $row) {
446:             $this->buddylistManager->add($row->name, 'member');
447:         }
448:     }
449:     
450:     /**
451:      * @Event("guild")
452:      * @Description("Private channel relay from guild channel")
453:      */
454:     public function relayPrivateChannelEvent($eventObj) {
455:         $sender = $eventObj->sender;
456:         $message = $eventObj->message;
457:     
458:         // Check if the private channel relay is enabled
459:         if ($this->settingManager->get("guest_relay") != 1) {
460:             return;
461:         }
462: 
463:         // Check that it's not a command or if it is a command, check that guest_relay_commands is not disabled
464:         if ($message[0] == $this->settingManager->get("symbol") && $this->settingManager->get("guest_relay_commands") != 1) {
465:             return;
466:         }
467: 
468:         $guest_color_channel = $this->settingManager->get("guest_color_channel");
469:         $guest_color_guest = $this->settingManager->get("guest_color_guest");
470:         $guest_color_guild = $this->settingManager->get("guest_color_guild");
471: 
472:         if (count($this->chatBot->chatlist) > 0) {
473:             //Relay the message to the private channel if there is at least 1 char in private channel
474:             $guildNameForRelay = $this->relayController->getGuildAbbreviation();
475:             if (!$this->util->isValidSender($sender)) {
476:                 // for relaying city alien raid messages where $sender == -1
477:                 $msg = "<end>{$guest_color_channel}[$guildNameForRelay]<end> {$guest_color_guest}{$message}<end>";
478:             } else {
479:                 $msg = "<end>{$guest_color_channel}[$guildNameForRelay]<end> ".$this->text->makeUserlink($sender).": {$guest_color_guest}{$message}<end>";
480:             }
481:             $this->chatBot->sendPrivate($msg, true);
482:         }
483:     }
484:     
485:     /**
486:      * @Event("priv")
487:      * @Description("Guild channel relay from priv channel")
488:      */
489:     public function relayGuildChannelEvent($eventObj) {
490:         $sender = $eventObj->sender;
491:         $message = $eventObj->message;
492:         
493:         // Check if the private channel relay is enabled
494:         if ($this->settingManager->get("guest_relay") != 1) {
495:             return;
496:         }
497: 
498:         // Check that it's not a command or if it is a command, check that guest_relay_commands is not disabled
499:         if ($message[0] == $this->settingManager->get("symbol") && $this->settingManager->get("guest_relay_commands") != 1) {
500:             return;
501:         }
502: 
503:         $guest_color_channel = $this->settingManager->get("guest_color_channel");
504:         $guest_color_guest = $this->settingManager->get("guest_color_guest");
505:         $guest_color_guild = $this->settingManager->get("guest_color_guild");
506: 
507:         //Relay the message to the guild channel
508:         $msg = "<end>{$guest_color_channel}[Guest]<end> ".$this->text->makeUserlink($sender).": {$guest_color_guild}{$message}<end>";
509:         $this->chatBot->sendGuild($msg, true);
510:     }
511:     
512:     /**
513:      * @Event("logOn")
514:      * @Description("Auto-invite members on logon")
515:      */
516:     public function logonAutoinviteEvent($eventObj) {
517:         $sender = $eventObj->sender;
518:         $data = $this->db->query("SELECT * FROM members_<myname> WHERE name = ? AND autoinv = ?", $sender, '1');
519:         if (count($data) != 0) {
520:             $msg = "You have been auto invited to the <highlight><myname><end> channel.  Use <highlight><symbol>autoinvite<end> to control your auto invite preference.";
521:             $this->chatBot->privategroup_invite($sender);
522:             $this->chatBot->sendTell($msg, $sender);
523:         }
524:     }
525:     
526:     /**
527:      * @Event("joinPriv")
528:      * @Description("Displays a message when a character joins the private channel")
529:      */
530:     public function joinPrivateChannelMessageEvent($eventObj) {
531:         $sender = $eventObj->sender;
532:         $whois = $this->playerManager->getByName($sender);
533: 
534:         $altInfo = $this->altsController->getAltInfo($sender);
535: 
536:         if ($whois !== null) {
537:             if (count($altInfo->alts) > 0) {
538:                 $msg = $this->playerManager->getInfo($whois) . " has joined the private channel. " . $altInfo->getAltsBlob(false, true);
539:             } else {
540:                 $msg = $this->playerManager->getInfo($whois) . " has joined the private channel.";
541:             }
542:         } else {
543:             if (count($altInfo->alts) > 0) {
544:                 $msg .= "$sender has joined the private channel. " . $altInfo->getAltsBlob(false, true);
545:             } else {
546:                 $msg = "$sender has joined the private channel.";
547:             }
548:         }
549: 
550:         if ($this->settingManager->get("guest_relay") == 1) {
551:             $this->chatBot->sendGuild($msg, true);
552:         }
553:         $this->chatBot->sendPrivate($msg, true);
554:     }
555:     
556:     /**
557:      * @Event("leavePriv")
558:      * @Description("Displays a message when a character leaves the private channel")
559:      */
560:     public function leavePrivateChannelMessageEvent($eventObj) {
561:         $sender = $eventObj->sender;
562:         $msg = "$sender has left the private channel.";
563: 
564:         if ($this->settingManager->get("guest_relay") == 1) {
565:             $this->chatBot->sendGuild($msg, true);
566:         }
567:     }
568:     
569:     /**
570:      * @Event("joinPriv")
571:      * @Description("Updates the database when a character joins the private channel")
572:      */
573:     public function joinPrivateChannelRecordEvent($eventObj) {
574:         $sender = $eventObj->sender;
575:         $this->onlineController->addPlayerToOnlineList($sender, $this->chatBot->vars['guild'] . ' Guests', 'priv');
576:     }
577:     
578:     /**
579:      * @Event("leavePriv")
580:      * @Description("Updates the database when a character leaves the private channel")
581:      */
582:     public function leavePrivateChannelRecordEvent($eventObj) {
583:         $sender = $eventObj->sender;
584:         $this->onlineController->removePlayerFromOnlineList($sender, 'priv');
585:     }
586:     
587:     /**
588:      * @Event("joinPriv")
589:      * @Description("Sends the online list to people as they join the private channel")
590:      */
591:     public function joinPrivateChannelShowOnlineEvent($eventObj) {
592:         $sender = $eventObj->sender;
593:         $msg = "";
594:         $msg = $this->onlineController->getOnlineList();
595:         $this->chatBot->sendTell($msg, $sender);
596:     }
597:     
598:     public function addUser($name, $autoInvite = 1) {
599:         $name = ucfirst(strtolower($name));
600:         $uid = $this->chatBot->get_uid($name);
601:         if ($this->chatBot->vars["name"] == $name) {
602:             $msg = "You cannot add the bot as a member of itself.";
603:         } else if (!$uid) {
604:             $msg = "Character <highlight>$name<end> does not exist.";
605:         } else {
606:             $data = $this->db->query("SELECT * FROM members_<myname> WHERE `name` = ?", $name);
607:             if (count($data) != 0) {
608:                 $msg = "<highlight>$name<end> is already a member of this bot.";
609:             } else {
610:                 $this->db->exec("INSERT INTO members_<myname> (`name`, `autoinv`) VALUES (?, ?)", $name, $autoInvite);
611:                 $msg = "<highlight>$name<end> has been added as a member of this bot.";
612:             }
613: 
614:             // always add in case they were removed from the buddy list for some reason
615:             $this->buddylistManager->add($name, 'member');
616:         }
617:         return $msg;
618:     }
619:     
620:     public function removeUser($name) {
621:         $name = ucfirst(strtolower($name));
622: 
623:         $data = $this->db->query("SELECT * FROM members_<myname> WHERE `name` = ?", $name);
624:         if (count($data) == 0) {
625:             $msg = "<highlight>$name<end> is not a member of this bot.";
626:         } else {
627:             $this->db->exec("DELETE FROM members_<myname> WHERE `name` = ?", $name);
628:             $msg = "<highlight>$name<end> has been removed as a member of this bot.";
629:             $this->buddylistManager->remove($name, 'member');
630:         }
631: 
632:         return $msg;
633:     }
634: }
635: 
636: 
Budabot 4 Docs API documentation generated by ApiGen