From 1a7edd7a5da2959d37198003a65e65ac15272ab0 Mon Sep 17 00:00:00 2001 From: Luca Bellanti Date: Sun, 4 Jun 2023 17:11:58 +0200 Subject: [PATCH] Explicitly set `allowed_updates` in Examples (#3741) --- examples/arbitrarycallbackdatabot.py | 2 +- examples/contexttypesbot.py | 2 +- examples/conversationbot.py | 2 +- examples/conversationbot2.py | 2 +- examples/customwebhookbot.py | 2 +- examples/deeplinking.py | 2 +- examples/echobot.py | 2 +- examples/errorhandlerbot.py | 2 +- examples/inlinebot.py | 2 +- examples/inlinekeyboard.py | 2 +- examples/inlinekeyboard2.py | 2 +- examples/nestedconversationbot.py | 2 +- examples/passportbot.py | 2 +- examples/paymentbot.py | 2 +- examples/persistentconversationbot.py | 2 +- examples/pollbot.py | 2 +- examples/rawapibot.py | 4 ++-- examples/timerbot.py | 2 +- examples/webappbot.py | 2 +- 19 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/arbitrarycallbackdatabot.py b/examples/arbitrarycallbackdatabot.py index 3fca2c5fe..392c67728 100644 --- a/examples/arbitrarycallbackdatabot.py +++ b/examples/arbitrarycallbackdatabot.py @@ -122,7 +122,7 @@ def main() -> None: application.add_handler(CallbackQueryHandler(list_button)) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/contexttypesbot.py b/examples/contexttypesbot.py index 17f8fb90f..30dc96753 100644 --- a/examples/contexttypesbot.py +++ b/examples/contexttypesbot.py @@ -147,7 +147,7 @@ def main() -> None: application.add_handler(CallbackQueryHandler(count_click)) application.add_handler(CommandHandler("print_users", print_users)) - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/conversationbot.py b/examples/conversationbot.py index 84c9accde..b846e3669 100644 --- a/examples/conversationbot.py +++ b/examples/conversationbot.py @@ -169,7 +169,7 @@ def main() -> None: application.add_handler(conv_handler) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/conversationbot2.py b/examples/conversationbot2.py index 14491bf5e..efb809e17 100644 --- a/examples/conversationbot2.py +++ b/examples/conversationbot2.py @@ -157,7 +157,7 @@ def main() -> None: application.add_handler(conv_handler) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/customwebhookbot.py b/examples/customwebhookbot.py index c129e41eb..f9539dfe3 100644 --- a/examples/customwebhookbot.py +++ b/examples/customwebhookbot.py @@ -129,7 +129,7 @@ async def main() -> None: application.add_handler(TypeHandler(type=WebhookUpdate, callback=webhook_update)) # Pass webhook settings to telegram - await application.bot.set_webhook(url=f"{url}/telegram") + await application.bot.set_webhook(url=f"{url}/telegram", allowed_updates=Update.ALL_TYPES) # Set up webserver async def telegram(request: Request) -> Response: diff --git a/examples/deeplinking.py b/examples/deeplinking.py index 025ed513f..63941916b 100644 --- a/examples/deeplinking.py +++ b/examples/deeplinking.py @@ -144,7 +144,7 @@ def main() -> None: application.add_handler(CommandHandler("start", start)) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/echobot.py b/examples/echobot.py index 6aa369cae..3c06e799c 100644 --- a/examples/echobot.py +++ b/examples/echobot.py @@ -74,7 +74,7 @@ def main() -> None: application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, echo)) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/errorhandlerbot.py b/examples/errorhandlerbot.py index 1152dc6da..0b6620f56 100644 --- a/examples/errorhandlerbot.py +++ b/examples/errorhandlerbot.py @@ -90,7 +90,7 @@ def main() -> None: application.add_error_handler(error_handler) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/inlinebot.py b/examples/inlinebot.py index 14310a6ea..8ec2cbc52 100644 --- a/examples/inlinebot.py +++ b/examples/inlinebot.py @@ -99,7 +99,7 @@ def main() -> None: application.add_handler(InlineQueryHandler(inline_query)) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/inlinekeyboard.py b/examples/inlinekeyboard.py index 517f810b4..d21a9c1d9 100644 --- a/examples/inlinekeyboard.py +++ b/examples/inlinekeyboard.py @@ -72,7 +72,7 @@ def main() -> None: application.add_handler(CommandHandler("help", help_command)) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/inlinekeyboard2.py b/examples/inlinekeyboard2.py index d40381588..2f57b7fe0 100644 --- a/examples/inlinekeyboard2.py +++ b/examples/inlinekeyboard2.py @@ -204,7 +204,7 @@ def main() -> None: application.add_handler(conv_handler) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/nestedconversationbot.py b/examples/nestedconversationbot.py index 684ee157a..2a4a79152 100644 --- a/examples/nestedconversationbot.py +++ b/examples/nestedconversationbot.py @@ -392,7 +392,7 @@ def main() -> None: application.add_handler(conv_handler) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/passportbot.py b/examples/passportbot.py index 77281e85e..d0669bd24 100644 --- a/examples/passportbot.py +++ b/examples/passportbot.py @@ -129,7 +129,7 @@ def main() -> None: application.add_handler(MessageHandler(filters.PASSPORT_DATA, msg)) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/paymentbot.py b/examples/paymentbot.py index d2206b7be..23b077bb6 100644 --- a/examples/paymentbot.py +++ b/examples/paymentbot.py @@ -165,7 +165,7 @@ def main() -> None: ) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/persistentconversationbot.py b/examples/persistentconversationbot.py index cd62cf7c6..22db5f452 100644 --- a/examples/persistentconversationbot.py +++ b/examples/persistentconversationbot.py @@ -180,7 +180,7 @@ def main() -> None: application.add_handler(show_data_handler) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/pollbot.py b/examples/pollbot.py index 9b41832b2..f7a49088a 100644 --- a/examples/pollbot.py +++ b/examples/pollbot.py @@ -179,7 +179,7 @@ def main() -> None: application.add_handler(PollHandler(receive_quiz_answer)) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/rawapibot.py b/examples/rawapibot.py index 54b1fff39..03c8a548b 100644 --- a/examples/rawapibot.py +++ b/examples/rawapibot.py @@ -24,7 +24,7 @@ if __version_info__ < (20, 0, 0, "alpha", 1): f"{TG_VER} version of this example, " f"visit https://docs.python-telegram-bot.org/en/v{TG_VER}/examples.html" ) -from telegram import Bot +from telegram import Bot, Update from telegram.error import Forbidden, NetworkError logging.basicConfig( @@ -58,7 +58,7 @@ async def main() -> NoReturn: async def echo(bot: Bot, update_id: int) -> int: """Echo the message the user sent.""" # Request updates after the last update_id - updates = await bot.get_updates(offset=update_id, timeout=10) + updates = await bot.get_updates(offset=update_id, timeout=10, allowed_updates=Update.ALL_TYPES) for update in updates: next_update_id = update.update_id + 1 diff --git a/examples/timerbot.py b/examples/timerbot.py index 9c49b5588..3c9e7a742 100644 --- a/examples/timerbot.py +++ b/examples/timerbot.py @@ -114,7 +114,7 @@ def main() -> None: application.add_handler(CommandHandler("unset", unset)) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__": diff --git a/examples/webappbot.py b/examples/webappbot.py index 011d9dae6..4a2198012 100644 --- a/examples/webappbot.py +++ b/examples/webappbot.py @@ -70,7 +70,7 @@ def main() -> None: application.add_handler(MessageHandler(filters.StatusUpdate.WEB_APP_DATA, web_app_data)) # Run the bot until the user presses Ctrl-C - application.run_polling() + application.run_polling(allowed_updates=Update.ALL_TYPES) if __name__ == "__main__":