/** * To know on which command we have to reply on when someone wants to set a notification, we * have to register the command with the Commands-module. */ private function registerTellCommand() { $moduleManager = ModuleManager::getInstance()->offsetGet('Commands'); $moduleManager->registerCommand(new \Command(self::NOTIFICATION_COMMAND_NAME, function ($pBot, $sDestination, $sChannel, $sNickname, $aParams, $sMessage) { if (stringH::IsNullOrWhiteSpace($sMessage)) { echo '7* Usage: nickname message'; return; } list($sReceiver, $sNotification) = explode(' ', $sMessage, 2); if (strtolower($sReceiver) == strtolower($sNickname)) { echo '10* Info: You cannot send notifications to yourself.'; return; } $oNotification = new Model(self::NOTIFICATION_TABLE, 'sReceiver', $sReceiver); if (count($oNotification->getAll()) >= self::NOTIFICATION_MESSAGE_LIMIT) { echo '10* Info: The message could not be stored, because there are already ' . self::NOTIFICATION_MESSAGE_LIMIT . ' messages waiting for ' . $sReceiver; return; } $oNotification = new Model(self::NOTIFICATION_TABLE, 'iTimestamp', time()); $oNotification->sReceiver = $sReceiver; $oNotification->sSender = $sNickname; $oNotification->sMessage = $sNotification; $oNotification->iTimestamp = time(); $oNotification->sNetwork = $pBot['Network']; $oNotification->sChannel = $sChannel; if ($oNotification->save()) { $sReceiver = strtolower($oNotification->sReceiver); if (!in_array($sReceiver, $this->notifiedUsers)) { $this->notifiedUsers[] = $sReceiver; } echo 'Sure ' . $sNickname . '!'; } return; })); }
public static function onPlayerTempTaken(string $temp_taken_by, string $temped_player) { $lvp_temphistoryArray = new Model('lvp_temphistory', 'temped_player', $temped_player); $lvp_temphistoryLatestTimestamp = $lvp_temphistoryArray->getAll('start_timestamp desc')[0]; if (!isset($lvp_temphistoryLatestTimestamp)) { return; } // Taken from someone not recorded granted temp admin rights $lvp_temphistory = new Model('lvp_temphistory', 'start_timestamp', $lvp_temphistoryLatestTimestamp->start_timestamp); if (!is_null($lvp_temphistory->end_timestamp)) { return; } // Taken from someone who already left or got taken rights $lvp_temphistory->temp_taken_by = $temp_taken_by; $lvp_temphistory->end_timestamp = time(); $lvp_temphistory->save(); }