حذف کردن یک کاربر خاص هنگام ورود به گروه

This commit is contained in:
2026-09-05 09:44:47 +03:30
parent 1aac5af086
commit c7639a251f
2 changed files with 12 additions and 1 deletions
+2
View File
@@ -7,6 +7,8 @@ load_dotenv()
BOT_TOKEN = os.getenv("BOT_TOKEN") BOT_TOKEN = os.getenv("BOT_TOKEN")
IM = int(os.getenv('im'))
if not BOT_TOKEN: if not BOT_TOKEN:
raise ValueError("BOT_TOKEN is not set") raise ValueError("BOT_TOKEN is not set")
+10 -1
View File
@@ -3,6 +3,7 @@ import logging
from bot import bot from bot import bot
from balethon.conditions import equals, regex from balethon.conditions import equals, regex
from config import IM
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -152,7 +153,15 @@ async def welcome(message):
if member.is_bot: if member.is_bot:
continue continue
try:
if member.id == IM:
await bot.ban_chat_member(
chat_id=message.chat.id,
user_id=member.id,
)
return
except Exception as e:
print(e)
await message.reply( await message.reply(
f"👋 سلام {member.first_name} عزیز\n" f"👋 سلام {member.first_name} عزیز\n"
f"به گروه {message.chat.title} خوش آمدید.\n" f"به گروه {message.chat.title} خوش آمدید.\n"