Receive messages from Telegram Bot to Google App Engine via Cloud Endpoint

11 views
Skip to first unread message

Davide via StackOverflow

unread,
Aug 19, 2016, 8:01:05 AM8/19/16
to google-appengin...@googlegroups.com

I have a python Google App Engine application that receive incoming message from Telegram Bot via webhook. I'm using Cloud Endpoint to receive request, so I use the Google Protocol RPC to manage the request and the response.

The json incoming update from Telegram that contain the message have a field called from. The problem is that when I write the RPC class to handle the message I can't use the name form for the variable because is a reserved keyword:

class TelegramMessage(messages.Message):
    message_id = messages.IntegerField(1, required = True)
    from = messages.MessageField(User, 2)

I can't change the name of variable because otherwise the from field from the incoming json go lost and I recive this warning in the console: No variant found for unrecognized field: from.

How can I solve it?



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/39038516/receive-messages-from-telegram-bot-to-google-app-engine-via-cloud-endpoint

Davide via StackOverflow

unread,
Aug 19, 2016, 10:46:06 AM8/19/16
to google-appengin...@googlegroups.com

I have a python Google App Engine application that receive incoming message from Telegram Bot via webhook. I'm using Cloud Endpoint to receive request, so I use the Google Protocol RPC to manage the request and the response.

The json incoming update from Telegram that contain the message have a field called from. The problem is that when I write the RPC class to handle the message I can't use the name from for the variable because is a reserved keyword:

Manzoor Wani via StackOverflow

unread,
Aug 23, 2016, 12:51:06 PM8/23/16
to google-appengin...@googlegroups.com

I would suggest to use a python library like python-telegram-bot. The author of the library renamed the Python-incompatible from attribute to from_user. So just do:

user = bot.getUpdates()[-1].from_user


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/39038516/receive-messages-from-telegram-bot-to-google-app-engine-via-cloud-endpoint/39106635#39106635
Reply all
Reply to author
Forward
0 new messages