From 4eb28df1ab4d09e326eb426982f20c9ba5ee3277 Mon Sep 17 00:00:00 2001 From: Florent Gallaire Date: Tue, 24 Aug 2021 13:01:10 +0200 Subject: [PATCH 1/2] A Google Cloud Functions webhook --- telebot/util.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/telebot/util.py b/telebot/util.py index d0a58b0..8c338c3 100644 --- a/telebot/util.py +++ b/telebot/util.py @@ -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' From b4f0a6d54666b5f2e7740c061ee7a2ac482f529e Mon Sep 17 00:00:00 2001 From: Florent Gallaire Date: Wed, 25 Aug 2021 14:17:25 +0200 Subject: [PATCH 2/2] add Google in the name --- telebot/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telebot/util.py b/telebot/util.py index 8c338c3..535ffb2 100644 --- a/telebot/util.py +++ b/telebot/util.py @@ -442,7 +442,7 @@ def deprecated(warn: bool=False, alternative: Optional[Callable]=None): # Cloud helpers -def webhook_functions(bot, request): +def webhook_google_functions(bot, request): """A webhook endpoint for Google Cloud Functions FaaS.""" if request.is_json: try: