Example #1
0
 public static function message($text, $params = array(), $errorType = E_NOTICE)
 {
     Leelabot::message('NginyUS : ' . $text, $params, $errorType);
     if ($errorType == E_ERROR) {
         exit;
     }
 }
Example #2
0
 public function SrvEventStartupGame($server)
 {
     if (is_array($this->config[$server]) && count($this->config[$server])) {
         // If messages was active on this server
         if (isset($this->config[$server]['Active'])) {
             $this->config[$server]['Active'] = Leelabot::parseBool($this->config[$server]['Active']);
         } else {
             $this->config[$server]['Active'] = FALSE;
         }
         // Time in secondes
         if (!(isset($this->config[$server]['EverySeconds']) && is_numeric($this->config[$server]['EverySeconds']) && $this->config[$server]['EverySeconds'] >= 0)) {
             $this->config[$server]['EverySeconds'] = 60;
         }
         // File where are stored the messages to send.
         if (empty($this->config[$server]['MessagesFile']) || !is_file($this->_main->getConfigLocation() . '/' . $this->config[$server]['MessagesFile']) && !touch($this->_main->getConfigLocation() . '/' . $this->config[$server]['MessagesFile'])) {
             Leelabot::message("Can't load messages files. Messages will not be send.", array(), E_WARNING);
             $this->config[$server]['MessagesFile'] = NULL;
             $this->config[$server]['Active'] = FALSE;
         } else {
             $this->config[$server]['MessagesFile'] = $this->_main->getConfigLocation() . '/' . $this->config[$server]['MessagesFile'];
         }
         // If everythings is ok, we can load the file.
         $this->_loadFileMessages($server);
         $server = ServerList::getServer($server);
         $server->set('lastmsg', end($server->get('msgs')));
         $server->set('lasttime', 0);
     } else {
         Leelabot::message("Messages config was not found for \"" . $server . "\" server.", array(), E_WARNING);
     }
 }
Example #3
0
 /** Sends a command with translate on top
  * This functions sends a message to the server, visible by everyone on top.
  * 
  * \param $message The message to send. It will be parsed like in Leelabot::message().
  * \param $args The arguments of the message, for value replacement. Like in Leelabot::message().
  * \param $translate Boolean indicating if the method has to translate the message before sending. Default : TRUE.
  * 
  * \return Nothing.
  * \see RCon::tell()
  * \see RCon::say()
  */
 public static function topMessage($message, $args = array(), $translate = TRUE)
 {
     $self = self::getInstance();
     if (!$self->_server->isEnabled()) {
         return FALSE;
     }
     //Parsing message vars
     foreach ($args as $id => $value) {
         $message = str_replace('$' . $id, $value, $message);
     }
     if ($translate) {
         $message = Leelabot::$instance->intl->translate($message);
     }
     Leelabot::message('Message on top : $0', array($message), E_DEBUG);
     //Adding bot's name if defined
     if (!empty(Leelabot::$instance->botName)) {
         $message = '(' . Leelabot::$instance->botName . '): ' . $message;
     }
     //Splitting message to fit in the space allowed by the game to chat
     if (strlen($message) >= 137) {
         $message = wordwrap($message, 136, "\n", true);
         $message = explode("\n", $message);
         $rep = true;
         foreach ($message as $chunk) {
             $rep = $rep & self::send($chunk);
         }
     } else {
         return self::send($message);
     }
 }
Example #4
0
 /** Routine : checks updates on the mirror.
  * This method is bound to a routine call, which will check the availability of update for the bot, and download them if necessary.
  * If automatic updates are enabled, it will also install them.
  * 
  * \return Nothing.
  */
 public function checkUpdate()
 {
     if (!preg_match('/: ([0-9]+) \\$/', Leelabot::REVISION, $matches)) {
         return FALSE;
     }
     Leelabot::message('Checking updates...', null, E_DEBUG);
     $currentVersion = $matches[1];
     $last = $this->getLastVersion();
     if ($last->rev <= $currentVersion) {
         return;
     }
     $versions = $this->getVersions();
     usort($versions, array($this, 'compareUpdates'));
     //Getting the last updated version
     $i = 0;
     for (; $versions[$i]->rev <= $currentVersion; $i++) {
     }
     $this->_updates = array_slice($versions, $i);
     Leelabot::$instance->plugins->callEvent('update', 'available');
 }
