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

Merge pull request #1277 from fgallaire/master

A Google Cloud Functions webhook
This commit is contained in:
Badiboy 2021-08-25 15:19:51 +03:00 committed by GitHub
commit 08b1dd31c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -440,3 +440,18 @@ def deprecated(warn: bool=False, alternative: Optional[Callable]=None):
return wrapper
return decorator
# Cloud helpers
def webhook_google_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'