コード例 #1
0
ファイル: TempHistory.php プロジェクト: xhoogland/Monique
 public static function addTempHistoryCommand(Commands $commandsModule)
 {
     $commandsModule->registerCommand(new Command('temphistory', function ($bot, $destination, $channel, $nickname, $params, $message) {
         if (strtolower($channel) != '#lvp.crew' && strtolower($channel) != '#xanland.logging') {
             return;
         }
         if (count($params) < 1 || count($params) > 2) {
             echo '!temphistory [playerName] [items=5]';
             return Command::OUTPUT_USAGE;
         }
         $tempedPlayer = $params[0];
         $lvpTemphistorySingle = new Model('lvp_temphistory', 'temped_player', $tempedPlayer);
         $lvpTemphistoryArray = $lvpTemphistorySingle->getAll('start_timestamp desc');
         $amountOfTempRows = count($lvpTemphistoryArray);
         if ($amountOfTempRows == 0) {
             echo stringH::Format('{0}*** No items found for player {1}.', ModuleBase::COLOUR_RED, $tempedPlayer);
             return;
         }
         $items = $params[1] ?? 5;
         if ($items > $amountOfTempRows) {
             $items = $amountOfTempRows;
         }
         $s = 's';
         if ($amountOfTempRows == 1) {
             $s = '';
         }
         echo stringH::Format('{0}*** Temp. admin log for {1} ({2}/{3} item{4}){5}', ModuleBase::COLOUR_RED, $tempedPlayer, $items, $amountOfTempRows, $s, PHP_EOL);
         $i = 0;
         foreach ($lvpTemphistoryArray as $lvpTemphistory) {
             $startTimestamp = $lvpTemphistory->start_timestamp;
             $endTimestamp = $lvpTemphistory->end_timestamp;
             $takenByOrIngame = 'taken by: ' . $lvpTemphistory->temp_taken_by;
             if (is_null($lvpTemphistory->temp_taken_by) && is_null($endTimestamp)) {
                 $takenByOrIngame = 'currently in-game';
                 $endTimestamp = 'now';
             }
             echo stringH::Format('{0}[{1}] {2}(Granted by: {3}, {4}){5}: {6} - {7} {8}({9}){10}', ModuleBase::COLOUR_RED, date('d-m-Y', $startTimestamp), ModuleBase::COLOUR_DARKGREEN, $lvpTemphistory->temp_granted_by, $takenByOrIngame, ModuleBase::CLEAR, date('H:i:s', $startTimestamp), $endTimestamp == 'now' ? 'now' : date('H:i:s', $endTimestamp), ModuleBase::COLOUR_GREY, Util::formatTime(($endTimestamp == 'now' ? strtotime($endTimestamp) : $endTimestamp) - $startTimestamp, true), PHP_EOL);
             // 8, 9, 10
             if ($i++ == $items - 1) {
                 break;
             }
         }
     }));
 }
コード例 #2
0
ファイル: Seen.php プロジェクト: xhoogland/Monique
 /**
  * Registers the .seen-command in the commands-module for use in-game
  *
  * @param Commands $moduleManager Object so the command can be registered in the commands-module
  */
 public static function addSeenCommand(Commands $moduleManager)
 {
     $moduleManager->registerCommand(new \Command('.seen', function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) {
         if (stringH::IsNullOrWhiteSpace($aParams[0]) || count($aParams) != 1) {
             echo '!msg * Usage: .seen <username>';
         } else {
             $oLastSeenPerson = self::getPersonSeenData('lvp_person_last_seen_id', $aParams[0]);
             if (!stringH::IsNullOrWhiteSpace($oLastSeenPerson->lvp_person_last_seen_id)) {
                 if ($oLastSeenPerson->sReason != 'online') {
                     echo stringH::Format('!msg {0} was last seen online {1}{2}.', $oLastSeenPerson->lvp_person_last_seen_id, date('H:i:s @ d-m-Y', $oLastSeenPerson->iTime), $oLastSeenPerson->sReason);
                 } else {
                     echo stringH::Format('!msg {0} is already online for {1}.', $oLastSeenPerson->lvp_person_last_seen_id, \Util::formatTime(time() - $oLastSeenPerson->iTime));
                 }
             } else {
                 echo '!msg * Error: Sorry, this username has not (yet) been found.';
             }
         }
     }));
 }
コード例 #3
0
ファイル: QuoteDevice.php プロジェクト: xhoogland/Monique
 /**
  * To know what the quoteDevice now wants we need to parse the information we are receiving in #LVP.echo from a
  * Nuwani-sisters-bot.
  *
  * @param Bot    $pBot
  * @param string $sMessage The message with the information for the quoteDevice.
  */
 public static function setInformation(Bot $pBot, string $sMessage)
 {
     $aParameters = explode(' ', \Util::stripFormat($sMessage . ' '));
     $aNewParameters = explode(' ', \Util::stripFormat($sMessage . ' '));
     unset($aNewParameters[0], $aNewParameters[1]);
     $sNewMessage = implode(' ', $aNewParameters);
     $sPathToLogFile = stringH::Format('Data/Logs/{0}-{1}-{2}-#lvp.echo.log', date('Y'), date('m'), date('d'));
     if (strstr($aParameters[0], '[') !== false && strstr($aParameters[0], ']') !== false) {
         if (strstr($aParameters[1], ':') !== false) {
             file_put_contents($sPathToLogFile, stringH::Format('[{0}] <{1}> {2}' . PHP_EOL, date('H:i:s'), trim($aParameters[1], ':'), $sNewMessage), FILE_APPEND);
         } elseif (strstr($aParameters[1], ':') === false && strstr($aParameters[1], '***') === false) {
             file_put_contents($sPathToLogFile, stringH::Format('[{0}] * {1} {2}' . PHP_EOL, date('H:i:s'), trim($aParameters[1], ':'), $sNewMessage), FILE_APPEND);
         } elseif ($aParameters[1] == '***' && strstr($aParameters[6], 'kicked') !== false) {
             file_put_contents($sPathToLogFile, stringH::Format('[{0}] *** {1} was kicked by {2}' . PHP_EOL, date('H:i:s'), $aParameters[2], 'LasVenturasPlayground'), FILE_APPEND);
         }
     } elseif ($aParameters[2] == 'on' && $aParameters[3] == 'IRC:') {
         unset($aNewParameters[2], $aNewParameters[3]);
         $sNewMessage = implode(' ', $aNewParameters);
         file_put_contents($sPathToLogFile, stringH::Format('[{0}] <{1}> {2}' . PHP_EOL, date('H:i:s'), trim($aParameters[1], ':'), $sNewMessage), FILE_APPEND);
     }
     if (strstr(strtolower($sMessage), 'monique') && !strstr(strtolower($sMessage), 'monique:') && file_get_contents(self::$m_sMqdFileName) != '') {
         self::sendRandomMessage($pBot);
     }
     return;
 }