Example #5
0
 /** Opens the log file.
  * This function opens the log file. If the log is on an FTP server, it will login, try to get its size, and open the local buffer file. If the size
  * 
  * \return TRUE if log loaded correctly, FALSE otherwise.
  */
 public function openLogFile($resume = FALSE)
 {
     switch ($this->_logfile['type']) {
         case 'file':
             Leelabot::message('Opening local game log file...');
             if (!($this->_logfile['fp'] = fopen($this->_logfile['location'], 'r'))) {
                 Leelabot::message('Can\'t open local log file : $0.', array($this->_logfile['location']), E_WARNING);
                 return FALSE;
             }
             if (!$resume) {
                 fseek($this->_logfile['fp'], 0, SEEK_END);
             }
             break;
         case 'ftp':
             Leelabot::message('Connecting to FTP server...');
             //Connecting to FTP server
             if (strpos($this->_logfile['server'], ':')) {
                 list($address, $port) = explode(':', $this->_logfile['server']);
             } else {
                 list($address, $port) = array($this->_logfile['server'], 21);
             }
             if (!($this->_logfile['ftp'] = ftp_connect($address, $port))) {
                 Leelabot::message('Can\'t connect to the log server.', array(), E_WARNING);
                 return FALSE;
             }
             ftp_set_option($this->_logfile['ftp'], FTP_AUTOSEEK, false);
             //Login
             if (!ftp_login($this->_logfile['ftp'], $this->_logfile['login'], $this->_logfile['password'])) {
                 Leelabot::message('Can\'t log in to the server.', array(), E_WARNING);
                 return FALSE;
             }
             if (!$resume) {
                 //Creating the buffer and getting end of remote log (to avoid entire log download)
                 Leelabot::message('Initializing online log read...');
                 $this->_logfile['fp'] = fopen('php://memory', 'r+');
                 $this->_logfile['state'] = FTP_FINISHED;
                 if (!($this->_logfile['origpointer'] = ftp_size($this->_logfile['ftp'], $this->_logfile['location']))) {
                     //If we can't get the size, we try to download the whole file into another temp file, and check its size
                     Leelabot::message('Can\'t get actual log size. Trying to download whole file (might be slow)...');
                     $tmpfile = fopen('php://memory', 'r+');
                     if (!ftp_get($this->_logfile['ftp'], $tmpfile, $this->_logfile['location'], FTP_BINARY)) {
                         Leelabot::message('Can\'t download log file.', array(), E_WARNING);
                         return FALSE;
                     }
                     $stat = stat($tmpfile);
                     $this->_logfile['origpointer'] = $stat['size'];
                     fclose($tmpfile);
                 }
                 $this->_logfile['pointer'] = 0;
             }
             break;
     }
     return TRUE;
 }
Example #6
0
 public function eventExists($listener, $event)
 {
     if (!isset($this->_events[$listener])) {
         Leelabot::message('Error: Undefined Event Listener: $0', $listener, E_DEBUG);
         return FALSE;
     }
     return isset($this->_events[$listener][$event]);
 }
Example #7
0
 /** Error handler for Leelabot
  * Handles errors thrown by PHP, writing them into the log along internal messages (useful for debugging from user experience).
  */
 public static function errorHandler($errno, $errstr, $errfile, $errline)
 {
     //Don't log error if it's a socket_accept() error (it floods the log)
     if (strpos($errstr, 'socket_accept') !== FALSE) {
         return TRUE;
     }
     if (Leelabot::$verbose >= 2 || $errno == E_ERROR) {
         Leelabot::message('Error in $0 at line $1 : $2', array($errfile, $errline, $errstr), $errno, FALSE, FALSE);
     }
 }
