tioffs/fentities

Telegram core api formate message html

v1.0 2019-08-09 19:22 UTC

This package is auto-updated.

Last update: 2024-10-29 05:52:57 UTC


README

Downloads Telegram

Installation

Using Composer:

composer require tioffs/fentities

Supports entities

  • messageEntityItalic
  • messageEntityBold
  • messageEntityCode
  • messageEntityPre
  • messageEntityStrike
  • messageEntityUnderline
  • messageEntityBlockquote
  • messageEntityTextUrl
  • messageEntityMention
  • messageEntityUrl

Example

$message  = [
                "_" => "message",
                "out" => false,
                "mentioned" => false,
                "media_unread" => false,
                "silent" => true,
                "post" => true,
                "from_scheduled" => false,
                "legacy" => false,
                "id" => 83943,
                "to_id" => [
                    "_" => "peerChannel",
                    "channel_id" => 123456789
                ],
                "date" => 1565361063,
                "message" => "PHP is a popular general-purpose scripting language that is especially suited to web development. http://php.net",
                "media" => [],
                "entities" => [
                    [
                        "_" => "messageEntityBold",
                        "offset" => 0,
                        "length" => 96
                    ],
                    [
                        "_" => "messageEntityUrl",
                        "offset" => 98,
                        "length" => 14
                    ]
                ],
                "views" => 34566
            ];

require_once 'vendor/autoload.php';
$text = Formats\Message::html($message);

Result

<b>PHP is a popular general-purpose scripting language that
is especially suited to web development.</b>
<a href="http://php.net">http://php.net</a>

Made with ♥ from the @tioffs