mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-21 22:56:38 +01:00
Explicitly set allowed_updates
in Examples (#3741)
This commit is contained in:
parent
f0e71216fe
commit
1a7edd7a5d
19 changed files with 20 additions and 20 deletions
|
@ -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__":
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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__":
|
||||
|
|
|
@ -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__":
|
||||
|
|
Loading…
Reference in a new issue