コード例 #1
0
 /**
  * Handles the event.
  *
  * @param array $matches
  *
  * @return void
  */
 public function handle($matches)
 {
     list(, $sender, $message) = $matches;
     $handle = ['Round_Spawn', 'Round_Start', 'Round_End'];
     $key = array_search($message, $handle);
     if ($key !== false) {
         $func = 'handle';
         $func .= ucwords(camel_case($handle[$key]));
         $this->{$func}();
     } else {
         Logger::log("{$message} is not a handled event", Logger::LEVEL_DEBUG);
     }
 }
コード例 #2
0
 /**
  * Handles the event.
  *
  * @param array $matches
  *
  * @return void
  */
 public function handle($matches)
 {
     $message = $matches[5];
     $handle = ['ready' => 'handleReady', 'r' => 'handleReady', 'unready' => 'handleUnready', 'pause' => 'handlePause', 'unpause' => 'handleUnpause', 'stay' => 'handleStay', 'switch' => 'handleSwitch', 'abort' => 'handleAbort'];
     $prefixes = ['.', '!'];
     if (array_search($message[0], $prefixes) === false) {
         Logger::log('prefix ' . $message[0] . ' does not match any of the specified prefixes', Logger::LEVEL_DEBUG);
         return;
     }
     if (isset($handle[substr($message, 1)])) {
         $this->{$handle[substr($message, 1)]}($matches);
     }
 }
コード例 #3
0
ファイル: Regex.php プロジェクト: uniquoooo/CSManager
 /**
  * Attempts to match a Regex pattern.
  *
  * @param string  $data
  * @param Handler $handler
  *
  * @return void
  */
 public function match($data, $handler)
 {
     $this->map = $this->map->fresh();
     foreach ($this->patterns as $regex) {
         if (isset($regex['ignore']) && $regex['ignore']) {
             continue;
         }
         if (isset($regex['in_game']) && $regex['in_game'] && !$this->map->inGame()) {
             continue;
         }
         if (preg_match($regex['pattern'], $data, $matches)) {
             (new $regex['class']($this->map, $this->rcon, $handler))->handle($matches);
             return;
         }
     }
     Logger::log("could not match data: {$data}", Logger::LEVEL_DEBUG);
 }
コード例 #4
0
 /**
  * Runs the migrations.
  *
  * @return bool
  * @return void
  */
 public function run()
 {
     foreach ($this->migrations as $table => $migration) {
         Logger::log("Migrating `{$table}`");
         try {
             $migration = new $migration();
             Capsule::schema()->create($table, function ($table) use($migration) {
                 $migration->up($table);
             });
         } catch (FatalThrowableError $e) {
             Logger::log("Error migrating table `{$table}`: {$e->getMessage()}", Logger::LEVEL_ERROR);
         } catch (\PDOException $e) {
             Logger::log("Error migrating table `{$table}`: {$e->getMessage()}", Logger::LEVEL_ERROR);
         }
     }
     Logger::log('Finished migrating.');
     return true;
 }
コード例 #5
0
ファイル: Handler.php プロジェクト: uniquoooo/CSManager
 /**
  * Kills the timer to say !ready.
  *
  * @return void
  */
 public function killSayReady()
 {
     Logger::log('killing !ready timer', Logger::LEVEL_DEBUG);
     $this->loop->cancelTimer($this->timers['ready']);
 }