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

48 lines
2.5 KiB
Python
Raw Normal View History

2022-12-05 19:49:51 +02:00
from os import sep
from app import app
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, ChatPermissions
2022-12-05 19:53:09 +02:00
from pyrogram import filters
2022-12-05 19:49:51 +02:00
from modules.utils import configGet, configSet, jsonLoad, jsonSave, locale, logWrite
# Callbacks sus users ==========================================================================================================
@app.on_callback_query(filters.regex("sus_allow_[\s\S]*"))
2022-12-05 19:49:51 +02:00
async def callback_query_sus_allow(app, clb):
fullclb = clb.data.split("_")
await app.send_message(configGet("admin_group"), locale("sus_allowed_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True)
2022-12-05 19:49:51 +02:00
logWrite(f"User {fullclb[2]} 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").format(fullclb[2]), show_alert=True)
2022-12-05 19:49:51 +02:00
await app.restrict_chat_member(configGet("destination_group"), int(fullclb[2]), permissions=ChatPermissions(
can_send_messages=True,
can_send_media_messages=True,
can_send_other_messages=True,
can_send_polls=True
)
)
2022-12-15 14:50:11 +02:00
@app.on_callback_query(filters.regex("sus_reject_[\s\S]*"))
async def callback_query_sus_reject(app, clb):
2022-12-05 19:49:51 +02:00
fullclb = clb.data.split("_")
2022-12-15 14:50:11 +02:00
await app.send_message(configGet("admin_group"), locale("sus_rejected_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True)
logWrite(f"User {fullclb[2]} was rejected to join with another link by {clb.from_user.id}")
2022-12-05 19:49:51 +02:00
2022-12-15 14:50:11 +02:00
edited_markup = [[InlineKeyboardButton(text=str(locale("sus_rejected", "button")), callback_data="nothing")]]
2022-12-05 19:49:51 +02:00
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
2022-12-15 14:50:11 +02:00
await clb.answer(text=locale("sus_rejected", "callback").format(fullclb[2]), show_alert=True)
2022-12-05 19:49:51 +02:00
await app.ban_chat_member(configGet("destination_group"), int(fullclb[2]))
jsonSave(jsonLoad(f"{configGet('data', 'locations')}{sep}user_default.json"), f"{configGet('data', 'locations')}{sep}users{sep}{fullclb[2]}.json")
configSet(["stage"], 10, file=fullclb[2])
2022-12-15 14:50:11 +02:00
configSet(["rejected"], True, file=fullclb[2])
configSet(["rejected_by"], clb.from_user.id, file=fullclb[2])
2022-12-05 19:49:51 +02:00
# ==============================================================================================================================