add gban watcher

This commit is contained in:
levina 2022-01-25 15:05:59 +07:00 committed by GitHub
parent 598e475f16
commit 8f366ad2a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,7 @@ from config import (
from program import __version__
from driver.veez import user
from driver.filters import command, other_filters
from driver.database.dbpunish import is_gbanned_user
from pyrogram import Client, filters
from pyrogram import __version__ as pyrover
from pytgcalls import (__version__ as pytover)
@ -164,3 +165,22 @@ async def new_chat(c: Client, m: Message):
]
)
)
chat_watcher_group = 5
@Client.on_message(group=chat_watcher_group)
async def chat_watcher_func(_, message: Message):
try:
userid = message.from_user.id
except Exception:
return
suspect = f"[{message.from_user.first_name}](tg://user?id={message.from_user.id})"
if await is_gbanned_user(userid):
try:
await message.chat.ban_member(userid)
except Exception:
return
await message.reply_text(
f"👮🏼 (> {suspect} <)\n\n**Gbanned** user joined, that user has been gbanned by sudo user and was blocked from this Chat !\n\n🚫 **Reason:** potential spammer and abuser."
)