Skip to content

Commit d8211ec

Browse files
committed
create bot reference in webhook handler, use create_references on new updates
1 parent 1b5806c commit d8211ec

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

telegram/ext/updater.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ def _start_webhook(self, listen, port, url_path, cert, key, bootstrap_retries, c
262262
url_path = '/{0}'.format(url_path)
263263

264264
# Create and start server
265-
self.httpd = WebhookServer((listen, port), WebhookHandler, self.update_queue, url_path)
265+
self.httpd = WebhookServer(
266+
(listen, port), WebhookHandler, self.update_queue, url_path, self.bot)
266267

267268
if use_ssl:
268269
self._check_ssl_cert(cert, key)

telegram/utils/webhookhandler.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ def __init__(self, http_code):
2121

2222
class WebhookServer(BaseHTTPServer.HTTPServer, object):
2323

24-
def __init__(self, server_address, RequestHandlerClass, update_queue, webhook_path):
24+
def __init__(self, server_address, RequestHandlerClass, update_queue, webhook_path, bot):
2525
super(WebhookServer, self).__init__(server_address, RequestHandlerClass)
2626
self.logger = logging.getLogger(__name__)
2727
self.update_queue = update_queue
2828
self.webhook_path = webhook_path
29+
self.bot = bot
2930
self.is_running = False
3031
self.server_lock = Lock()
3132
self.shutdown_lock = Lock()
@@ -82,7 +83,10 @@ def do_POST(self):
8283

8384
self.logger.debug('Webhook received data: ' + json_string)
8485

85-
update = Update.de_json(json.loads(json_string))
86+
update_dict = json.loads(json_string)
87+
self.server.create_references(update_dict)
88+
update = Update.de_json(update_dict)
89+
8690
self.logger.debug('Received Update with ID %d on Webhook' % update.update_id)
8791
self.server.update_queue.put(update)
8892

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy