Issue
Trying to send emoji to bot in telegram using this code
text_found = None
messagetosend = '🏠'
with TelegramClient(username, api_id, api_hash) as client:
@client.on(events.NewMessage(chats = botname))
async def my_event_handler(event):
global text_found
text_found = event.raw_text
await client.disconnect()
# client(functions.messages.StartBotRequest(bot = botname, peer = '@user', start_param = emoji.emojize(':House Building:')+' Мой Кабинет'))
client(functions.messages.StartBotRequest(bot = botname, peer = '@user', start_param = messagetosend))
client.run_until_disconnected()
print(text_found)
but receive error- Start parameter invalid (caused by StartBotRequest) how to fix this?
Solution
This is very likely a restriction from Telegram's API itself. The error is not created by Telethon, meaning it can't be "fixed", but there are workarounds.
You can either encode the text into something else (perhaps the unicode values, or Python's unicode escape encoding), or use send_message
instead (but then you can't set the peer
):
client.send_message(botname, messagetosend)
(Don't forget to await
the above call if you use it within an async
context.)
Answered By - Lonami
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.