async def on_url_message(event): chat = event.chat extracted_domains = [] for (ent, txt) in event.get_entities_text(): if ent.offset != 0: break if isinstance(ent, types.MessageEntityUrl): url = txt extract_url = tldextract.extract(url) extracted_domains.append(extract_url.domain + "." + extract_url.suffix) for url in urlsql.get_blacklisted_urls(chat.id): if url in extracted_domains: try: await event.delete() except: return
async def _(event): if event.fwd_from: return if event.is_private: return if event.is_group: if await can_change_info(message=event): pass else: return chat = event.chat base_string = "Current <b>blacklisted</b> domains:\n" blacklisted = urlsql.get_blacklisted_urls(chat.id) if not blacklisted: await event.reply("There are no blacklisted domains here!") return for domain in blacklisted: base_string += "- <code>{}</code>\n".format(domain) await event.reply(base_string, parse_mode="html")