Fix /leave command
This commit is contained in:
parent
d390d2ebe9
commit
0706448755
|
@ -3,26 +3,6 @@ from load import bot, dp, types
|
|||
import config
|
||||
from database import Member
|
||||
|
||||
@dp.message_handler(commands=["leave"],chat_type=[types.ChatType.SUPERGROUP])
|
||||
async def leave_group(message:types.Message):
|
||||
user = message.from_user
|
||||
args = message.text.split()
|
||||
|
||||
# TODO: translate it too
|
||||
if (len(args) < 1) or not ( ' '.join(args[1:]) == "I UNDERSTAND" ):
|
||||
await message.answer("Для того чтобы покинуть чат вам нужно ввести /leave I UNDERSTANT!")
|
||||
return
|
||||
|
||||
# TODO: rewrite it
|
||||
# database.delete_user(user.id)
|
||||
|
||||
# Ban user and save (bool)
|
||||
status = await bot.kick_chat_member(chat_id=message.chat.id,user_id=user.id,until_date=None)
|
||||
|
||||
if status:
|
||||
await message.answer(f"User [{user.first_name}](tg://user?id={user.id}) has laved chat forever.",
|
||||
parse_mode="Markdown")
|
||||
|
||||
@dp.message_handler(commands=["start","help"],chat_type=[types.ChatType.SUPERGROUP])
|
||||
async def start_command_group(message:types.Message):
|
||||
await message.answer((
|
||||
|
@ -33,6 +13,24 @@ async def start_command_group(message:types.Message):
|
|||
parse_mode="Markdown"
|
||||
)
|
||||
|
||||
@dp.message_handler(commands=["leave"],chat_type=[types.ChatType.SUPERGROUP])
|
||||
async def leave_group(message:types.Message):
|
||||
user = message.from_user
|
||||
arguments = message.get_args()
|
||||
|
||||
if (arguments != "I UNDERSTAND!"):
|
||||
await message.answer("use /leave I UNDERSTAND")
|
||||
return
|
||||
|
||||
Member.delete().where(Member.user_id == user.id).execute()
|
||||
|
||||
# Ban user and save (bool)
|
||||
status = await bot.kick_chat_member(chat_id=message.chat.id,user_id=user.id,until_date=None)
|
||||
|
||||
if status:
|
||||
await message.answer(f"User [{user.first_name}](tg://user?id={user.id}) has laved chat forever",parse_mode="Markdown")
|
||||
|
||||
Member.delete().where(Member.user_id == user.id).execute()
|
||||
|
||||
@dp.message_handler(commands=["bio","me"],chat_type=[types.ChatType.SUPERGROUP])
|
||||
async def get_information(message: types.Message):
|
||||
|
|
Reference in New Issue