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:  *  - Legendadv (RK2)
  8:  *  - Tyrence (RK2)
  9:  *
 10:  * @Instance
 11:  *
 12:  * Commands this controller contains:
 13:  *  @DefineCommand(
 14:  *      command     = 'events',
 15:  *      accessLevel = 'all',
 16:  *      description = 'View/Join/Leave events',
 17:  *      help        = 'events.txt'
 18:  *  )
 19:  *  @DefineCommand(
 20:  *      command     = 'events add .+',
 21:  *      accessLevel = 'mod',
 22:  *      description = 'Add an event',
 23:  *      help        = 'events.txt'
 24:  *  )
 25:  *  @DefineCommand(
 26:  *      command     = 'events rem .+',
 27:  *      accessLevel = 'mod',
 28:  *      description = 'Remove an event',
 29:  *      help        = 'events.txt'
 30:  *  )
 31:  *  @DefineCommand(
 32:  *      command     = 'events setdesc .+',
 33:  *      accessLevel = 'mod',
 34:  *      description = 'Change or set the description for an event',
 35:  *      help        = 'events.txt'
 36:  *  )
 37:  *  @DefineCommand(
 38:  *      command     = 'events setdate .+',
 39:  *      accessLevel = 'mod',
 40:  *      description = 'Change or set the date for an event',
 41:  *      help        = 'events.txt'
 42:  *  )
 43:  */
 44: class EventsController {
 45: 
 46:     /**
 47:      * Name of the module.
 48:      * Set automatically by module loader.
 49:      */
 50:     public $moduleName;
 51: 
 52:     /** @Inject */
 53:     public $db;
 54:     
 55:     /** @Inject */
 56:     public $chatBot;
 57: 
 58:     /** @Inject */
 59:     public $settingManager;
 60: 
 61:     /** @Inject */
 62:     public $text;
 63:     
 64:     /** @Inject */
 65:     public $util;
 66:     
 67:     /** @Inject */
 68:     public $altsController;
 69:     
 70:     private $apisocket = null;
 71: 
 72:     /** @Setup */
 73:     public function setup() {
 74:         $this->db->loadSQLFile($this->moduleName, "events");
 75: 
 76:         $this->settingManager->add($this->moduleName, "num_events_shown", "Maximum number of events shown", "edit", "number", "5", "5;10;15;20");
 77:     }
 78:     
 79:     /**
 80:      * @HandlesCommand("events")
 81:      * @Matches("/^events$/i")
 82:      */
 83:     public function eventsCommand($message, $channel, $sender, $sendto, $args) {
 84:         $msg = $this->getEvents();
 85:         if ($msg == '') {
 86:             $msg = "No events entered yet.";
 87:         }
 88:         $sendto->reply($msg);
 89:     }
 90: 
 91:     /**
 92:      * @HandlesCommand("events")
 93:      * @Matches("/^events join ([0-9]+)$/i")
 94:      */
 95:     public function eventsJoinCommand($message, $channel, $sender, $sendto, $args) {
 96:         $id = $args[1];
 97:         $row = $this->db->queryRow("SELECT * FROM events WHERE `id` = ?", $id);
 98:         if (time() < ($row->event_date + (3600 * 3))) {
 99:             // cannot join an event after 3 hours past its starttime
100:             if (strpos($row->event_attendees, $sender) !== false) {
101:                 $msg = "You are already on the event list.";
102:             } else {
103:                 if ($row->event_attendees == "") {
104:                     $row->event_attendees = "$sender";
105:                 } else {
106:                     $row->event_attendees .= ",$sender";
107:                 }
108:                 $this->db->exec("UPDATE events SET `event_attendees` = ? WHERE `id` = ?", $row->event_attendees, $id);
109:                 $msg = "You have been added to the event.";
110:             }
111:         } else {
112:             $msg = "You cannot join an event once it has already passed!";
113:         }
114:         $sendto->reply($msg);
115:     }
116:     
117:     /**
118:      * @HandlesCommand("events")
119:      * @Matches("/^events leave ([0-9]+)$/i")
120:      */
121:     public function eventsLeaveCommand($message, $channel, $sender, $sendto, $args) {
122:         $id = $args[1];
123:         $row = $this->db->queryRow("SELECT * FROM events WHERE `id` = ?", $id);
124:         if (time() < ($row->event_date + (3600 * 3))) {
125:             // cannot leave an event after 3 hours past its starttime
126:             if (strpos($row->event_attendees,$sender) !== false) {
127:                 $event = explode(",", $row->event_attendees);
128:                 forEach ($event as $i => $value) {
129:                     if ($value == $sender) {
130:                         unset($event[$i]);
131:                         $event = array_values($event);
132:                     }
133:                 }
134:                 $event = implode(",", $event);
135:                 $this->db->exec("UPDATE events SET `event_attendees` = ? WHERE `id` = ?", $event, $id);
136:                 $msg = "You have been removed from the event.";
137:             } else {
138:                 $msg = "You are not on the event list.";
139:             }
140:         } else {
141:             $msg = "You cannot leave an event once it has already passed!";
142:         }
143:         $sendto->reply($msg);
144:     }
145:     
146:     /**
147:      * @HandlesCommand("events")
148:      * @Matches("/^events list ([0-9]+)$/i")
149:      */
150:     public function eventsListCommand($message, $channel, $sender, $sendto, $args) {
151:         $id = $args[1];
152:         $row = $this->db->queryRow("SELECT event_attendees FROM events WHERE `id` = ?", $id);
153:         if ($row !== null) {
154:             $link = $this->text->makeChatcmd("Join this event", "/tell <myname> events join $id")."\n";
155:             $link .= $this->text->makeChatcmd("Leave this event", "/tell <myname> events leave $id")."\n\n";
156: 
157:             if (empty($row->event_attendees)) {
158:                 $link .= "No one has signed up to attend this event!";
159:             } else {
160:                 $eventlist = explode(",", $row->event_attendees);
161:                 sort($eventlist);
162:                 forEach ($eventlist as $key => $name) {
163:                     $row = $this->db->queryRow("SELECT * FROM players WHERE name = ? AND dimension = '<dim>'", $name);
164:                     $info = '';
165:                     if ($row !== null) {
166:                         $info = " <white>Lvl $row->level $row->profession<end>";
167:                     }
168: 
169:                     $altInfo = $this->altsController->getAltInfo($name);
170:                     $alt = '';
171:                     if (count($altInfo->alts) > 0) {
172:                         if ($altInfo->main == $name) {
173:                             $alt = " <highlight>::<end> " . $this->text->makeChatcmd("Alts", "/tell <myname> alts $name");
174:                         } else {
175:                             $alt = " <highlight>::<end> " . $this->text->makeChatcmd("Alts of {$altInfo->main}", "/tell <myname> alts $name");
176:                         }
177:                     }
178: 
179:                     $link .= $name . "$info $alt\n";
180:                 }
181:             }
182:             $msg = $this->text->makeBlob("Players Attending Event $id", $link);
183:         } else {
184:             $msg = "Could not find event with id $id.";
185:         }
186: 
187:         $sendto->reply($msg);
188:     }
189:     
190:     /**
191:      * @HandlesCommand("events add .+")
192:      * @Matches("/^events add (.+)$/i")
193:      */
194:     public function eventsAddCommand($message, $channel, $sender, $sendto, $args) {
195:         $eventName = $args[1];
196:         $this->db->exec("INSERT INTO events (`time_submitted`, `submitter_name`, `event_name`, `event_date`) VALUES (?, ?, ?, null)", time(), $sender, $eventName);
197:         $event_id = $this->db->lastInsertId();
198:         $msg = "Event: '$eventName' was added [Event ID $event_id].";
199:         $sendto->reply($msg);
200:     }
201:     
202:     /**
203:      * @HandlesCommand("events rem .+")
204:      * @Matches("/^events rem ([0-9]+)$/i")
205:      */
206:     public function eventsRemoveCommand($message, $channel, $sender, $sendto, $args) {
207:         $id = $args[1];
208:         $row = $this->db->queryRow("SELECT * FROM events WHERE id = ?", $id);
209:         if ($row === null) {
210:             $msg = "Could not find an event with id $id.";
211:         } else {
212:             $this->db->exec("DELETE FROM events WHERE `id` = ?", $id);
213:             $msg = "Event with id $id has been deleted.";
214:         }
215:         $sendto->reply($msg);
216:     }
217:     
218:     /**
219:      * @HandlesCommand("events setdesc .+")
220:      * @Matches("/^events setdesc ([0-9]+) (.+)$/i")
221:      */
222:     public function eventsSetDescCommand($message, $channel, $sender, $sendto, $args) {
223:         $id = $args[1];
224:         $desc = $args[2];
225:         $row = $this->db->queryRow("SELECT * FROM events WHERE id = ?", $id);
226:         if ($row === null) {
227:             $msg = "Could not find an event with id $id.";
228:         } else {
229:             $this->db->exec("UPDATE events SET `event_desc` = ? WHERE `id` = ?", $desc, $id);
230:             $msg = "Description for event with id $id has been updated.";
231:         }
232:         $sendto->reply($msg);
233:     }
234:     
235:     /**
236:      * @HandlesCommand("events setdate .+")
237:      * @Matches("/^events setdate ([0-9]+) ([0-9]{4})-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01]) ([0-1]?[0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])$/i")
238:      */
239:     public function eventsSetDateCommand($message, $channel, $sender, $sendto, $args) {
240:         $id = $args[1];
241:         $row = $this->db->queryRow("SELECT * FROM events WHERE id = ?", $id);
242:         if ($row === null) {
243:             $msg = "Could not find an event with id $id.";
244:         } else {
245:             // yyyy-dd-mm hh:mm:ss
246:             $eventDate = mktime($args[5], $args[6], 0, $args[3], $args[4], $args[2]);
247:             $this->db->exec("UPDATE events SET `event_date` = ? WHERE `id` = ?", $eventDate, $id);
248:             $msg = "Date/Time for event with id $id has been updated.";
249:         }
250:         $sendto->reply($msg);
251:     }
252:     
253:     public function getEvents() {
254:         $sql = "SELECT * FROM events ORDER BY `event_date` DESC LIMIT ?";
255:         $data = $this->db->query($sql, intval($this->settingManager->get('num_events_shown')));
256:         if (count($data) > 0) {
257:             $upcoming_title = "<header2>Upcoming Events<end>\n\n";
258:             $past_title = "<header2>Past Events<end>\n\n";
259:             $updated = 0;
260:             forEach ($data as $row) {
261:                 if ($row->event_attendees == '') {
262:                     $attendance = 0;
263:                 } else {
264:                     $attendance = count(explode(",", $row->event_attendees));
265:                 }
266:                 if ($updated < $row->time_submitted) {
267:                     $updated = $row->time_submitted;
268:                 }
269: 
270:                 if ($row->event_date > time()) {
271:                     $upcoming = "Event Date: <highlight>" . $this->util->date($row->event_date) . "<end>\n";
272:                     $upcoming .= "Event Name: <highlight>$row->event_name<end>     [Event ID $row->id]\n";
273:                     $upcoming .= "Author: <highlight>$row->submitter_name<end>\n";
274:                     $upcoming .= "Attendance: <highlight>" . $this->text->makeChatcmd("$attendance signed up", "/tell <myname> events list $row->id") . "<end>" .
275:                         " [" . $this->text->makeChatcmd("Join", "/tell <myname> events join $row->id") . "/" . 
276:                         $this->text->makeChatcmd("Leave", "/tell <myname> events leave $row->id") . "]\n";
277:                     $upcoming .= "Description: <highlight>" . $row->event_desc . "<end>\n";
278:                     $upcoming .= "Date Submitted: <highlight>" . $this->util->date($row->time_submitted) . "<end>\n\n";
279:                     $upcoming_events = $upcoming.$upcoming_events;
280:                 } else {
281:                     $past = "Event Date: <highlight>" . $this->util->date($row->event_date) . "<end>\n";
282:                     $past .= "Event Name: <highlight>$row->event_name<end>     [Event ID $row->id]\n";
283:                     $past .= "Author: <highlight>$row->submitter_name<end>\n";
284:                     $past .= "Attendance: <highlight>" . $this->text->makeChatcmd("$attendance signed up", "/tell <myname> events list $row->id") . "<end>\n";
285:                     $past .= "Description: <highlight>" . $row->event_desc . "<end>\n";
286:                     $past .= "Date Submitted: <highlight>" . $this->util->date($row->time_submitted) . "<end>\n\n";
287:                     $past_events .= $past;
288:                 }
289:             }
290:             if (!$upcoming_events) {
291:                 $upcoming_events = "<i>More to come.  Check back soon!</i>\n\n";
292:             }
293:             if (!$past_events) {
294:                 $link = $upcoming_title.$upcoming_events;
295:             } else {
296:                 $link = $upcoming_title.$upcoming_events.$past_title.$past_events;
297:             }
298: 
299:             return $this->text->makeBlob("Events" . " [Last updated " . $this->util->date($updated)."]", $link);
300:         } else {
301:             return "";
302:         }
303:     }
304:     
305:     /**
306:      * @Event("logOn")
307:      * @Description("Show events to org members logging on")
308:      */
309:     public function logonEvent($eventObj) {
310:         $sender = $eventObj->sender;
311: 
312:         if ($this->chatBot->isReady() && isset($this->chatBot->guildmembers[$sender])) {
313:             if ($this->hasRecentEvents()) {
314:                 $this->chatBot->sendTell($this->getEvents(), $sender);
315:             }
316:         }
317:     }
318:     
319:     /**
320:      * @Event("joinPriv")
321:      * @Description("Show events to characters joining the private channel")
322:      */
323:     public function joinPrivEvent($eventObj) {
324:         $sender = $eventObj->sender;
325: 
326:         if ($this->hasRecentEvents()) {
327:             $this->chatBot->sendTell($this->getEvents(), $sender);
328:         }
329:     }
330:     
331:     public function hasRecentEvents() {
332:         $sevenDays = time() - (86400 * 7);
333:         $row = $this->db->queryRow("SELECT * FROM events WHERE `event_date` > ? LIMIT 1", $sevenDays);
334:         return $row !== null;
335:     }
336: }
337: 
338: 
Budabot 4 Docs API documentation generated by ApiGen