Example #8
0
 /** First auth command. Give all rights.
  * This function is triggered by the !setadmin command. It will need for argument a password, the same that is defined in
  * the configuration. If the given password is valid, the bot will put the client in the rights file with the super cow powers.
  * 
  * \param $id The client ID.
  * \param $command The client command parameters.
  * 
  * \return Nothing.
  */
 public function CommandSetadmin($id, $command)
 {
     if (!isset($command[0])) {
         RCon::tell($id, 'Not enough parameters');
         return TRUE;
     }
     $player = Server::getPlayer($id);
     //If the password is wrong, we send an error message and we log info for player.
     if ($command[0] != $this->config['FirstPasswd']) {
         RCon::tell($id, 'Invalid password');
         Leelabot::message('Invalid super-user right granting attempt from :', array(), E_WARNING);
         Leelabot::message('	Name: $0', $player->name);
         Leelabot::message('	GUID: $0', $player->guid);
         Leelabot::message('	IP: $0', $player->ip);
         return TRUE;
     }
     //The password is good, so we register the player, we notify him and we unload the command.
     if (empty($player->auth)) {
         $name = preg_replace("#[^a-zA-Z0-9]#", '', $player->name);
     } else {
         $name = preg_replace("#[^a-zA-Z0-9]#", '', $player->authLogin);
     }
     $this->rights[$name] = array();
     $this->rights[$name]['aliases'] = array($player->name);
     $this->rights[$name]['GUID'] = array(Server::getName() => $player->guid);
     $this->rights[$name]['IP'] = $player->ip;
     $this->rights[$name]['level'] = 100;
     if (!empty($player->authLogin)) {
         $this->rights[$name]['auth'] = $player->authLogin;
     }
     $this->saveRights($this->config['RightsFile']);
     $this->deleteCommand('setadmin', $this);
     $this->_plugins->callEventSimple('rights', 'authenticate', $id, $name);
     $player->level = 100;
     $player->auth = $name;
     RCon::tell($id, 'You\'re now a super-user on this server. Your pair IP/aliases will be used to authenticate you on other servers.');
     RCon::tell($id, 'The !setadmin command is now disabled for the current session. Make sure to remove the password from config.');
 }
Example #9
0
 public function SrvEventClientConnect($id)
 {
     Leelabot::message('Client connected : $0', array($id));
 }
Example #10
0
 /** Loads the banlist.
  * This function takes the file pointed by Banlist parameter from the config and loads the banlist from it. It also indexes IPs
  * for a more efficient and less time-eating search for bans.
  * 
  * \return TRUE if the banlist loaded correctly, FALSE otherwise.
  */
 public function loadBanlist()
 {
     $contents = file_get_contents($this->_banlistLocation);
     if ($contents === FALSE) {
         Leelabot::message('Can\'t load banlist : $0', array(Leelabot::lastError()), E_WARNING);
         return FALSE;
     }
     $this->_banlist = Leelabot::parseINIStringRecursive($contents);
     if (!$this->_banlist) {
         $this->_banlist = array();
     }
     $this->_bannedIP = array();
     foreach ($this->_banlist as $banID => $ban) {
         if (isset($ban['IP'])) {
             if (!isset($this->_bannedIP[$ban['IP']])) {
                 $this->_bannedIP[$ban['IP']] = array();
             }
             $this->_bannedIP[$ban['IP']][] = $banID;
         }
     }
     $this->_bannedGUID = array();
     foreach ($this->_banlist as $banID => $ban) {
         foreach ($ban['GUIDList'] as $guid) {
             if (!isset($this->_bannedGUID[$guid])) {
                 $this->_bannedGUID[$guid] = array();
             }
             $this->_bannedGUID[$guid][] = $banID;
         }
     }
     return TRUE;
 }
