webhook2xmpp/classes/webhook_comp/discord.php
2021-05-15 11:26:20 +02:00

37 lines
No EOL
767 B
PHP

<?php
namespace classes\webhook_comp;
class discord
{
private $json;
private $readable = "";
public function __construct($json)
{
$this->json = $json;
}
public function readableMessage()
{
if(!empty($this->json->content))
{
return $this->json->content;
}
if(!empty($this->json->embeds->title))
{
$this->readable .= $this->json->embeds->title . PHP_EOL;
}
if(!empty($this->json->embeds->description))
{
$this->readable .= preg_replace("/(?:__|[*#])|\[(.*?)\]\(.*?\)/"," ",$this->json->embeds->description) . PHP_EOL;
$this->readable .= $this->json->embeds->url;
}
return $this->readable;
}
}