Merge Beta with Stable releases #1
@ -1,126 +1,103 @@
|
||||
from os import sep
|
||||
from time import time
|
||||
from datetime import datetime
|
||||
from app import app
|
||||
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from pyrogram import filters
|
||||
from modules.utils import configGet, configSet, jsonLoad, jsonSave, locale, logWrite
|
||||
from classes.holo_user import HoloUser
|
||||
from modules.utils import configGet, locale, logWrite
|
||||
from modules.database import col_tmp, col_applications
|
||||
|
||||
# Callbacks application ========================================================================================================
|
||||
@app.on_callback_query(filters.regex("sub_yes_[\s\S]*"))
|
||||
async def callback_query_accept(app, clb):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(int(fullclb[2]))
|
||||
|
||||
await app.send_message(configGet("admin_group"), locale("approved_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True)
|
||||
logWrite(f"User {fullclb[2]} got approved by {clb.from_user.id}")
|
||||
await app.send_message(configGet("admin_group"), 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
|
||||
|
||||
async for member in app.get_chat_members(configGet("destination_group")):
|
||||
if member.user.id == int(fullclb[2]):
|
||||
if member.user.id == holo_user.id:
|
||||
need_link = False
|
||||
|
||||
if need_link:
|
||||
link = await app.create_chat_invite_link(configGet("destination_group"), name=f"Invite for {fullclb[2]}", member_limit=1) #, expire_date=datetime.now()+timedelta(days=1))
|
||||
link = await app.create_chat_invite_link(configGet("destination_group"), name=f"Invite for {holo_user.id}", member_limit=1) #, expire_date=datetime.now()+timedelta(days=1))
|
||||
|
||||
await app.send_message(int(fullclb[2]), locale("read_rules", "message"))
|
||||
await app.send_message(holo_user.id, locale("read_rules", "message"))
|
||||
|
||||
for rule_msg in locale("rules"):
|
||||
await app.send_message(int(fullclb[2]), rule_msg)
|
||||
await app.send_message(holo_user.id, rule_msg)
|
||||
|
||||
await app.send_message(int(fullclb[2]), locale("approved", "message"), reply_markup=InlineKeyboardMarkup(
|
||||
await app.send_message(holo_user.id, locale("approved", "message"), reply_markup=InlineKeyboardMarkup(
|
||||
[[
|
||||
InlineKeyboardButton(str(locale("join", "button")), url=link.invite_link)
|
||||
]]
|
||||
))
|
||||
|
||||
configSet(["link"], link.invite_link, file=fullclb[2])
|
||||
logWrite(f"User {fullclb[2]} got an invite link {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(int(fullclb[2]), locale("approved_joined", "message"))
|
||||
await app.send_message(holo_user.id, locale("approved_joined", "message"))
|
||||
|
||||
configSet(["approved"], True, file=fullclb[2])
|
||||
configSet(["sent"], False, file=fullclb[2])
|
||||
|
||||
application = jsonLoad(f"{configGet('data', 'locations')}{sep}applications.json")
|
||||
application[fullclb[2]]["approved"] = True
|
||||
application[fullclb[2]]["approved_by"] = clb.from_user.id
|
||||
application[fullclb[2]]["approval_date"] = int(time())
|
||||
jsonSave(application, f"{configGet('data', 'locations')}{sep}applications.json")
|
||||
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")]]
|
||||
|
||||
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await clb.answer(text=locale("sub_accepted", "callback").format(fullclb[2]), show_alert=True)
|
||||
|
||||
@app.on_callback_query(filters.regex("sub_no_aggressive_[\s\S]*"))
|
||||
async def callback_query_refuse_aggressive(app, clb):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
|
||||
await app.send_message(configGet("admin_group"), locale("refused_by_agr", "message").format(clb.from_user.first_name, fullclb[3]), disable_notification=True)
|
||||
await app.send_message(int(fullclb[3]), locale("refused", "message"))
|
||||
logWrite(f"User {fullclb[3]} got refused by {clb.from_user.id} due to being aggressive")
|
||||
|
||||
configSet(["refused"], True, file=fullclb[3])
|
||||
configSet(["sent"], False, file=fullclb[3])
|
||||
|
||||
application = jsonLoad(f"{configGet('data', 'locations')}{sep}applications.json")
|
||||
application[fullclb[3]]["refused"] = True
|
||||
application[fullclb[3]]["refused_by"] = clb.from_user.id
|
||||
application[fullclb[3]]["refusal_date"] = int(time())
|
||||
jsonSave(application, f"{configGet('data', 'locations')}{sep}applications.json")
|
||||
|
||||
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_no_aggressive", "callback").format(fullclb[3]), show_alert=True)
|
||||
|
||||
@app.on_callback_query(filters.regex("sub_no_russian_[\s\S]*"))
|
||||
async def callback_query_refuse_russian(app, clb):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
|
||||
await app.send_message(configGet("admin_group"), locale("refused_by_rus", "message").format(clb.from_user.first_name, fullclb[3]), disable_notification=True)
|
||||
await app.send_message(int(fullclb[3]), locale("refused", "message"))
|
||||
await app.send_message(int(fullclb[3]), locale("refused_russian", "message"))
|
||||
logWrite(f"User {fullclb[3]} got refused by {clb.from_user.id} due to being russian")
|
||||
|
||||
configSet(["refused"], True, file=fullclb[3])
|
||||
configSet(["sent"], False, file=fullclb[3])
|
||||
|
||||
application = jsonLoad(f"{configGet('data', 'locations')}{sep}applications.json")
|
||||
application[fullclb[3]]["refused"] = True
|
||||
application[fullclb[3]]["refused_by"] = clb.from_user.id
|
||||
application[fullclb[3]]["refusal_date"] = int(time())
|
||||
jsonSave(application, f"{configGet('data', 'locations')}{sep}applications.json")
|
||||
|
||||
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_no_russian", "callback").format(fullclb[3]), show_alert=True)
|
||||
await clb.answer(text=locale("sub_accepted", "callback").format(holo_user.id), show_alert=True)
|
||||
|
||||
@app.on_callback_query(filters.regex("sub_no_[\s\S]*"))
|
||||
async def callback_query_refuse(app, clb):
|
||||
async def callback_query_reject(app, clb):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(int(fullclb[2]))
|
||||
|
||||
await app.send_message(configGet("admin_group"), locale("refused_by", "message").format(clb.from_user.first_name, fullclb[2]), disable_notification=True)
|
||||
await app.send_message(int(fullclb[2]), locale("refused", "message"))
|
||||
logWrite(f"User {fullclb[2]} got refused by {clb.from_user.id}")
|
||||
await app.send_message(configGet("admin_group"), 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"))
|
||||
logWrite(f"User {holo_user.id} got rejected by {clb.from_user.id}")
|
||||
|
||||
configSet(["refused"], True, file=fullclb[2])
|
||||
configSet(["sent"], False, file=fullclb[2])
|
||||
|
||||
application = jsonLoad(f"{configGet('data', 'locations')}{sep}applications.json")
|
||||
application[fullclb[2]]["refused"] = True
|
||||
application[fullclb[2]]["refused_by"] = clb.from_user.id
|
||||
application[fullclb[2]]["refusal_date"] = int(time())
|
||||
jsonSave(application, f"{configGet('data', 'locations')}{sep}applications.json")
|
||||
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")]]
|
||||
|
||||
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await clb.answer(text=locale("sub_refused", "callback").format(fullclb[2]), show_alert=True)
|
||||
await clb.answer(text=locale("sub_rejected", "callback").format(holo_user.id), show_alert=True)
|
||||
|
||||
@app.on_callback_query(filters.regex("sub_aggressive_[\s\S]*"))
|
||||
async def callback_query_reject_aggressive(app, clb):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(int(fullclb[2]))
|
||||
|
||||
await app.send_message(configGet("admin_group"), locale("rejected_by_agr", "message").format(clb.from_user.first_name, holo_user.id), disable_notification=True)
|
||||
await app.send_message(holo_user.id, locale("rejected_aggressive", "message"))
|
||||
logWrite(f"User {holo_user.id} got rejected by {clb.from_user.id} due to being aggressive")
|
||||
|
||||
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")]]
|
||||
|
||||
await clb.message.edit(text=clb.message.text, reply_markup=InlineKeyboardMarkup(edited_markup))
|
||||
await clb.answer(text=locale("sub_aggressive", "callback").format(holo_user.id), show_alert=True)
|
||||
|
||||
@app.on_callback_query(filters.regex("sub_russian_[\s\S]*"))
|
||||
async def callback_query_reject_russian(app, clb):
|
||||
|
||||
fullclb = clb.data.split("_")
|
||||
holo_user = HoloUser(int(fullclb[2]))
|
||||
|
||||
await app.send_message(configGet("admin_group"), 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"))
|
||||
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}})
|
||||
|
||||
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").format(holo_user.id), show_alert=True)
|
||||
# ==============================================================================================================================
|
Reference in New Issue
Block a user