Example #11
0
 /** Loads the webserver and configures it.
  * This function loads the webserver and configures it from the data given in argument.
  * 
  * \param $config Configuration data
  * 
  * \return TRUE if server loaded successfully, FALSE otherwise.
  */
 public function load($config)
 {
     Leelabot::message('Loading OuterAPI...');
     include 'lib/nginyus/nginyus.php';
     NginyUS_load('lib/nginyus/');
     $this->_server = new NginyUS();
     //Checking validity of the IP/Port couple
     if (!isset($config['BindAddress']) || !isset($config['BindPort']) || !in_array($config['BindPort'], range(0, 65535)) || !filter_var($config['BindAddress'], FILTER_VALIDATE_IP)) {
         Leelabot::message('Bind address/port not found or incorrect', array(), E_WARNING);
         return FALSE;
     }
     $this->_server->setAddress($config['BindAddress'], $config['BindPort']);
     //Getting the SiteManager
     $this->_manager = $this->_server->manageSites();
     //Loading the webservice
     if (isset($config['Webservice']) && (!isset($config['Webservice']['Enable']) || Leelabot::parseBool($config['Webservice']['Enable']))) {
         Leelabot::message('Loading Webservice...');
         $this->_WSEnabled = TRUE;
         $WSConfig = $config['Webservice'];
         //Including the MLPFIM Webservice class
         include 'lib/mlpfim/mlpfimserver.php';
         //If there is aliases, we update them to add the API path to them
         if (!empty($WSConfig['Aliases'])) {
             $newAliases = array();
             foreach (explode(',', $WSConfig['Aliases']) as $alias) {
                 $newAliases[] = trim($alias) . '/api';
             }
             $WSConfig['Aliases'] = join(', ', $newAliases);
         } else {
             $WSConfig['Aliases'] = '';
         }
         //Creating site for that
         $this->_manager->newSite('webservice');
         $site = $this->_manager->getSite('webservice');
         $this->_manager->loadConfig('webservice', array('SiteRoot' => $config['BindAddress'] . '/api', 'Alias' => $WSConfig['Aliases'], 'DocumentRoot' => '.', 'ProcessFiles' => 'core/webservice.class.php'));
         if (isset($WSConfig['Authentication']) && Leelabot::parseBool($WSConfig['Authentication']) == TRUE && isset($WSConfig['AuthFile']) && is_file(Leelabot::$instance->getConfigLocation() . '/' . $WSConfig['AuthFile'])) {
             $this->_WSAuth = TRUE;
             $WSConfig['AuthFile'] = Leelabot::$instance->getConfigLocation() . '/' . $WSConfig['AuthFile'];
             $this->_WSAuthFile = $WSConfig['AuthFile'];
         } else {
             Leelabot::message('Using Webservice without authentication is not secure !', array(), E_WARNING, TRUE);
         }
     }
     //Loading the webadmin
     if (isset($config['Webadmin']) && (!isset($config['Webadmin']['Enable']) || Leelabot::parseBool($config['Webadmin']['Enable']))) {
         Leelabot::message('Loading Webadmin...');
         $this->_WAEnabled = TRUE;
         $WAConfig = $config['Webadmin'];
         //If there is aliases, we update them to add the admin path to them
         if (!empty($WAConfig['Aliases'])) {
             $newAliases = array();
             foreach (explode(',', $WAConfig['Aliases']) as $alias) {
                 $newAliases[] = trim($alias) . '/admin';
             }
             $WAConfig['Aliases'] = join(', ', $newAliases);
         } else {
             $WAConfig['Aliases'] = '';
         }
         //Creating the site in the webserver
         $this->_manager->newSite('webadmin');
         $site = $this->_manager->getSite('webadmin');
         $this->_manager->loadConfig('webadmin', array('SiteRoot' => $config['BindAddress'] . '/admin', 'Alias' => $WAConfig['Aliases'], 'DocumentRoot' => '.', 'ProcessFiles' => 'web/controllers/dispatcher.class.php'));
         if (isset($WAConfig['Authentication']) && Leelabot::parseBool($WAConfig['Authentication']) == TRUE && isset($WAConfig['AuthFile']) && is_file(Leelabot::$instance->getConfigLocation() . '/' . $WAConfig['AuthFile'])) {
             $this->_WAAuth = TRUE;
             $WAConfig['AuthFile'] = Leelabot::$instance->getConfigLocation() . '/' . $WAConfig['AuthFile'];
             $this->_WAAuthFile = $WAConfig['AuthFile'];
         } else {
             Leelabot::message('Using Webadmin without authentication is not secure !', array(), E_WARNING, TRUE);
         }
     }
     $this->_server->connect();
     //Setting InnerAPI classes
     if (!empty($this->_manager->getSite('webadmin')->classes['LeelabotAdmin'])) {
         Webadmin::setWAObject($this->_manager->getSite('webadmin')->classes['LeelabotAdmin']);
     }
     if (!empty($this->_manager->getSite('webadmin')->classes['LeelabotAdmin'])) {
         $this->_manager->getSite('webadmin')->classes['LeelabotAdmin']->setAuthentication($this->_WAAuth, $this->_WAAuthFile);
     }
     if (!empty($this->_manager->getSite('webadmin')->classes['LeelabotAdmin'])) {
         $this->_manager->getSite('webservice')->classes['LeelabotWebservice']->setAuthentication($this->_WSAuth, $this->_WSAuthFile);
     }
 }
Example #12
0
 public function RoutineIrcMain()
 {
     $donnees = LeelaBotIrc::get();
     if ($donnees) {
         $commande = explode(' ', $donnees);
         $message = explode(':', $donnees, 3);
         $pseudo = explode('!', $message[1]);
         $pseudo = $pseudo[0];
         LeelaBotIrc::setPseudo($pseudo);
         if (isset($commande[1]) && rtrim($commande[0]) == 'PING') {
             LeelaBotIrc::send('PONG :' . $message[1]);
         }
         // For crazy IRC server
         if (isset($commande[1])) {
             if ($commande[1] == '001') {
                 if (isset($this->config['AutoPerform'])) {
                     foreach ($this->config['AutoPerform'] as $command) {
                         LeelaBotIrc::send($command);
                     }
                 }
                 LeelaBotIrc::join(implode(',', $this->config['Channels']));
                 Leelabot::message('The IRC bot has join $0', array(implode(',', $this->config['Channels'])));
             }
             if ($commande[1] == '433') {
                 $this->config['Nick'] = $this->config['Nick'] . '_';
                 LeelaBotIrc::setConfig($this->config);
                 LeelaBotIrc::send("NICK " . $this->config['Nick']);
                 Leelabot::message('The IRC nickname has changed for $0', array($this->config['Nick']));
             }
             if ($commande[1] == 'PRIVMSG') {
                 $channel = $commande[2];
                 LeelaBotIrc::setChannel($channel);
                 if ($message[2][0] == '!') {
                     $cmd = explode(' ', trim($message[2]));
                     $cmd[0] = substr($cmd[0], 1);
                     $level = LeelaBotIrc::getLevel($pseudo, $this->config['MainChannel']);
                     $return = $this->_plugins->callEvent('irc', $cmd[0], $level, NULL, $pseudo, $channel, $cmd, $message);
                     if ($return === Events::ACCESS_DENIED) {
                         LeelaBotIrc::sendMessage("You don't have enough rights.");
                     }
                 } else {
                     $irc2urt = LeelaBotIrc::standardize(rtrim($message[2]));
                     $pseudo = explode(' ', $message[1]);
                     $pseudo = explode('!', $pseudo[0]);
                     $pseudo = $pseudo[0];
                     $serverlist = ServerList::getList();
                     if (is_array($this->config['AutoSpeak'])) {
                         foreach ($serverlist as $server) {
                             if (isset($this->config['AutoSpeak'][$server][$channel]) && in_array($this->config['AutoSpeak'][$server][$channel], array(1, 3))) {
                                 $rcon = ServerList::getServerRCon($server);
                                 $rcon->say('^4IRC : <$nick> $message', array('nick' => $pseudo, 'message' => $irc2urt));
                             }
                         }
                     } elseif (is_numeric($this->config['AutoSpeak']) && in_array($this->config['AutoSpeak'], array(1, 3))) {
                         foreach ($serverlist as $server) {
                             $rcon = ServerList::getServerRCon($server);
                             $rcon->say('^4IRC : <$nick> $message', array('nick' => $pseudo, 'message' => $irc2urt));
                         }
                     }
                 }
             }
         }
     }
 }
