Skip to content

all2001/telegram-entities-decoder

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

telegram-entities-decoder

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

  • 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

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', 'API_KEY_STRING');
$decoded_text = $entity_decoder->decode($message);

Credits

Contacts

Telegram @LucaDevelop

About

Telegram entities decoder in PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%