webhook2xmpp/classes/webhook_comp/discord.php
Mateusz Pieła ae66154be2 Fix
2021-05-15 12:01:18 +02:00

39 lines
No EOL
812 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;
}
$this->readable .= PHP_EOL;
if(!empty($this->json->embeds[0]->title))
{
$this->readable .= $this->json->embeds[0]->title . PHP_EOL;
}
if(!empty($this->json->embeds[0]->description))
{
$this->readable .= preg_replace("/(?:__|[*#])|\[(.*?)\]\(.*?\)/"," ",$this->json->embeds[0]->description) . PHP_EOL;
$this->readable .= $this->json->embeds[0]->url;
}
return $this->readable;
}
}