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:
parent
50e5e96bb1
commit
4eb28df1ab
@ -440,3 +440,18 @@ def deprecated(warn: bool=False, alternative: Optional[Callable]=None):
|
|||||||
return wrapper
|
return wrapper
|
||||||
return decorator
|
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'
|
||||||
|
Loading…
Reference in New Issue
Block a user