This code sends a message to the Telegram Supergroup if a new member has joined. When an error occurs when sending a message, I want to change my account to continue. It is possible to go to the next "item". How do I go to the next account in a loop when I receive an error?
from pyrogram import Client, Filters
list_account = ['001', '002']
for item in list_account:
app = Client(item)
@app.on_message(Filters.chat("public_link_chat") & Filters.new_chat_members)
def welcome(client, message):
try:
client.send_message(
message.chat.id, 'Test',
reply_to_message_id=message.message_id,
disable_web_page_preview=True
)
except Exception as e:
print(e)
# How do I go to the next account in a loop when I receive an error?
app.start()
app.join_chat("public_link_chat")
app.idle()
Function "continue" does not work in this case.
Description of function here: https://docs.pyrogram.ml/resources/UpdateHandling