Changed code style to black
This commit is contained in:
@@ -6,17 +6,25 @@ from modules.utils import locale
|
||||
from modules.database import col_bans
|
||||
from modules.logging import logWrite
|
||||
|
||||
|
||||
@app.on_callback_query(filters.regex("ban_[\s\S]*"))
|
||||
async def callback_query_reject(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
|
||||
if not await isAnAdmin(int(fullclb[1])):
|
||||
col_bans.insert_one( {"user": int(fullclb[1])} )
|
||||
col_bans.insert_one({"user": int(fullclb[1])})
|
||||
|
||||
edited_markup = [[InlineKeyboardButton(text=str(locale("banned", "button")), callback_data="nothing")]]
|
||||
edited_markup = [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("banned", "button")), callback_data="nothing"
|
||||
)
|
||||
]
|
||||
]
|
||||
|
||||
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await clb.message.edit(
|
||||
text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)
|
||||
)
|
||||
await clb.answer(text=locale("sub_banned", "callback", locale=clb.from_user))
|
||||
|
||||
logWrite(f"User {fullclb[1]} has been banned by {clb.from_user.id}")
|
||||
@@ -24,4 +32,4 @@ async def callback_query_reject(app: Client, clb: CallbackQuery):
|
||||
try:
|
||||
await app.send_message(int(fullclb[1]), locale("you_are_banned", "message"))
|
||||
except Exception as exp:
|
||||
logWrite(f"Could send ban message to {fullclb[1]} due to {exp}")
|
||||
logWrite(f"Could send ban message to {fullclb[1]} due to {exp}")
|
||||
|
@@ -4,8 +4,11 @@ from pyrogram.types import CallbackQuery
|
||||
from pyrogram.client import Client
|
||||
from modules.utils import locale
|
||||
|
||||
|
||||
# Callback empty ===============================================================================================================
|
||||
@app.on_callback_query(filters.regex("nothing"))
|
||||
async def callback_query_nothing(app: Client, clb: CallbackQuery):
|
||||
await clb.answer(text=locale("nothing", "callback", locale=clb.from_user))
|
||||
# ==============================================================================================================================
|
||||
|
||||
|
||||
# ==============================================================================================================================
|
||||
|
@@ -1,6 +1,11 @@
|
||||
from datetime import datetime
|
||||
from app import app
|
||||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, ReplyKeyboardRemove, CallbackQuery
|
||||
from pyrogram.types import (
|
||||
InlineKeyboardMarkup,
|
||||
InlineKeyboardButton,
|
||||
ReplyKeyboardRemove,
|
||||
CallbackQuery,
|
||||
)
|
||||
from pyrogram.client import Client
|
||||
from pyrogram import filters
|
||||
from classes.holo_user import HoloUser
|
||||
@@ -9,91 +14,194 @@ from modules.handlers.confirmation import confirm_yes
|
||||
from modules.handlers.welcome import welcome_pass
|
||||
from modules.database import col_tmp, col_applications
|
||||
|
||||
|
||||
# Callbacks reapply ============================================================================================================
|
||||
@app.on_callback_query(filters.regex("reapply_yes_[\s\S]*"))
|
||||
async def callback_reapply_query_accept(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(int(fullclb[2]))
|
||||
|
||||
await app.send_message(configGet("admin", "groups"), locale("approved_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
|
||||
logWrite(f"User {holo_user.id} got their reapplication approved by {clb.from_user.id}")
|
||||
await app.send_message(
|
||||
configGet("admin", "groups"),
|
||||
locale("approved_by", "message").format(clb.from_user.first_name, holo_user.id),
|
||||
disable_notification=True,
|
||||
)
|
||||
logWrite(
|
||||
f"User {holo_user.id} got their reapplication approved by {clb.from_user.id}"
|
||||
)
|
||||
|
||||
await app.send_message(holo_user.id, locale("approved_joined", "message", locale=holo_user))
|
||||
await app.send_message(
|
||||
holo_user.id, locale("approved_joined", "message", locale=holo_user)
|
||||
)
|
||||
|
||||
applications = col_applications.find({"user": holo_user.id})
|
||||
|
||||
if len(list(applications)) > 1:
|
||||
col_applications.delete_many({"user": holo_user.id})
|
||||
col_applications.insert_one({"user": holo_user.id, "date": datetime.now(), "admin": clb.from_user.id, "application": col_tmp.find_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}})["application"]})
|
||||
col_applications.insert_one(
|
||||
{
|
||||
"user": holo_user.id,
|
||||
"date": datetime.now(),
|
||||
"admin": clb.from_user.id,
|
||||
"application": col_tmp.find_one(
|
||||
{"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}}
|
||||
)["application"],
|
||||
}
|
||||
)
|
||||
elif applications == 1:
|
||||
col_applications.find_one_and_replace({"user": holo_user.id}, {"user": holo_user.id, "date": datetime.now(), "admin": clb.from_user.id, "application": col_tmp.find_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}})["application"]})
|
||||
col_applications.find_one_and_replace(
|
||||
{"user": holo_user.id},
|
||||
{
|
||||
"user": holo_user.id,
|
||||
"date": datetime.now(),
|
||||
"admin": clb.from_user.id,
|
||||
"application": col_tmp.find_one(
|
||||
{"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}}
|
||||
)["application"],
|
||||
},
|
||||
)
|
||||
else:
|
||||
col_applications.insert_one({"user": holo_user.id, "date": datetime.now(), "admin": clb.from_user.id, "application": col_tmp.find_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}})["application"]})
|
||||
col_tmp.update_one({"user": holo_user.id, "type": "application"}, {"$set": {"state": "approved", "sent": False}})
|
||||
col_applications.insert_one(
|
||||
{
|
||||
"user": holo_user.id,
|
||||
"date": datetime.now(),
|
||||
"admin": clb.from_user.id,
|
||||
"application": col_tmp.find_one(
|
||||
{"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}}
|
||||
)["application"],
|
||||
}
|
||||
)
|
||||
col_tmp.update_one(
|
||||
{"user": holo_user.id, "type": "application"},
|
||||
{"$set": {"state": "approved", "sent": False}},
|
||||
)
|
||||
|
||||
edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]]
|
||||
edited_markup = [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("accepted", "button")), callback_data="nothing"
|
||||
)
|
||||
]
|
||||
]
|
||||
|
||||
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await clb.answer(text=locale("sub_accepted", "callback", locale=clb.from_user).format(holo_user.id), show_alert=True)
|
||||
await clb.message.edit(
|
||||
text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)
|
||||
)
|
||||
await clb.answer(
|
||||
text=locale("sub_accepted", "callback", locale=clb.from_user).format(
|
||||
holo_user.id
|
||||
),
|
||||
show_alert=True,
|
||||
)
|
||||
|
||||
need_link = True
|
||||
|
||||
async for member in app.get_chat_members(configGet("users", "groups")):
|
||||
if member.user.id == holo_user.id:
|
||||
need_link = False
|
||||
|
||||
if need_link:
|
||||
link = await app.create_chat_invite_link(configGet("users", "groups"), name=f"Invite for {holo_user.id}", member_limit=1) #, expire_date=datetime.now()+timedelta(days=1))
|
||||
|
||||
await app.send_message(holo_user.id, locale("read_rules", "message", locale=holo_user))
|
||||
if need_link:
|
||||
link = await app.create_chat_invite_link(
|
||||
configGet("users", "groups"),
|
||||
name=f"Invite for {holo_user.id}",
|
||||
member_limit=1,
|
||||
) # , expire_date=datetime.now()+timedelta(days=1))
|
||||
|
||||
await app.send_message(
|
||||
holo_user.id, locale("read_rules", "message", locale=holo_user)
|
||||
)
|
||||
|
||||
for rule_msg in locale("rules", locale=holo_user):
|
||||
await app.send_message(holo_user.id, rule_msg)
|
||||
|
||||
await app.send_message(holo_user.id, locale("approved", "message"), reply_markup=InlineKeyboardMarkup(
|
||||
[[
|
||||
InlineKeyboardButton(str(locale("join", "button", locale=holo_user)), url=link.invite_link)
|
||||
]]
|
||||
))
|
||||
await app.send_message(
|
||||
holo_user.id,
|
||||
locale("approved", "message"),
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
str(locale("join", "button", locale=holo_user)),
|
||||
url=link.invite_link,
|
||||
)
|
||||
]
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
holo_user.set("link", link.invite_link)
|
||||
logWrite(f"User {holo_user.id} got an invite link {link.invite_link}")
|
||||
|
||||
else:
|
||||
await app.send_message(holo_user.id, locale("approved_joined", "message", locale=holo_user))
|
||||
await app.send_message(
|
||||
holo_user.id, locale("approved_joined", "message", locale=holo_user)
|
||||
)
|
||||
|
||||
|
||||
@app.on_callback_query(filters.regex("reapply_no_[\s\S]*"))
|
||||
async def callback_query_reapply_reject(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(int(fullclb[2]))
|
||||
|
||||
await app.send_message(configGet("admin", "groups"), locale("rejected_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True)
|
||||
await app.send_message(holo_user.id, locale("rejected", "message", locale=holo_user))
|
||||
logWrite(f"User {fullclb[2]} got their reapplication rejected by {clb.from_user.id}")
|
||||
await app.send_message(
|
||||
configGet("admin", "groups"),
|
||||
locale("rejected_by", "message").format(clb.from_user.first_name, fullclb[2]),
|
||||
disable_notification=True,
|
||||
)
|
||||
await app.send_message(
|
||||
holo_user.id, locale("rejected", "message", locale=holo_user)
|
||||
)
|
||||
logWrite(
|
||||
f"User {fullclb[2]} got their reapplication rejected by {clb.from_user.id}"
|
||||
)
|
||||
|
||||
col_tmp.update_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}}, {"$set": {"state": "rejected", "sent": False}})
|
||||
col_tmp.update_one(
|
||||
{"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}},
|
||||
{"$set": {"state": "rejected", "sent": False}},
|
||||
)
|
||||
|
||||
edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")], [InlineKeyboardButton(text=str(locale("ban", "button")), callback_data=f"ban_{fullclb[2]}")]]
|
||||
edited_markup = [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("declined", "button")), callback_data="nothing"
|
||||
)
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("ban", "button")), callback_data=f"ban_{fullclb[2]}"
|
||||
)
|
||||
],
|
||||
]
|
||||
|
||||
await clb.message.edit(
|
||||
text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)
|
||||
)
|
||||
await clb.answer(
|
||||
text=locale("sub_rejected", "callback", locale=clb.from_user).format(
|
||||
fullclb[2]
|
||||
),
|
||||
show_alert=True,
|
||||
)
|
||||
|
||||
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await clb.answer(text=locale("sub_rejected", "callback", locale=clb.from_user).format(fullclb[2]), show_alert=True)
|
||||
|
||||
# Use old application when user reapplies after leaving the chat
|
||||
@app.on_callback_query(filters.regex("reapply_old_[\s\S]*"))
|
||||
async def callback_query_reapply_old(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(clb.from_user)
|
||||
|
||||
if holo_user.sponsorship_state()[0] == "fill":
|
||||
await clb.message.reply_text(locale("finish_sponsorship", "message"), quote=False)
|
||||
await clb.message.reply_text(
|
||||
locale("finish_sponsorship", "message"), quote=False
|
||||
)
|
||||
return
|
||||
|
||||
message = await app.get_messages(clb.from_user.id, int(fullclb[2]))
|
||||
|
||||
if col_tmp.find_one({"user": holo_user.id, "type": "application"}) is None and col_applications.find_one({"user": holo_user.id}) is not None:
|
||||
if (
|
||||
col_tmp.find_one({"user": holo_user.id, "type": "application"}) is None
|
||||
and col_applications.find_one({"user": holo_user.id}) is not None
|
||||
):
|
||||
col_tmp.insert_one(
|
||||
{
|
||||
"user": holo_user.id,
|
||||
@@ -103,37 +211,68 @@ async def callback_query_reapply_old(app: Client, clb: CallbackQuery):
|
||||
"state": "fill",
|
||||
"reapply": True,
|
||||
"stage": 10,
|
||||
"application": col_applications.find_one({"user": holo_user.id})["application"]
|
||||
"application": col_applications.find_one({"user": holo_user.id})[
|
||||
"application"
|
||||
],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
await confirm_yes(app, message, kind="application")
|
||||
await clb.message.edit(clb.message.text, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("done", "button", locale=clb.from_user), "nothing")]]))
|
||||
await clb.message.edit(
|
||||
clb.message.text,
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
locale("done", "button", locale=clb.from_user), "nothing"
|
||||
)
|
||||
]
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
# Start a new application when user reapplies after leaving the chat
|
||||
@app.on_callback_query(filters.regex("reapply_new_[\s\S]*"))
|
||||
async def callback_query_reapply_new(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
|
||||
holo_user = HoloUser(clb.from_user)
|
||||
|
||||
if holo_user.sponsorship_state()[0] == "fill":
|
||||
await clb.message.reply_text(locale("finish_sponsorship", "message"), quote=False)
|
||||
await clb.message.reply_text(
|
||||
locale("finish_sponsorship", "message"), quote=False
|
||||
)
|
||||
return
|
||||
|
||||
await clb.answer(locale("reapply_stopped", "callback", locale=clb.from_user))
|
||||
message = await app.get_messages(clb.from_user.id, int(fullclb[2]))
|
||||
col_tmp.update_one({"user": clb.from_user.id, "type": "application"}, {"$set": {"state": "fill", "completed": False, "stage": 1}})
|
||||
col_tmp.update_one(
|
||||
{"user": clb.from_user.id, "type": "application"},
|
||||
{"$set": {"state": "fill", "completed": False, "stage": 1}},
|
||||
)
|
||||
holo_user.application_restart(reapply=True)
|
||||
await welcome_pass(app, message, once_again=True)
|
||||
logWrite(f"User {clb.from_user.id} restarted the application after leaving the chat earlier")
|
||||
await clb.message.edit(clb.message.text, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("done", "button", locale=clb.from_user), "nothing")]]))
|
||||
logWrite(
|
||||
f"User {clb.from_user.id} restarted the application after leaving the chat earlier"
|
||||
)
|
||||
await clb.message.edit(
|
||||
clb.message.text,
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
locale("done", "button", locale=clb.from_user), "nothing"
|
||||
)
|
||||
]
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
# Abort application fill in progress and restart it
|
||||
@app.on_callback_query(filters.regex("reapply_stop_[\s\S]*"))
|
||||
async def callback_query_reapply_stop(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(clb.from_user)
|
||||
|
||||
@@ -142,5 +281,10 @@ async def callback_query_reapply_stop(app: Client, clb: CallbackQuery):
|
||||
message = await app.get_messages(clb.from_user.id, int(fullclb[2]))
|
||||
await welcome_pass(app, message, once_again=True)
|
||||
logWrite(f"User {clb.from_user.id} restarted the application due to typo in it")
|
||||
await clb.message.edit(locale("reapply_restarted", "message", locale=holo_user), reply_markup=ReplyKeyboardRemove())
|
||||
# ==============================================================================================================================
|
||||
await clb.message.edit(
|
||||
locale("reapply_restarted", "message", locale=holo_user),
|
||||
reply_markup=ReplyKeyboardRemove(),
|
||||
)
|
||||
|
||||
|
||||
# ==============================================================================================================================
|
||||
|
@@ -6,10 +6,10 @@ from pyrogram import filters
|
||||
from modules.utils import locale, logWrite
|
||||
from modules.commands.rules import DefaultRulesMarkup
|
||||
|
||||
|
||||
# Callback rule ================================================================================================================
|
||||
@app.on_callback_query(filters.regex("rule_[\s\S]*"))
|
||||
async def callback_query_rule(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
|
||||
logWrite(f"User {clb.from_user.id} requested to check out rule {fullclb[1]}")
|
||||
@@ -18,55 +18,88 @@ async def callback_query_rule(app: Client, clb: CallbackQuery):
|
||||
|
||||
if rule_num == len(locale("rules")):
|
||||
lower_buttons = [
|
||||
InlineKeyboardButton(locale("rules_prev", "button", locale=clb.from_user), callback_data=f"rule_{rule_num-1}")
|
||||
InlineKeyboardButton(
|
||||
locale("rules_prev", "button", locale=clb.from_user),
|
||||
callback_data=f"rule_{rule_num-1}",
|
||||
)
|
||||
]
|
||||
elif rule_num == 1:
|
||||
lower_buttons = [
|
||||
InlineKeyboardButton(locale("rules_next", "button", locale=clb.from_user), callback_data=f"rule_{rule_num+1}")
|
||||
InlineKeyboardButton(
|
||||
locale("rules_next", "button", locale=clb.from_user),
|
||||
callback_data=f"rule_{rule_num+1}",
|
||||
)
|
||||
]
|
||||
else:
|
||||
lower_buttons = [
|
||||
InlineKeyboardButton(locale("rules_prev", "button", locale=clb.from_user), callback_data=f"rule_{rule_num-1}"),
|
||||
InlineKeyboardButton(locale("rules_next", "button", locale=clb.from_user), callback_data=f"rule_{rule_num+1}")
|
||||
InlineKeyboardButton(
|
||||
locale("rules_prev", "button", locale=clb.from_user),
|
||||
callback_data=f"rule_{rule_num-1}",
|
||||
),
|
||||
InlineKeyboardButton(
|
||||
locale("rules_next", "button", locale=clb.from_user),
|
||||
callback_data=f"rule_{rule_num+1}",
|
||||
),
|
||||
]
|
||||
|
||||
try:
|
||||
await clb.message.edit(text=locale("rules", locale=clb.from_user)[rule_num-1], disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(
|
||||
await clb.message.edit(
|
||||
text=locale("rules", locale=clb.from_user)[rule_num - 1],
|
||||
disable_web_page_preview=True,
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton(locale("rules_home", "button", locale=clb.from_user), callback_data="rules_home"),
|
||||
InlineKeyboardButton(locale("rules_additional", "button", locale=clb.from_user), callback_data="rules_additional")
|
||||
InlineKeyboardButton(
|
||||
locale("rules_home", "button", locale=clb.from_user),
|
||||
callback_data="rules_home",
|
||||
),
|
||||
InlineKeyboardButton(
|
||||
locale("rules_additional", "button", locale=clb.from_user),
|
||||
callback_data="rules_additional",
|
||||
),
|
||||
],
|
||||
lower_buttons
|
||||
lower_buttons,
|
||||
]
|
||||
)
|
||||
),
|
||||
)
|
||||
except bad_request_400.MessageNotModified:
|
||||
pass
|
||||
|
||||
await clb.answer(text=locale("rules_page", "callback", locale=clb.from_user).format(fullclb[1]))
|
||||
await clb.answer(
|
||||
text=locale("rules_page", "callback", locale=clb.from_user).format(fullclb[1])
|
||||
)
|
||||
|
||||
|
||||
@app.on_callback_query(filters.regex("rules_home"))
|
||||
async def callback_query_rules_home(app: Client, clb: CallbackQuery):
|
||||
|
||||
logWrite(f"User {clb.from_user.id} requested to check out homepage rules")
|
||||
|
||||
try:
|
||||
await clb.message.edit(text=locale("rules_msg", locale=clb.from_user), disable_web_page_preview=True, reply_markup=DefaultRulesMarkup(clb.from_user).keyboard)
|
||||
await clb.message.edit(
|
||||
text=locale("rules_msg", locale=clb.from_user),
|
||||
disable_web_page_preview=True,
|
||||
reply_markup=DefaultRulesMarkup(clb.from_user).keyboard,
|
||||
)
|
||||
except bad_request_400.MessageNotModified:
|
||||
pass
|
||||
|
||||
await clb.answer(text=locale("rules_home", "callback", locale=clb.from_user))
|
||||
|
||||
|
||||
@app.on_callback_query(filters.regex("rules_additional"))
|
||||
async def callback_query_rules_additional(app: Client, clb: CallbackQuery):
|
||||
|
||||
logWrite(f"User {clb.from_user.id} requested to check out additional rules")
|
||||
|
||||
try:
|
||||
await clb.message.edit(text=locale("rules_additional", locale=clb.from_user), disable_web_page_preview=True, reply_markup=DefaultRulesMarkup(clb.from_user).keyboard)
|
||||
await clb.message.edit(
|
||||
text=locale("rules_additional", locale=clb.from_user),
|
||||
disable_web_page_preview=True,
|
||||
reply_markup=DefaultRulesMarkup(clb.from_user).keyboard,
|
||||
)
|
||||
except bad_request_400.MessageNotModified:
|
||||
pass
|
||||
|
||||
await clb.answer(text=locale("rules_additional", "callback", locale=clb.from_user))
|
||||
# ==============================================================================================================================
|
||||
|
||||
|
||||
# ==============================================================================================================================
|
||||
|
@@ -8,29 +8,78 @@ from bson.objectid import ObjectId
|
||||
|
||||
from modules.utils import configGet, jsonLoad, locale
|
||||
|
||||
|
||||
# Callback sid =================================================================================================================
|
||||
@app.on_callback_query(filters.regex("sid_[\s\S]*"))
|
||||
async def callback_query_sid(app: Client, clb: CallbackQuery):
|
||||
await clb.answer(url=f'https://t.me/{(await app.get_me()).username}?start={clb.data.split("_")[1]}')
|
||||
await clb.answer(
|
||||
url=f'https://t.me/{(await app.get_me()).username}?start={clb.data.split("_")[1]}'
|
||||
)
|
||||
|
||||
|
||||
# ==============================================================================================================================
|
||||
|
||||
|
||||
# Callback shc =================================================================================================================
|
||||
@app.on_callback_query(filters.regex("shc_[\s\S]*"))
|
||||
async def callback_query_shc(app: Client, clb: CallbackQuery):
|
||||
|
||||
if (clb.from_user.id not in jsonLoad(path.join(configGet("cache", "locations"), "group_members"))):
|
||||
await clb.answer(locale("spoiler_forbidden", "callback", locale=clb.from_user), show_alert=True)
|
||||
if clb.from_user.id not in jsonLoad(
|
||||
path.join(configGet("cache", "locations"), "group_members")
|
||||
):
|
||||
await clb.answer(
|
||||
locale("spoiler_forbidden", "callback", locale=clb.from_user),
|
||||
show_alert=True,
|
||||
)
|
||||
return
|
||||
|
||||
spoil = col_spoilers.find_one( {"_id": ObjectId(clb.data.split("_")[1])} )
|
||||
spoil = col_spoilers.find_one({"_id": ObjectId(clb.data.split("_")[1])})
|
||||
|
||||
if spoil["description"] == "":
|
||||
desc = locale("spoiler_empty_named", "message", locale=clb.from_user).format(locale(spoil["category"], "message", "spoiler_categories"), clb.from_user.first_name)
|
||||
desc = locale("spoiler_empty_named", "message", locale=clb.from_user).format(
|
||||
locale(spoil["category"], "message", "spoiler_categories"),
|
||||
clb.from_user.first_name,
|
||||
)
|
||||
else:
|
||||
desc = locale("spoiler_described_named", "message", locale=clb.from_user).format(locale(spoil["category"], "message", "spoiler_categories"), clb.from_user.first_name, spoil["description"])
|
||||
desc = locale(
|
||||
"spoiler_described_named", "message", locale=clb.from_user
|
||||
).format(
|
||||
locale(spoil["category"], "message", "spoiler_categories"),
|
||||
clb.from_user.first_name,
|
||||
spoil["description"],
|
||||
)
|
||||
|
||||
await app.send_message(configGet("users", "groups"), desc, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("spoiler_view", "button", locale=clb.from_user), callback_data=f'sid_{clb.data.split("_")[1]}')]]))
|
||||
await app.send_message(configGet("admin", "groups"), desc, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("spoiler_view", "button", locale=clb.from_user), callback_data=f'sid_{clb.data.split("_")[1]}')]]))
|
||||
await app.send_message(
|
||||
configGet("users", "groups"),
|
||||
desc,
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
locale("spoiler_view", "button", locale=clb.from_user),
|
||||
callback_data=f'sid_{clb.data.split("_")[1]}',
|
||||
)
|
||||
]
|
||||
]
|
||||
),
|
||||
)
|
||||
await app.send_message(
|
||||
configGet("admin", "groups"),
|
||||
desc,
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
locale("spoiler_view", "button", locale=clb.from_user),
|
||||
callback_data=f'sid_{clb.data.split("_")[1]}',
|
||||
)
|
||||
]
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
await clb.answer(locale("spoiler_sent", "callback", locale=clb.from_user), show_alert=True)
|
||||
# ==============================================================================================================================
|
||||
await clb.answer(
|
||||
locale("spoiler_sent", "callback", locale=clb.from_user), show_alert=True
|
||||
)
|
||||
|
||||
|
||||
# ==============================================================================================================================
|
||||
|
@@ -1,6 +1,11 @@
|
||||
from datetime import datetime
|
||||
from app import app
|
||||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, ForceReply, CallbackQuery
|
||||
from pyrogram.types import (
|
||||
InlineKeyboardMarkup,
|
||||
InlineKeyboardButton,
|
||||
ForceReply,
|
||||
CallbackQuery,
|
||||
)
|
||||
from pyrogram.client import Client
|
||||
from pyrogram import filters
|
||||
from classes.errors.holo_user import LabelSettingError
|
||||
@@ -8,46 +13,79 @@ from classes.holo_user import HoloUser
|
||||
from modules.utils import configGet, locale, logWrite, should_quote
|
||||
from modules.database import col_tmp, col_sponsorships
|
||||
|
||||
|
||||
# Callbacks sponsorship ========================================================================================================
|
||||
@app.on_callback_query(filters.regex("sponsor_apply_[\s\S]*"))
|
||||
async def callback_query_sponsor_apply(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(int(fullclb[2]))
|
||||
|
||||
if holo_user.application_state()[0] == "fill":
|
||||
await clb.message.reply_text(locale("finish_application", "message"), quote=should_quote(clb.message))
|
||||
await clb.message.reply_text(
|
||||
locale("finish_application", "message"), quote=should_quote(clb.message)
|
||||
)
|
||||
return
|
||||
|
||||
logWrite(f"User {holo_user.id} applied for sponsorship")
|
||||
|
||||
holo_user.sponsorship_restart()
|
||||
|
||||
edited_markup = [[InlineKeyboardButton(text=str(locale("sponsor_started", "button")), callback_data="nothing")]]
|
||||
edited_markup = [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("sponsor_started", "button")), callback_data="nothing"
|
||||
)
|
||||
]
|
||||
]
|
||||
|
||||
await clb.message.edit(
|
||||
text=locale("sponsorship_applying", "message", locale=holo_user),
|
||||
reply_markup=InlineKeyboardMarkup(edited_markup),
|
||||
)
|
||||
await app.send_message(
|
||||
holo_user.id,
|
||||
locale(f"sponsor1", "message", locale=holo_user),
|
||||
reply_markup=ForceReply(
|
||||
placeholder=str(locale(f"sponsor1", "force_reply", locale=holo_user.locale))
|
||||
),
|
||||
)
|
||||
await clb.answer(
|
||||
text=locale("sponsor_started", "callback", locale=holo_user).format(
|
||||
holo_user.id
|
||||
),
|
||||
show_alert=False,
|
||||
)
|
||||
|
||||
await clb.message.edit(text=locale("sponsorship_applying", "message", locale=holo_user), reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await app.send_message(holo_user.id, locale(f"sponsor1", "message", locale=holo_user), reply_markup=ForceReply(placeholder=str(locale(f"sponsor1", "force_reply", locale=holo_user.locale))))
|
||||
await clb.answer(text=locale("sponsor_started", "callback", locale=holo_user).format(holo_user.id), show_alert=False)
|
||||
|
||||
@app.on_callback_query(filters.regex("sponsor_yes_[\s\S]*"))
|
||||
async def callback_query_sponsor_yes(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(int(fullclb[2]))
|
||||
|
||||
await app.send_message(configGet("admin", "groups"), locale("sponsor_approved_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
|
||||
await app.send_message(holo_user.id, locale("sponsor_approved", "message", locale=holo_user))
|
||||
await app.send_message(
|
||||
configGet("admin", "groups"),
|
||||
locale("sponsor_approved_by", "message").format(
|
||||
clb.from_user.first_name, holo_user.id
|
||||
),
|
||||
disable_notification=True,
|
||||
)
|
||||
await app.send_message(
|
||||
holo_user.id, locale("sponsor_approved", "message", locale=holo_user)
|
||||
)
|
||||
logWrite(f"User {holo_user.id} got sponsorship approved by {clb.from_user.id}")
|
||||
|
||||
if col_sponsorships.find_one({"user": holo_user.id}) is not None:
|
||||
col_sponsorships.update_one({"user": holo_user.id},
|
||||
col_sponsorships.update_one(
|
||||
{"user": holo_user.id},
|
||||
{
|
||||
"$set": {
|
||||
"date": datetime.now(),
|
||||
"admin": clb.from_user.id,
|
||||
"sponsorship": col_tmp.find_one({"user": holo_user.id, "type": "sponsorship"})["sponsorship"]
|
||||
"sponsorship": col_tmp.find_one(
|
||||
{"user": holo_user.id, "type": "sponsorship"}
|
||||
)["sponsorship"],
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
else:
|
||||
col_sponsorships.insert_one(
|
||||
@@ -55,49 +93,84 @@ async def callback_query_sponsor_yes(app: Client, clb: CallbackQuery):
|
||||
"user": holo_user.id,
|
||||
"date": datetime.now(),
|
||||
"admin": clb.from_user.id,
|
||||
"sponsorship": col_tmp.find_one({"user": holo_user.id, "type": "sponsorship"})["sponsorship"]
|
||||
"sponsorship": col_tmp.find_one(
|
||||
{"user": holo_user.id, "type": "sponsorship"}
|
||||
)["sponsorship"],
|
||||
}
|
||||
)
|
||||
|
||||
col_tmp.update_one({"user": holo_user.id, "type":"sponsorship"},
|
||||
{
|
||||
"$set": {
|
||||
"state": "approved",
|
||||
"sent": False
|
||||
}
|
||||
}
|
||||
|
||||
col_tmp.update_one(
|
||||
{"user": holo_user.id, "type": "sponsorship"},
|
||||
{"$set": {"state": "approved", "sent": False}},
|
||||
)
|
||||
|
||||
try:
|
||||
await holo_user.label_set(configGet("users", "groups"), col_tmp.find_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "sponsorship"}})["sponsorship"]["label"])
|
||||
await holo_user.label_set(
|
||||
configGet("users", "groups"),
|
||||
col_tmp.find_one(
|
||||
{"user": {"$eq": holo_user.id}, "type": {"$eq": "sponsorship"}}
|
||||
)["sponsorship"]["label"],
|
||||
)
|
||||
except LabelSettingError as exp:
|
||||
await app.send_message(configGet("admin", "groups"), exp.__str__(), disable_notification=True)
|
||||
await app.send_message(
|
||||
configGet("admin", "groups"), exp.__str__(), disable_notification=True
|
||||
)
|
||||
|
||||
edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]]
|
||||
edited_markup = [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("accepted", "button")), callback_data="nothing"
|
||||
)
|
||||
]
|
||||
]
|
||||
|
||||
await app.edit_message_caption(
|
||||
clb.message.chat.id,
|
||||
clb.message.id,
|
||||
caption=clb.message.caption,
|
||||
reply_markup=InlineKeyboardMarkup(edited_markup),
|
||||
)
|
||||
await clb.answer(
|
||||
text=locale("sponsor_accepted", "callback").format(fullclb[2]), show_alert=False
|
||||
)
|
||||
|
||||
await app.edit_message_caption(clb.message.chat.id, clb.message.id, caption=clb.message.caption, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await clb.answer(text=locale("sponsor_accepted", "callback").format(fullclb[2]), show_alert=False)
|
||||
|
||||
@app.on_callback_query(filters.regex("sponsor_no_[\s\S]*"))
|
||||
async def callback_query_sponsor_no(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(int(fullclb[2]))
|
||||
|
||||
await app.send_message(configGet("admin", "groups"), locale("sponsor_rejected_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
|
||||
await app.send_message(holo_user.id, locale("sponsor_rejected", "message", locale=holo_user))
|
||||
await app.send_message(
|
||||
configGet("admin", "groups"),
|
||||
locale("sponsor_rejected_by", "message").format(
|
||||
clb.from_user.first_name, holo_user.id
|
||||
),
|
||||
disable_notification=True,
|
||||
)
|
||||
await app.send_message(
|
||||
holo_user.id, locale("sponsor_rejected", "message", locale=holo_user)
|
||||
)
|
||||
logWrite(f"User {holo_user.id} got sponsorship rejected by {clb.from_user.id}")
|
||||
|
||||
col_tmp.update_one({"user": holo_user.id, "type": "sponsorship"},
|
||||
{
|
||||
"$set": {
|
||||
"state": "rejected",
|
||||
"sent": False
|
||||
}
|
||||
}
|
||||
col_tmp.update_one(
|
||||
{"user": holo_user.id, "type": "sponsorship"},
|
||||
{"$set": {"state": "rejected", "sent": False}},
|
||||
)
|
||||
|
||||
edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")]]
|
||||
edited_markup = [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("declined", "button")), callback_data="nothing"
|
||||
)
|
||||
]
|
||||
]
|
||||
|
||||
await app.edit_message_caption(clb.message.chat.id, clb.message.id, caption=clb.message.caption, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await clb.answer(text=locale("sponsor_rejected", "callback").format(fullclb[2]), show_alert=False)
|
||||
await app.edit_message_caption(
|
||||
clb.message.chat.id,
|
||||
clb.message.id,
|
||||
caption=clb.message.caption,
|
||||
reply_markup=InlineKeyboardMarkup(edited_markup),
|
||||
)
|
||||
await clb.answer(
|
||||
text=locale("sponsor_rejected", "callback").format(fullclb[2]), show_alert=False
|
||||
)
|
||||
|
@@ -8,14 +8,18 @@ from modules.utils import configGet, locale, logWrite
|
||||
from modules.database import col_tmp, col_applications
|
||||
from modules.commands.rules import DefaultRulesMarkup
|
||||
|
||||
|
||||
# Callbacks application ========================================================================================================
|
||||
@app.on_callback_query(filters.regex("sub_yes_[\s\S]*"))
|
||||
async def callback_query_accept(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(int(fullclb[2]))
|
||||
|
||||
await app.send_message(configGet("admin", "groups"), locale("approved_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
|
||||
await app.send_message(
|
||||
configGet("admin", "groups"),
|
||||
locale("approved_by", "message").format(clb.from_user.first_name, holo_user.id),
|
||||
disable_notification=True,
|
||||
)
|
||||
logWrite(f"User {holo_user.id} got approved by {clb.from_user.id}")
|
||||
|
||||
need_link = True
|
||||
@@ -23,65 +27,167 @@ async def callback_query_accept(app: Client, clb: CallbackQuery):
|
||||
async for member in app.get_chat_members(configGet("users", "groups")):
|
||||
if member.user.id == holo_user.id:
|
||||
need_link = False
|
||||
|
||||
|
||||
if need_link:
|
||||
link = await app.create_chat_invite_link(configGet("users", "groups"), name=f"Invite for {holo_user.id}", member_limit=1) #, expire_date=datetime.now()+timedelta(days=1))
|
||||
link = await app.create_chat_invite_link(
|
||||
configGet("users", "groups"),
|
||||
name=f"Invite for {holo_user.id}",
|
||||
member_limit=1,
|
||||
) # , expire_date=datetime.now()+timedelta(days=1))
|
||||
|
||||
await app.send_message(holo_user.id, locale("read_rules", "message", locale=holo_user))
|
||||
await app.send_message(
|
||||
holo_user.id, locale("read_rules", "message", locale=holo_user)
|
||||
)
|
||||
|
||||
await app.send_message(holo_user.id, locale("rules_msg", locale=holo_user), disable_web_page_preview=True, reply_markup=DefaultRulesMarkup(holo_user).keyboard)
|
||||
await app.send_message(
|
||||
holo_user.id,
|
||||
locale("rules_msg", locale=holo_user),
|
||||
disable_web_page_preview=True,
|
||||
reply_markup=DefaultRulesMarkup(holo_user).keyboard,
|
||||
)
|
||||
|
||||
await app.send_message(holo_user.id, locale("approved", "message", locale=holo_user), reply_markup=InlineKeyboardMarkup(
|
||||
[[
|
||||
InlineKeyboardButton(str(locale("join", "button", locale=holo_user)), url=link.invite_link)
|
||||
]]
|
||||
))
|
||||
await app.send_message(
|
||||
holo_user.id,
|
||||
locale("approved", "message", locale=holo_user),
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
str(locale("join", "button", locale=holo_user)),
|
||||
url=link.invite_link,
|
||||
)
|
||||
]
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
holo_user.set("link", link.invite_link)
|
||||
logWrite(f"User {holo_user.id} got an invite link {link.invite_link}")
|
||||
|
||||
else:
|
||||
await app.send_message(holo_user.id, locale("approved_joined", "message", locale=holo_user))
|
||||
await app.send_message(
|
||||
holo_user.id, locale("approved_joined", "message", locale=holo_user)
|
||||
)
|
||||
|
||||
col_applications.insert_one({"user": holo_user.id, "date": datetime.now(), "admin": clb.from_user.id, "application": col_tmp.find_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}})["application"]})
|
||||
col_tmp.update_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}}, {"$set": {"state": "approved", "sent": False}})
|
||||
col_applications.insert_one(
|
||||
{
|
||||
"user": holo_user.id,
|
||||
"date": datetime.now(),
|
||||
"admin": clb.from_user.id,
|
||||
"application": col_tmp.find_one(
|
||||
{"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}}
|
||||
)["application"],
|
||||
}
|
||||
)
|
||||
col_tmp.update_one(
|
||||
{"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}},
|
||||
{"$set": {"state": "approved", "sent": False}},
|
||||
)
|
||||
|
||||
edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]]
|
||||
edited_markup = [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("accepted", "button")), callback_data="nothing"
|
||||
)
|
||||
]
|
||||
]
|
||||
|
||||
await clb.message.edit(
|
||||
text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)
|
||||
)
|
||||
await clb.answer(
|
||||
text=locale("sub_accepted", "callback", locale=clb.from_user).format(
|
||||
holo_user.id
|
||||
),
|
||||
show_alert=True,
|
||||
)
|
||||
|
||||
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await clb.answer(text=locale("sub_accepted", "callback", locale=clb.from_user).format(holo_user.id), show_alert=True)
|
||||
|
||||
@app.on_callback_query(filters.regex("sub_no_[\s\S]*"))
|
||||
async def callback_query_reject(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(int(fullclb[2]))
|
||||
|
||||
await app.send_message(configGet("admin", "groups"), locale("rejected_by", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
|
||||
await app.send_message(holo_user.id, locale("rejected", "message", locale=holo_user))
|
||||
await app.send_message(
|
||||
configGet("admin", "groups"),
|
||||
locale("rejected_by", "message").format(clb.from_user.first_name, holo_user.id),
|
||||
disable_notification=True,
|
||||
)
|
||||
await app.send_message(
|
||||
holo_user.id, locale("rejected", "message", locale=holo_user)
|
||||
)
|
||||
logWrite(f"User {holo_user.id} got rejected by {clb.from_user.id}")
|
||||
|
||||
col_tmp.update_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}}, {"$set": {"state": "rejected", "sent": False}})
|
||||
col_tmp.update_one(
|
||||
{"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}},
|
||||
{"$set": {"state": "rejected", "sent": False}},
|
||||
)
|
||||
|
||||
edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")], [InlineKeyboardButton(text=str(locale("ban", "button")), callback_data=f"ban_{fullclb[2]}")]]
|
||||
edited_markup = [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("declined", "button")), callback_data="nothing"
|
||||
)
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("ban", "button")), callback_data=f"ban_{fullclb[2]}"
|
||||
)
|
||||
],
|
||||
]
|
||||
|
||||
await clb.message.edit(
|
||||
text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)
|
||||
)
|
||||
await clb.answer(
|
||||
text=locale("sub_rejected", "callback", locale=clb.from_user).format(
|
||||
holo_user.id
|
||||
),
|
||||
show_alert=True,
|
||||
)
|
||||
|
||||
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await clb.answer(text=locale("sub_rejected", "callback", locale=clb.from_user).format(holo_user.id), show_alert=True)
|
||||
|
||||
@app.on_callback_query(filters.regex("sub_russian_[\s\S]*"))
|
||||
async def callback_query_reject_russian(app: Client, clb: CallbackQuery):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(int(fullclb[2]))
|
||||
|
||||
await app.send_message(configGet("admin", "groups"), locale("rejected_by_rus", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
|
||||
await app.send_message(holo_user.id, locale("rejected_russian", "message", locale=holo_user))
|
||||
logWrite(f"User {holo_user.id} got rejected by {clb.from_user.id} due to being russian")
|
||||
await app.send_message(
|
||||
configGet("admin", "groups"),
|
||||
locale("rejected_by_rus", "message").format(
|
||||
clb.from_user.first_name, holo_user.id
|
||||
),
|
||||
disable_notification=True,
|
||||
)
|
||||
await app.send_message(
|
||||
holo_user.id, locale("rejected_russian", "message", locale=holo_user)
|
||||
)
|
||||
logWrite(
|
||||
f"User {holo_user.id} got rejected by {clb.from_user.id} due to being russian"
|
||||
)
|
||||
|
||||
col_tmp.update_one({"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}}, {"$set": {"state": "rejected", "sent": False}})
|
||||
col_tmp.update_one(
|
||||
{"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}},
|
||||
{"$set": {"state": "rejected", "sent": False}},
|
||||
)
|
||||
|
||||
edited_markup = [[InlineKeyboardButton(text=str(locale("declined", "button")), callback_data="nothing")]]
|
||||
edited_markup = [
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=str(locale("declined", "button")), callback_data="nothing"
|
||||
)
|
||||
]
|
||||
]
|
||||
|
||||
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await clb.answer(text=locale("sub_russian", "callback", locale=clb.from_user).format(holo_user.id), show_alert=True)
|
||||
# ==============================================================================================================================
|
||||
await clb.message.edit(
|
||||
text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup)
|
||||
)
|
||||
await clb.answer(
|
||||
text=locale("sub_russian", "callback", locale=clb.from_user).format(
|
||||
holo_user.id
|
||||
),
|
||||
show_alert=True,
|
||||
)
|
||||
|
||||
|
||||
# ==============================================================================================================================
|
||||
|
@@ -1,49 +1,104 @@
|
||||
from app import app
|
||||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, ChatPermissions, CallbackQuery
|
||||
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
|
||||
|
||||
|
||||
# Callbacks sus users ==========================================================================================================
|
||||
@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}")
|
||||
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")]]
|
||||
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 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(
|
||||
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
|
||||
)
|
||||
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}")
|
||||
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")]]
|
||||
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 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}})
|
||||
# ==============================================================================================================================
|
||||
col_tmp.update_one(
|
||||
{"user": {"$eq": holo_user.id}, "type": {"$eq": "application"}},
|
||||
{"$set": {"state": "rejected", "sent": False}},
|
||||
)
|
||||
|
||||
|
||||
# ==============================================================================================================================
|
||||
|
Reference in New Issue
Block a user