Skip to content

Commit

Permalink
Safer sendoutput
Browse files Browse the repository at this point in the history
  • Loading branch information
JABirchall committed Aug 23, 2016
1 parent d1adc34 commit 5054261
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions app/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*
* @package App
*/
use TeamSpeak3\Ts3Exception;

/**
* Class Plugin
*
Expand Down Expand Up @@ -205,18 +207,22 @@ static function sortByLengthDESC($array)
function sendOutput($text, ...$params)
{
$text = vsprintf($text, $params);

$client = $this->teamSpeak3Bot->node->clientGetByName($this->info['invokername']);

if (\App\TeamSpeak3Bot::$config['newLineNewMessage'] === false) {
$client->message($text);
$this->teamSpeak3Bot->printOutput($text);
} else {
$messages = explode(PHP_EOL, $text);
foreach ($messages as $message) {
$client->message($message);
$this->teamSpeak3Bot->printOutput($message);
try {

$client = $this->teamSpeak3Bot->node->clientGetByName($this->info['invokername']);

if (\App\TeamSpeak3Bot::$config['newLineNewMessage'] === false) {
$client->message($text);
$this->teamSpeak3Bot->printOutput($text);
} else {
$messages = explode(PHP_EOL, $text);
foreach ($messages as $message) {
$client->message($message);
$this->teamSpeak3Bot->printOutput($message);
}
}
} catch (Ts3Exception $e) {
$this->teamSpeak3Bot->printOutput($e->getMessage());
}
return;
}
Expand Down

0 comments on commit 5054261

Please sign in to comment.