diff --git a/telegram/ext/updater.py b/telegram/ext/updater.py index a3b78e55b..cb5238834 100644 --- a/telegram/ext/updater.py +++ b/telegram/ext/updater.py @@ -124,7 +124,8 @@ class Updater(object): timeout=10, network_delay=5., clean=False, - bootstrap_retries=0): + bootstrap_retries=0, + allowed_updates=None): """ Starts polling updates from Telegram. @@ -146,6 +147,8 @@ class Updater(object): | 0 - no retries (default) | > 0 - retry up to X times + allowed_updates (Optional[list[str]]): Passed to Bot.getUpdates + Returns: Queue: The update queue that can be filled from the main thread @@ -158,7 +161,7 @@ class Updater(object): self.job_queue.start() self._init_thread(self.dispatcher.start, "dispatcher") self._init_thread(self._start_polling, "updater", poll_interval, timeout, - network_delay, bootstrap_retries, clean) + network_delay, bootstrap_retries, clean, allowed_updates) # Return the update queue so the main thread can insert updates return self.update_queue @@ -215,7 +218,8 @@ class Updater(object): # Return the update queue so the main thread can insert updates return self.update_queue - def _start_polling(self, poll_interval, timeout, network_delay, bootstrap_retries, clean): + def _start_polling(self, poll_interval, timeout, network_delay, bootstrap_retries, clean, + allowed_updates): """ Thread target of thread 'updater'. Runs in background, pulls updates from Telegram and inserts them in the update queue of the @@ -230,7 +234,10 @@ class Updater(object): while self.running: try: updates = self.bot.getUpdates( - self.last_update_id, timeout=timeout, network_delay=network_delay) + self.last_update_id, + timeout=timeout, + network_delay=network_delay, + allowed_updates=allowed_updates) except RetryAfter as e: self.logger.info(str(e)) cur_interval = 0.5 + e.retry_after @@ -332,7 +339,7 @@ class Updater(object): self._clean_updates() sleep(1) - self.bot.setWebhook(webhook_url=webhook_url, certificate=cert) + self.bot.setWebhook(url=webhook_url, certificate=cert) except (Unauthorized, InvalidToken): raise except TelegramError: