From 5ae7d345f24ea0c37b3c2cf89a52a657f7a5fe90 Mon Sep 17 00:00:00 2001 From: Jacob Bom Date: Fri, 9 Sep 2016 19:44:37 +0200 Subject: [PATCH] Add get_entities.. Should probably write what it returns... Question is just how to show it here. --- Code-snippets.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Code-snippets.md b/Code-snippets.md index 98242fe..5d552b0 100644 --- a/Code-snippets.md +++ b/Code-snippets.md @@ -107,6 +107,13 @@ To download a file (you will need its `file_id`): >>> newFile.download('voice.ogg') ``` +To use MessageEntity extract the entities from a Message object using `get_entities`. +Note: This method should always be used instead of the ``entities`` attribute, since it calculates the correct substring from the message text based on UTF-16 codepoints - that is, it extracts the correct string even on when working with weird characters such as Emojis. + +```python +>>> entities = message.get_entities() +``` + There are many more API methods, to read the full API documentation visit the [Telegram API documentation](https://core.telegram.org/bots/api) or the [library documentation of telegram.Bot](http://pythonhosted.org/python-telegram-bot/telegram.bot.html) #### What to read next?