Explicitly set allowed_updates in Examples (#3741)

This commit is contained in:
Luca Bellanti 2023-06-04 17:11:58 +02:00 committed by GitHub
parent f0e71216fe
commit 1a7edd7a5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 20 additions and 20 deletions

View file

@ -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__":

View file

@ -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__":

View file

@ -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__":

View file

@ -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__":

View file

@ -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:

View file

@ -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__":

View file

@ -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__":

View file

@ -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__":

View file

@ -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__":

View file

@ -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__":

View file

@ -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__":

View file

@ -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__":

View file

@ -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__":

View file

@ -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__":

View file

@ -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__":

View file

@ -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__":

View file

@ -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

View file

@ -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__":

View file

@ -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__":