2022-08-07 04:45:35 -04:00
|
|
|
from load import bot, dp, types
|
|
|
|
|
|
|
|
import config
|
2022-11-06 03:48:10 -05:00
|
|
|
from database import Member
|
2022-08-07 04:45:35 -04:00
|
|
|
|
2022-12-01 05:54:32 -05:00
|
|
|
|
2023-01-22 05:27:20 -05:00
|
|
|
@dp.message_handler(
|
|
|
|
commands=["start", "help"],
|
|
|
|
chat_type=[types.ChatType.SUPERGROUP]
|
|
|
|
)
|
|
|
|
async def start_command_group(message: types.Message):
|
2022-08-07 04:45:35 -04:00
|
|
|
await message.answer((
|
|
|
|
f"Hi,**{message.from_user.first_name}**!\n"
|
|
|
|
"My commands:\n"
|
2022-12-01 05:54:32 -05:00
|
|
|
" /help , /start - read the message\n"
|
|
|
|
" /me , /bio - member information (if member group)"),
|
2022-08-07 04:45:35 -04:00
|
|
|
parse_mode="Markdown"
|
|
|
|
)
|
|
|
|
|
2023-01-22 05:27:20 -05:00
|
|
|
|
|
|
|
@dp.message_handler(
|
|
|
|
commands=["leave"],
|
|
|
|
chat_type=[types.ChatType.SUPERGROUP]
|
|
|
|
)
|
|
|
|
async def leave_group(message: types.Message):
|
2022-11-06 09:57:15 -05:00
|
|
|
user = message.from_user
|
2022-12-01 05:54:32 -05:00
|
|
|
|
|
|
|
if (message.text.split()[0] != "I UNDERSTAND!"):
|
2022-11-06 09:57:15 -05:00
|
|
|
await message.answer("use /leave I UNDERSTAND")
|
|
|
|
return
|
|
|
|
|
2022-12-01 05:54:32 -05:00
|
|
|
Member.delete().get(Member.user_id == user.id)
|
2022-11-06 09:57:15 -05:00
|
|
|
|
2023-01-22 05:27:20 -05:00
|
|
|
status = await bot.kick_chat_member(
|
|
|
|
chat_id=message.chat.id,
|
|
|
|
user_id=user.id,
|
|
|
|
until_date=None
|
|
|
|
)
|
2022-11-06 09:57:15 -05:00
|
|
|
|
|
|
|
if status:
|
2023-01-22 05:27:20 -05:00
|
|
|
await message.answer((
|
|
|
|
f"User [{user.first_name}](tg://user?id={user.id})"
|
|
|
|
"has leaved chat for forever"
|
|
|
|
), parse_mode="Markdown"
|
|
|
|
)
|
2022-11-06 09:57:15 -05:00
|
|
|
|
2023-01-22 05:27:20 -05:00
|
|
|
Member.delete().where(Member.user_id == user.id).execute()
|
|
|
|
|
2022-08-16 06:28:08 -04:00
|
|
|
|
2023-01-22 05:27:20 -05:00
|
|
|
@dp.message_handler(
|
|
|
|
commands=["bio", "me"],
|
|
|
|
chat_type=[types.ChatType.SUPERGROUP]
|
|
|
|
)
|
2022-08-07 04:45:35 -04:00
|
|
|
async def get_information(message: types.Message):
|
2022-12-01 05:54:32 -05:00
|
|
|
user = Member.get(Member.user_id == message.from_user.id)
|
2022-08-07 04:45:35 -04:00
|
|
|
|
|
|
|
await message.answer((
|
2022-11-06 03:48:10 -05:00
|
|
|
f"[{user.first_name}](tg://user?id={user.user_id}) ({user.role})\n"
|
|
|
|
f"Warns: {user.warns}/{config.limit_of_warns}"),
|
2022-08-07 04:45:35 -04:00
|
|
|
parse_mode="Markdown"
|
|
|
|
)
|
|
|
|
|
2022-08-16 06:28:08 -04:00
|
|
|
|
2022-12-01 05:54:32 -05:00
|
|
|
@dp.message_handler(
|
2023-01-22 05:27:20 -05:00
|
|
|
commands=["report2"],
|
2022-12-01 05:54:32 -05:00
|
|
|
replied=True,
|
|
|
|
chat_type=[types.ChatType.SUPERGROUP]
|
|
|
|
)
|
|
|
|
async def user_report(message: types.Message):
|
2022-08-07 04:45:35 -04:00
|
|
|
args = message.text.split()
|
2022-12-01 05:54:32 -05:00
|
|
|
|
2022-08-07 04:45:35 -04:00
|
|
|
if (len(args) != 2):
|
2023-01-22 05:27:20 -05:00
|
|
|
await message.answer("/report (reason)")
|
2022-08-07 04:45:35 -04:00
|
|
|
return
|
|
|
|
|
|
|
|
reported_user = message.reply_to_message.from_user
|
|
|
|
reporter_user = message.from_user
|
2023-01-22 05:27:20 -05:00
|
|
|
reason = args[1]
|
2022-08-07 04:45:35 -04:00
|
|
|
|
2022-12-01 05:54:32 -05:00
|
|
|
await bot.send_message(
|
|
|
|
config.second_group_id,
|
|
|
|
(
|
2022-12-25 09:17:05 -05:00
|
|
|
"Complaint about: [{}](tg://user?id={})\n"
|
2023-01-22 05:27:20 -05:00
|
|
|
"Complaint from: [{}](tg://user?id={})\n\n"
|
|
|
|
"Note: {}\n"
|
2022-12-01 05:54:32 -05:00
|
|
|
"{}"
|
|
|
|
).format(
|
|
|
|
reported_user.first_name,
|
|
|
|
reported_user.id,
|
|
|
|
reporter_user.first_name,
|
|
|
|
reporter_user.id,
|
|
|
|
reason,
|
2023-01-22 05:27:20 -05:00
|
|
|
message.reply_to_message.link("link message", as_html=False)
|
2022-12-01 05:54:32 -05:00
|
|
|
),
|
2023-01-22 05:27:20 -05:00
|
|
|
parse_mode="Markdown",
|
2022-12-01 05:54:32 -05:00
|
|
|
)
|