1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

A Google Cloud Functions webhook

This commit is contained in:
Florent Gallaire 2021-08-24 13:01:10 +02:00
parent 50e5e96bb1
commit 4eb28df1ab

View File

@ -440,3 +440,18 @@ def deprecated(warn: bool=False, alternative: Optional[Callable]=None):
return wrapper
return decorator
# Cloud helpers
def webhook_functions(bot, request):
"""A webhook endpoint for Google Cloud Functions FaaS."""
if request.is_json:
try:
request_json = request.get_json()
update = types.Update.de_json(request_json)
bot.process_new_updates([update])
return ''
except Exception as e:
print(e)
return 'Bot FAIL', 400
else:
return 'Bot ON'