简体   繁体   中英

How can I delete 'new chat members' messages in telegram group with pytelegrambotapi?

My code sample (currently not working):

import telebot
bot = telebot.TeleBot(token)

@bot.message_handler(content_types=['new_chat_members', 'left_chat_member'])
def bot_func(message):
    bot.delete_message(message.chat.id, message.message_id)

Any ideas on how to make this work?

consider the bot permissions added to the group, this code is sufficient

bot = Bot(token=TOKEN)
dp = Dispatcher(bot)


@dp.message_handler(content_types=['new_chat_members', 'left_chat_member'])
async def on_user_joined(message: types.Message):
    print("JOIN message removed")
    await message.delete()

如果我想删除留言?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM