From 649fbc40c8b9e8c83cece29e97f76ca18983afd8 Mon Sep 17 00:00:00 2001 From: Leandro Toledo Date: Sun, 12 Jul 2015 10:30:35 -0300 Subject: [PATCH] Encode to UTF8 text messages --- examples/echobot.py | 2 +- telegram/message.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/echobot.py b/examples/echobot.py index 9455d7d8f..fc386982a 100644 --- a/examples/echobot.py +++ b/examples/echobot.py @@ -21,7 +21,7 @@ def echo(): if LAST_UPDATE_ID < update.update_id: # chat_id is required to reply any message chat_id = update.message.chat_id - message = update.message.text.encode('utf-8') + message = update.message.text if (message): # Reply the message diff --git a/telegram/message.py b/telegram/message.py index a0cd36452..4bdb44a76 100644 --- a/telegram/message.py +++ b/telegram/message.py @@ -82,6 +82,11 @@ class Message(object): else: reply_to_message = None + if 'text' in data: + text = data['text'].encode('utf-8') + else: + text = None + if 'audio' in data: from telegram import Audio audio = Audio.de_json(data['audio']) @@ -143,7 +148,7 @@ class Message(object): forward_from=forward_from, forward_date=data.get('forward_date', None), reply_to_message=reply_to_message, - text=data.get('text', None), + text=text, audio=audio, document=document, photo=photo,