Example #13
0
 /** Init function. Loads configuration.
  * This function is called at the plugin's creation, and loads the config from main config data (in Leelabot::$config).
  * 
  * \return Nothing.
  */
 public function init()
 {
     // Got an warning on teamkill
     if (isset($this->config['TeamKills'])) {
         if (!is_bool($this->config['TeamKills'])) {
             // Only if is the first load of plugin
             $this->config['TeamKills'] = Leelabot::parseBool($this->config['TeamKills']);
         }
     } else {
         $this->config['TeamKills'] = TRUE;
     }
     // Got an warning on teamhit
     if (isset($this->config['TeamHits'])) {
         if (!is_bool($this->config['TeamHits'])) {
             // Only if is the first load of plugin
             $this->config['TeamHits'] = Leelabot::parseBool($this->config['TeamHits']);
         }
     } else {
         $this->config['TeamHits'] = FALSE;
     }
     // Got an warning if player say an bad word
     if (!isset($this->config['BadWordsFile']) || !is_file($this->_main->getConfigLocation() . '/' . $this->config['BadWordsFile']) && !touch($this->_main->getConfigLocation() . '/' . $this->config['BadWordsFile'])) {
         if (isset($this->config['BadWords'])) {
             if (!is_bool($this->config['BadWords'])) {
                 // Only if is the first load of plugin
                 $this->config['BadWords'] = Leelabot::parseBool($this->config['BadWords']);
             }
             $this->_badwords = explode('\\n', file_get_contents($this->_main->getConfigLocation() . '/' . $this->config['BadWordsFile']));
         } else {
             $this->config['BadWords'] = TRUE;
         }
     } else {
         if (isset($this->config['BadWords'])) {
             if (!is_bool($this->config['BadWords'])) {
                 // Only if is the first load of plugin
                 $this->config['BadWords'] = Leelabot::parseBool($this->config['BadWords']);
             }
             if ($this->config['BadWords']) {
                 Leelabot::message("The BadWordsFile configuration isn't set. The bot can't load BadWords warning.", array(), E_WARNING);
             }
         }
         $this->config['BadWords'] = FALSE;
     }
     // Clear warning on InitGame
     if (isset($this->config['ClearOnInit'])) {
         if (!is_bool($this->config['ClearOnInit'])) {
             // Only if is the first load of plugin
             $this->config['ClearOnInit'] = Leelabot::parseBool($this->config['ClearOnInit']);
         }
     } else {
         $this->config['ClearOnInit'] = TRUE;
     }
     // Kick on [WarnsKick] warns (must be a positive number)
     if (!(isset($this->config['WarnsKick']) && is_numeric($this->config['WarnsKick']) && $this->config['WarnsKick'] > 0)) {
         $this->config['WarnsKick'] = 3;
     }
     // Kick player after [SecondsBeforeKick]  (must be a positive number or 0)
     if (!(isset($this->config['SecondsBeforeKick']) && is_numeric($this->config['SecondsBeforeKick']) && $this->config['SecondsBeforeKick'] >= 0)) {
         $this->config['SecondsBeforeKick'] = 60;
     }
     // Level where we can't take warning. (ex: 100 = super op can't take warning)
     if (!(isset($this->config['Level']) && is_numeric($this->config['Level']) && $this->config['Level'] >= 0)) {
         $this->config['Level'] = 100;
     }
     // We delete useless event
     if (!$this->config['TeamKills']) {
         $this->deleteServerEvent('kill');
     }
     if (!$this->config['TeamHits']) {
         $this->deleteServerEvent('hit');
     }
     if (!$this->config['BadWords']) {
         $this->deleteServerEvent('say');
     }
     // We browse all servers for variables initialization
     $servers = ServerList::getList();
     foreach ($servers as $serv) {
         // Take server instance
         $server = ServerList::getServer($serv);
         // Initialize server variables
         $server->set('warns', array());
         $server->set('forgive', array());
         // Initialize players variables
         $_warns = $server->get('warns');
         $players = array_keys($server->getPlayerList());
         foreach ($players as $id) {
             $_warns[$id] = array('num' => 0, 'last' => 0);
         }
         $server->set('warns', $_warns);
     }
 }
