exception chat message method
This commit is contained in:
parent
8a6726dad1
commit
17b7e4249f
@ -3,6 +3,7 @@
|
||||
namespace ManiaControl;
|
||||
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
use ManiaControl\Players\Player;
|
||||
|
||||
/**
|
||||
* Chat Utility Class
|
||||
@ -71,9 +72,12 @@ class Chat {
|
||||
return false;
|
||||
}
|
||||
$chatMessage = '$z$<' . $this->getPrefix($prefix) . $message . '$>$z';
|
||||
if ($login === null) {
|
||||
if (!$login) {
|
||||
$this->maniaControl->client->chatSendServerMessage($chatMessage);
|
||||
} else {
|
||||
if ($login instanceof Player) {
|
||||
$login = $login->login;
|
||||
}
|
||||
try{
|
||||
$this->maniaControl->client->chatSendServerMessage($chatMessage, $login);
|
||||
} catch(Exception $e){
|
||||
@ -112,7 +116,7 @@ class Chat {
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an error message to the given login
|
||||
* Send an Error Message to the Chat
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $login
|
||||
@ -124,6 +128,18 @@ class Chat {
|
||||
return $this->sendChat($format . $message, $login);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the Exception Information to the Chat
|
||||
*
|
||||
* @param Exception $exception
|
||||
* @param string $login
|
||||
* @return bool
|
||||
*/
|
||||
public function sendException(\Exception $exception, $login = null) {
|
||||
$message = "Exception occured: '{$exception->getMessage()}' ({$exception->getCode()})";
|
||||
$this->sendError($message, $login);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an usage info message to the given login
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user