حذف کردن یک کاربر خاص هنگام ورود به گروه
This commit is contained in:
@@ -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
@@ -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"
|
||||||
|
|||||||
Reference in New Issue
Block a user