Bug fixes and improvements #8
@ -281,10 +281,9 @@ class HoloUser():
|
|||||||
"""Reset application of a user in tmp collection and replace it with an empty one
|
"""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:
|
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)
|
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:
|
async def application_next(self, query: str, msg: Message) -> None:
|
||||||
"""Move on filling application of user
|
"""Move on filling application of user
|
||||||
|
@ -21,7 +21,14 @@ async def callback_reapply_query_accept(app: Client, clb: CallbackQuery):
|
|||||||
|
|
||||||
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.delete_one({"user": holo_user.id})
|
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_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_tmp.update_one({"user": holo_user.id, "type": "application"}, {"$set": {"state": "approved", "sent": False}})
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ from pyrogram.enums.parse_mode import ParseMode
|
|||||||
from classes.holo_user import HoloUser
|
from classes.holo_user import HoloUser
|
||||||
from modules.utils import all_locales, configGet, locale, logWrite
|
from modules.utils import all_locales, configGet, locale, logWrite
|
||||||
from modules.handlers.welcome import welcome_pass
|
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
|
from modules import custom_filters
|
||||||
|
|
||||||
# Confirmation =================================================================================================================
|
# Confirmation =================================================================================================================
|
||||||
@ -54,8 +54,12 @@ async def confirm_yes(app: Client, msg: Message, kind: Literal["application", "s
|
|||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
if tmp_application["reapply"]:
|
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(
|
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}")
|
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:
|
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}")
|
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"):
|
for pattern in all_locales("return", "keyboard"):
|
||||||
welcome_1.append(pattern[0][0])
|
welcome_1.append(pattern[0][0])
|
||||||
@app.on_message(custom_filters.enabled_applications & ~filters.scheduled & filters.private & filters.command(welcome_1, prefixes=[""]))
|
@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
|
"""Set user's stage to 1 and start a fresh application
|
||||||
|
|
||||||
### Args:
|
### Args:
|
||||||
@ -27,6 +27,7 @@ async def welcome_pass(app: Client, msg: Message, once_again: bool = True) -> No
|
|||||||
|
|
||||||
holo_user = HoloUser(msg.from_user)
|
holo_user = HoloUser(msg.from_user)
|
||||||
|
|
||||||
|
if once_again is False:
|
||||||
holo_user.application_restart()
|
holo_user.application_restart()
|
||||||
|
|
||||||
logWrite(f"User {msg.from_user.id} confirmed starting the application")
|
logWrite(f"User {msg.from_user.id} confirmed starting the application")
|
||||||
|
Reference in New Issue
Block a user