ivnkara/telegram-entities-decoder 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ivnkara/telegram-entities-decoder

最新稳定版本:v0.0.3

Composer 安装命令:

composer require ivnkara/telegram-entities-decoder

包简介

Telegram entities decoder in PHP

README 文档

README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

EntityDecoder

This class decode style entities from Telegram bot messages (bold, italic, etc.) in text with inline entities that duplicate (when possible) the exact style the message had originally when was sended to the bot. All this work is necessary because Telegram returns offset and length of the entities in UTF-16 code units that they've been hard to decode correctly in PHP

Compatibility

PHP >= 7.0

Features

  • Decode entities from text messages and attachments caption.
  • Supports all Telegram parse modes (Markdown, HTML and MarkdownV2). HTML has more entropy but it's easily the best and it's recommended.
  • Supports emoji in the text field
  • Easy to use

NOTE: Markdown parse mode is deprecated and no longer up-to-date so it doesn't support all entities. Use MarkdownV2 or HTML.

TODOs

  1. Manage Exceptions and wrong inputs
  2. Find an easier way to calculate emoji length that not use a regexp or any other way that require to be updated from emoji DB.
  3. Right to left writing compatibility

Example usage

$entity_decoder = new EntityDecoder('HTML');
$decoded_text = $entity_decoder->decode($message);

See demo folder for full example

Composer

composer require lucadevelop/telegram-entities-decoder

Usage:

require 'vendor/autoload.php';
use lucadevelop\TelegramEntitiesDecoder\EntityDecoder;
[...]
$entity_decoder = new EntityDecoder('HTML');
$decoded_text = $entity_decoder->decode($message);

Credits

Contacts

Telegram @LucaDevelop

统计信息

  • 总下载量: 47
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-10-31