This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Telegram/modules/callbacks/sus.py

105 lines
3.1 KiB
Python
Raw Normal View History

2022-12-05 19:49:51 +02:00
from app import app
2023-03-09 17:25:06 +02:00
from pyrogram.types import (
InlineKeyboardMarkup,
InlineKeyboardButton,
ChatPermissions,
CallbackQuery,
)
2022-12-27 14:36:54 +02:00
from pyrogram.client import Client
2022-12-05 19:53:09 +02:00
from pyrogram import filters
2022-12-15 15:32:17 +02:00
from classes.holo_user import HoloUser
from modules.utils import configGet, locale, logWrite
from modules.database import col_tmp
2022-12-05 19:49:51 +02:00
2023-03-09 17:25:06 +02:00
2022-12-05 19:49:51 +02:00
# Callbacks sus users ==========================================================================================================
@app.on_callback_query(filters.regex("sus_allow_[\s\S]*"))
2022-12-27 14:36:54 +02:00
async def callback_query_sus_allow(app: Client, clb: CallbackQuery):
2022-12-05 19:49:51 +02:00
fullclb = clb.data.split("_")
2022-12-15 15:32:17 +02:00
holo_user = HoloUser(int(fullclb[2]))
2022-12-05 19:49:51 +02:00
2023-03-09 17:25:06 +02:00
await app.send_message(
configGet("admin", "groups"),
locale("sus_allowed_by", "message").format(
clb.from_user.first_name, holo_user.id
),
disable_notification=True,
)
logWrite(
f"User {holo_user.id} was allowed to join with another link by {clb.from_user.id}"
)
2022-12-05 19:49:51 +02:00
2023-03-09 17:25:06 +02:00
edited_markup = [
[
InlineKeyboardButton(
text=str(locale("sus_allowed", "button")), callback_data="nothing"
)
]
]
2022-12-05 19:49:51 +02:00
2023-03-09 17:25:06 +02:00
await clb.message.edit(
text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)
)
await clb.answer(
text=locale("sus_allowed", "callback", locale=clb.from_user).format(
holo_user.id
),
show_alert=True,
)
2022-12-05 19:49:51 +02:00
2023-03-09 17:25:06 +02:00
await app.restrict_chat_member(
configGet("users", "groups"),
holo_user.id,
permissions=ChatPermissions(
2022-12-05 19:49:51 +02:00
can_send_messages=True,
can_send_media_messages=True,
can_send_other_messages=True,
2023-03-09 17:25:06 +02:00
can_send_polls=True,
),
2022-12-05 19:49:51 +02:00
)
2023-03-09 17:25:06 +02:00
2022-12-15 14:50:11 +02:00
@app.on_callback_query(filters.regex("sus_reject_[\s\S]*"))
2022-12-27 14:36:54 +02:00
async def callback_query_sus_reject(app: Client, clb: CallbackQuery):
2022-12-05 19:49:51 +02:00
fullclb = clb.data.split("_")
2022-12-15 15:32:17 +02:00
holo_user = HoloUser(int(fullclb[2]))
2022-12-05 19:49:51 +02:00
2023-03-09 17:25:06 +02:00
await app.send_message(
configGet("admin", "groups"),
locale("sus_rejected_by", "message").format(
clb.from_user.first_name, holo_user.id
),
disable_notification=True,
)
logWrite(
f"User {holo_user.id} was rejected to join with another link by {clb.from_user.id}"
)
2022-12-05 19:49:51 +02:00
2023-03-09 17:25:06 +02:00
edited_markup = [
[
InlineKeyboardButton(
text=str(locale("sus_rejected", "button")), callback_data="nothing"
)
]
]
2022-12-05 19:49:51 +02:00
2023-03-09 17:25:06 +02:00
await clb.message.edit(
text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)
)
await clb.answer(
text=locale("sus_rejected", "callback", locale=clb.from_user).format(
holo_user.id
),
show_alert=True,
)
2022-12-05 19:49:51 +02:00
2023-01-04 20:59:09 +02:00
await app.ban_chat_member(configGet("users", "groups"), holo_user.id)
2022-12-05 19:49:51 +02:00
2023-03-09 17:25:06 +02:00
col_tmp.update_one(
{"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}},
{"$set": {"state": "rejected", "sent": False}},
)
# ==============================================================================================================================