D
D
Dmitry2021-12-07 15:15:02
Python
Dmitry, 2021-12-07 15:15:02

How to prevent the removal of a link, on behalf of a supergroup?

Tell me how to prevent the removal of links, on behalf of the super group.

import telebot
import time 
from telebot import types

bot = telebot.TeleBot("Moy_token")

@bot.message_handler(func=lambda message: message.entities is not None and message.chat.id)
def delete_links(message):
    for entity in message.entities:
        if entity.type in ["url", "text_link"]:
            bot.delete_message(message.chat.id, message.message_id)
        else:
            return

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-12-07
@SoreMix

See who sent the message, and if the sender is a supergroup, then do nothing.

if message.sender_chat and message.sender_chat == “supergroup”:
    return

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question