It is not possible to send a welcome message after accepting users into the channel pyrogram

33 Views Asked by At

After accepting all applications, I want a decorator to work that will send a newsletter to new users. The example is taken from the official documentation, but it doesn't work for me, please tell me what could be the reason?

channel = -1001941764466
app = Client("account", api_id, api_hash)
MESSAGE = "{} Welcome to [Pyrogram](https://docs.pyrogram.org/)'s group chat {}!"

@app.on_message()
async def approve_all_join_requests(client, message):
    if message.text == "/approve_all":
        await app.approve_all_chat_join_requests(chat_id=channel)
        await message.reply_text("All applications have been accepted")


# Filter in only new_chat_members updates generated in TARGET chat
@app.on_chat_member_updated(filters.chat(channel) & filters.new_chat_members)
async def welcome(client, message):
    # Build the new members list (with mentions) by using their first_name
    new_members = [u.mention for u in message.new_chat_members]
    # Build the welcome message by using an emoji and the list we built above
    text = MESSAGE.format(emoji.SPARKLES, ", ".join(new_members))
    # Send the welcome message, without the web page preview
    await message.reply_text(text, disable_web_page_preview=True)

app.run()  # Automatically start() and idle()

my test channel is closed and applications are accepted on command, but this did not work for an open channel either

0

There are 0 best solutions below