Skip to content

Commit

Permalink
Explicitly set allowed_updates in Examples (#3741)
Browse files Browse the repository at this point in the history
  • Loading branch information
Trifase committed Jun 4, 2023
1 parent f0e7121 commit 1a7edd7
Show file tree
Hide file tree
Showing 19 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion examples/arbitrarycallbackdatabot.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/contexttypesbot.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/conversationbot.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/conversationbot2.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/customwebhookbot.py
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion examples/deeplinking.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/echobot.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/errorhandlerbot.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/inlinebot.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/inlinekeyboard.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/inlinekeyboard2.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/nestedconversationbot.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/passportbot.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/paymentbot.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/persistentconversationbot.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/pollbot.py
Expand Up @@ -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__":
Expand Down
4 changes: 2 additions & 2 deletions examples/rawapibot.py
Expand Up @@ -24,7 +24,7 @@
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(
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion examples/timerbot.py
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion examples/webappbot.py
Expand Up @@ -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__":
Expand Down

0 comments on commit 1a7edd7

Please sign in to comment.