Fixed some logic holes
This commit is contained in:
parent
dabfa2ecef
commit
92386ac8ce
@ -281,10 +281,9 @@ class HoloUser():
|
||||
"""Reset application of a user in tmp collection and replace it with an empty one
|
||||
"""
|
||||
if col_tmp.find_one({"user": self.id, "type": "application"}) is None:
|
||||
col_tmp.insert_one(document=DefaultApplicationTemp(self.id).dict)
|
||||
else:
|
||||
col_tmp.delete_one({"user": self.id, "type": "application"})
|
||||
col_tmp.insert_one(document=DefaultApplicationTemp(self.id, reapply=reapply).dict)
|
||||
else:
|
||||
col_tmp.find_one_and_replace({"user": self.id, "type": "application"}, DefaultApplicationTemp(self.id, reapply=reapply).dict)
|
||||
|
||||
async def application_next(self, query: str, msg: Message) -> None:
|
||||
"""Move on filling application of user
|
||||
|
@ -21,8 +21,15 @@ async def callback_reapply_query_accept(app: Client, clb: CallbackQuery):
|
||||
|
||||
await app.send_message(holo_user.id, locale("approved_joined", "message", locale=holo_user))
|
||||
|
||||
col_applications.delete_one({"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"]})
|
||||
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"]})
|
||||
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"]})
|
||||
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}})
|
||||
|
||||
edited_markup = [[InlineKeyboardButton(text=str(locale("accepted", "button")), callback_data="nothing")]]
|
||||
|
@ -9,7 +9,7 @@ from pyrogram.enums.parse_mode import ParseMode
|
||||
from classes.holo_user import HoloUser
|
||||
from modules.utils import all_locales, configGet, locale, logWrite
|
||||
from modules.handlers.welcome import welcome_pass
|
||||
from modules.database import col_tmp
|
||||
from modules.database import col_tmp, col_applications
|
||||
from modules import custom_filters
|
||||
|
||||
# Confirmation =================================================================================================================
|
||||
@ -54,8 +54,12 @@ async def confirm_yes(app: Client, msg: Message, kind: Literal["application", "s
|
||||
|
||||
i += 1
|
||||
|
||||
if tmp_application["reapply"]:
|
||||
await app.send_message(chat_id=configGet("admin", "groups"), text=(locale("reapply_got", "message")).format(str(holo_user.id), msg.from_user.first_name, msg.from_user.username, "\n".join(application_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(
|
||||
if tmp_application["reapply"] is True and col_applications.find_one({"user": holo_user.id}) is not None:
|
||||
await app.send_message(
|
||||
chat_id=configGet("admin", "groups"),
|
||||
text=(locale("reapply_got", "message")).format(str(holo_user.id),msg.from_user.first_name, msg.from_user.username, "\n".join(application_content)),
|
||||
parse_mode=ParseMode.MARKDOWN,
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton(text=str(locale("reapply_yes", "button")), callback_data=f"reapply_yes_{holo_user.id}")
|
||||
@ -67,7 +71,11 @@ async def confirm_yes(app: Client, msg: Message, kind: Literal["application", "s
|
||||
)
|
||||
)
|
||||
else:
|
||||
await app.send_message(chat_id=configGet("admin", "groups"), text=(locale("application_got", "message")).format(str(holo_user.id), msg.from_user.first_name, msg.from_user.username, "\n".join(application_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(
|
||||
await app.send_message(
|
||||
chat_id=configGet("admin", "groups"),
|
||||
text=(locale("application_got", "message")).format(str(holo_user.id), msg.from_user.first_name, msg.from_user.username, "\n".join(application_content)),
|
||||
parse_mode=ParseMode.MARKDOWN,
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton(text=str(locale("sub_yes", "button")), callback_data=f"sub_yes_{holo_user.id}")
|
||||
|
@ -13,7 +13,7 @@ for pattern in all_locales("welcome", "keyboard"):
|
||||
for pattern in all_locales("return", "keyboard"):
|
||||
welcome_1.append(pattern[0][0])
|
||||
@app.on_message(custom_filters.enabled_applications & ~filters.scheduled & filters.private & filters.command(welcome_1, prefixes=[""]))
|
||||
async def welcome_pass(app: Client, msg: Message, once_again: bool = True) -> None:
|
||||
async def welcome_pass(app: Client, msg: Message, once_again: bool = False) -> None:
|
||||
"""Set user's stage to 1 and start a fresh application
|
||||
|
||||
### Args:
|
||||
@ -27,7 +27,8 @@ async def welcome_pass(app: Client, msg: Message, once_again: bool = True) -> No
|
||||
|
||||
holo_user = HoloUser(msg.from_user)
|
||||
|
||||
holo_user.application_restart()
|
||||
if once_again is False:
|
||||
holo_user.application_restart()
|
||||
|
||||
logWrite(f"User {msg.from_user.id} confirmed starting the application")
|
||||
await msg.reply_text(locale("question1", "message", locale=msg.from_user), reply_markup=ForceReply(placeholder=locale("question1", "force_reply", locale=msg.from_user)))
|
||||
|
Reference in New Issue
Block a user