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
2023-03-09 16:31:39 +01:00

101 lines
2.8 KiB
Python

from app import app
from pyrogram.types import (
InlineKeyboardMarkup,
InlineKeyboardButton,
ChatPermissions,
CallbackQuery,
)
from pyrogram.client import Client
from pyrogram import filters
from classes.holo_user import HoloUser
from modules.utils import configGet, locale, logWrite
from modules.database import col_tmp
@app.on_callback_query(filters.regex("sus_allow_[\s\S]*"))
async def callback_query_sus_allow(app: Client, clb: CallbackQuery):
fullclb = clb.data.split("_")
holo_user = HoloUser(int(fullclb[2]))
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}"
)
edited_markup = [
[
InlineKeyboardButton(
text=str(locale("sus_allowed", "button")), callback_data="nothing"
)
]
]
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,
)
await app.restrict_chat_member(
configGet("users", "groups"),
holo_user.id,
permissions=ChatPermissions(
can_send_messages=True,
can_send_media_messages=True,
can_send_other_messages=True,
can_send_polls=True,
),
)
@app.on_callback_query(filters.regex("sus_reject_[\s\S]*"))
async def callback_query_sus_reject(app: Client, clb: CallbackQuery):
fullclb = clb.data.split("_")
holo_user = HoloUser(int(fullclb[2]))
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}"
)
edited_markup = [
[
InlineKeyboardButton(
text=str(locale("sus_rejected", "button")), callback_data="nothing"
)
]
]
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,
)
await app.ban_chat_member(configGet("users", "groups"), holo_user.id)
col_tmp.update_one(
{"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}},
{"$set": {"state": "rejected", "sent": False}},
)