Example #14
0
 /** Adds a custom event listener, with its auto-binding method prefix.
  * This function adds a new event listener to the event system. It allows a plugin to create his own space of events, which it cans trigger after, allowing better
  * and easier interaction between plugins.
  * 
  * \param $name The name the listener will get.
  * \param $autoMethodPrefix The prefix there will be used by other plugins for automatic method binding.
  * 
  * \return TRUE if the listener was correctly created, FALSE otherwise.
  * 
  * \see Events::addEventListener()
  */
 public function addEventListener($name, $autoMethodPrefix)
 {
     parent::addEventListener($name, $autoMethodPrefix);
     Leelabot::message('Using automatic events recognition on all plugins for listener $0...', $name);
     foreach ($this->_plugins as $pluginName => &$data) {
         if ($this->_pluginCache[$pluginName]['autoload'] === TRUE) {
             $methods = get_class_methods($data['className']);
             foreach ($methods as $method) {
                 if (preg_match('#^' . $autoMethodPrefix . '#', $method)) {
                     $event = strtolower(preg_replace('#' . $autoMethodPrefix . '(.+)#', '$1', $method));
                     Leelabot::message('Adding method $0, on event $1/$2', array($data['className'] . '::' . $method, $name, $event), E_DEBUG);
                     $this->addEvent($name, $pluginName, $event, array($data['obj'], $method));
                 }
             }
         }
     }
 }
Example #15
0
 /** Client message : notify it in the necessary logs.
  * This function is triggered by the say event. It will log the message in the chat log, and if it's a command, it will log it in the
  * commands log.
  * 
  * \param $id The ID of the client who sent a message.
  * \param $message The message itself.
  * 
  * \return Nothing.
  */
 public function SrvEventSay($id, $message)
 {
     Leelabot::message('Logging say message');
     print_r($this->_logFiles);
     $player = Server::getPlayer($id);
     $this->log('chat', $player->name . ' <' . $player->uuid . '>: ' . $message);
     $cmd = explode(' ', $message);
     //Checking if the message is a command
     if (strlen($cmd[0]) && $cmd[0][0] == '!') {
         if ($this->_plugins->eventExists('command', substr($cmd[0], 1))) {
             $cmdlevel = $this->_plugins->getEventLevel('command', substr($cmd[0], 1));
         } else {
             $cmdlevel = '?';
         }
         $this->log('commands', $player->name . ' <' . $player->uuid . '>: ' . $message);
         if (!empty($player->auth)) {
             $this->log('commands', "\t" . 'Authname: ' . $player->auth);
         }
         $this->log('commands', "\t" . 'Level check: ' . $player->level . '/' . $cmdlevel);
         if ($cmdlevel === '?') {
             $this->log('commands', "\t" . 'Command not found.');
         } elseif ($cmdlevel > $player->level) {
             $this->log('commands', "\t" . 'Access denied.');
         } else {
             $this->log('commands', "\t" . 'Access granted.');
         }
     }
 }