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?
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:
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