Now using custom filters
This commit is contained in:
parent
d7936fa600
commit
096a0498f8
@ -12,7 +12,7 @@ from modules.database import col_applications
|
||||
from modules import custom_filters
|
||||
|
||||
# Applications command =========================================================================================================
|
||||
@app.on_message(~ filters.scheduled & filters.command(["application"], prefixes=["/"]) & custom_filters.admin)
|
||||
@app.on_message(custom_filters.enabled_applications & ~filters.scheduled & filters.command(["application"], prefixes=["/"]) & custom_filters.admin)
|
||||
async def cmd_application(app: Client, msg: Message):
|
||||
|
||||
try:
|
||||
|
@ -11,7 +11,7 @@ from modules.database import col_applications
|
||||
from modules import custom_filters
|
||||
|
||||
# Applications command =========================================================================================================
|
||||
@app.on_message(~ filters.scheduled & filters.command(["applications"], prefixes=["/"]) & custom_filters.admin)
|
||||
@app.on_message(custom_filters.enabled_applications & ~filters.scheduled & filters.command(["applications"], prefixes=["/"]) & custom_filters.admin)
|
||||
async def cmd_applications(app: Client, msg: Message):
|
||||
|
||||
logWrite(f"Admin {msg.from_user.id} requested export of a database")
|
||||
|
@ -4,8 +4,9 @@ from pyrogram.types import Message
|
||||
from pyrogram.client import Client
|
||||
from modules.utils import should_quote, logWrite, locale
|
||||
from modules.database import col_tmp
|
||||
from modules import custom_filters
|
||||
|
||||
@app.on_message(~ filters.scheduled & filters.command("cancel", prefixes=["/"]))
|
||||
@app.on_message((custom_filters.enabled_applications | custom_filters.enabled_sponsorships) & ~filters.scheduled & filters.command("cancel", prefixes=["/"]))
|
||||
async def command_cancel(app: Client, msg: Message):
|
||||
col_tmp.delete_many( {"user": msg.from_user.id} )
|
||||
await msg.reply_text(locale("cancel", "message", locale=msg.from_user), quote=should_quote(msg))
|
||||
|
@ -9,7 +9,7 @@ from classes.holo_user import HoloUser, UserNotFoundError, UserInvalidError
|
||||
from modules.utils import jsonLoad, should_quote, logWrite, locale, download_tmp, create_tmp
|
||||
from modules import custom_filters
|
||||
|
||||
@app.on_message(~ filters.scheduled & filters.command("identify", prefixes=["/"]) & custom_filters.admin)
|
||||
@app.on_message((custom_filters.enabled_applications | custom_filters.enabled_sponsorships) & ~filters.scheduled & filters.command("identify", prefixes=["/"]) & custom_filters.admin)
|
||||
async def command_identify(app: Client, msg: Message):
|
||||
|
||||
if len(msg.command) != 2:
|
||||
|
@ -6,7 +6,7 @@ from modules.utils import locale, should_quote, find_user
|
||||
from classes.holo_user import HoloUser, LabelTooLongError
|
||||
from modules import custom_filters
|
||||
|
||||
@app.on_message(~ filters.scheduled & filters.command(["label"], prefixes=["/"]) & custom_filters.admin)
|
||||
@app.on_message(custom_filters.enabled_applications & ~filters.scheduled & filters.command(["label"], prefixes=["/"]) & custom_filters.admin)
|
||||
async def cmd_label(app: Client, msg: Message):
|
||||
|
||||
if len(msg.command) < 3:
|
||||
|
@ -7,7 +7,7 @@ from modules.utils import logWrite, locale, should_quote
|
||||
from modules import custom_filters
|
||||
|
||||
# Message command ==============================================================================================================
|
||||
@app.on_message(~ filters.scheduled & filters.command(["message"], prefixes=["/"]) & custom_filters.admin)
|
||||
@app.on_message(~filters.scheduled & filters.command(["message"], prefixes=["/"]) & custom_filters.admin)
|
||||
async def cmd_message(app: Client, msg: Message):
|
||||
|
||||
try:
|
||||
|
@ -11,7 +11,7 @@ from modules.database import col_applications, col_users
|
||||
from classes.errors.geo import PlaceNotFoundError
|
||||
|
||||
# Nearby command ===============================================================================================================
|
||||
@app.on_message(~ filters.scheduled & (filters.private | (filters.chat(configGet("admin_group")) | filters.chat(configGet("destination_group")))) & filters.command(["nearby"], prefixes=["/"]) & (custom_filters.allowed | custom_filters.admin))
|
||||
@app.on_message(custom_filters.enabled_applications & ~filters.scheduled & (filters.private | (filters.chat(configGet("admin_group")) | filters.chat(configGet("destination_group")))) & filters.command(["nearby"], prefixes=["/"]) & (custom_filters.allowed | custom_filters.admin))
|
||||
async def cmd_nearby(app: Client, msg: Message):
|
||||
|
||||
holo_user = HoloUser(msg.from_user)
|
||||
|
@ -6,9 +6,10 @@ from classes.holo_user import HoloUser
|
||||
from modules.utils import configGet, locale, should_quote
|
||||
from modules.handlers.welcome import welcome_pass
|
||||
from modules.database import col_tmp
|
||||
from modules import custom_filters
|
||||
|
||||
# Reapply command ==============================================================================================================
|
||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(["reapply"], prefixes=["/"]))
|
||||
@app.on_message(custom_filters.enabled_applications & ~filters.scheduled & filters.private & filters.command(["reapply"], prefixes=["/"]))
|
||||
async def cmd_reapply(app: Client, msg: Message):
|
||||
|
||||
holo_user = HoloUser(msg.from_user)
|
||||
|
@ -11,7 +11,7 @@ from modules import custom_filters
|
||||
pid = getpid()
|
||||
|
||||
# Shutdown command =============================================================================================================
|
||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(["kill", "die", "reboot"], prefixes=["/"]) & custom_filters.admin)
|
||||
@app.on_message(~filters.scheduled & filters.private & filters.command(["kill", "die", "reboot"], prefixes=["/"]) & custom_filters.admin)
|
||||
async def cmd_kill(app: Client, msg: Message):
|
||||
|
||||
logWrite(f"Shutting down bot with pid {pid}")
|
||||
|
@ -8,7 +8,7 @@ from modules.utils import locale, should_quote
|
||||
from modules.database import col_applications
|
||||
|
||||
# Sponsorship command ==========================================================================================================
|
||||
@app.on_message(~ filters.scheduled & filters.command(["sponsorship"], prefixes=["/"]) & (custom_filters.allowed | custom_filters.admin))
|
||||
@app.on_message(custom_filters.enabled_sponsorships & ~filters.scheduled & filters.command(["sponsorship"], prefixes=["/"]) & (custom_filters.allowed | custom_filters.admin))
|
||||
async def cmd_sponsorship(app: Client, msg: Message):
|
||||
if HoloUser(msg.from_user).application_state()[0] == "fill":
|
||||
await msg.reply_text(locale("finish_application", "message", locale=msg.from_user), quote=should_quote(msg))
|
||||
|
@ -4,9 +4,10 @@ from pyrogram.types import ReplyKeyboardMarkup, Message
|
||||
from pyrogram.client import Client
|
||||
from modules.utils import locale, logWrite
|
||||
from modules.database import col_users
|
||||
from modules import custom_filters
|
||||
|
||||
# Start command ================================================================================================================
|
||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"]))
|
||||
@app.on_message(custom_filters.enabled_applications & ~filters.scheduled & filters.private & filters.command(["start"], prefixes=["/"]))
|
||||
async def cmd_start(app: Client, msg: Message):
|
||||
|
||||
user = col_users.find_one({"user": msg.from_user.id})
|
||||
|
@ -8,7 +8,7 @@ from modules.database import col_warnings
|
||||
from modules import custom_filters
|
||||
|
||||
# Warn command =================================================================================================================
|
||||
@app.on_message(~ filters.scheduled & filters.command(["warn"], prefixes=["/"]) & custom_filters.admin)
|
||||
@app.on_message(custom_filters.enabled_warnings & ~filters.scheduled & filters.command(["warn"], prefixes=["/"]) & custom_filters.admin)
|
||||
async def cmd_warn(app: Client, msg: Message):
|
||||
|
||||
if msg.chat.id == configGet("destination_group"):
|
||||
|
@ -8,7 +8,7 @@ from modules.database import col_users, col_warnings
|
||||
from modules import custom_filters
|
||||
|
||||
# Warnings command =============================================================================================================
|
||||
@app.on_message(~ filters.scheduled & filters.command(["warnings"], prefixes=["/"]) & custom_filters.admin)
|
||||
@app.on_message(custom_filters.enabled_warnings & ~filters.scheduled & filters.command(["warnings"], prefixes=["/"]) & custom_filters.admin)
|
||||
async def cmd_warnings(app: Client, msg: Message):
|
||||
|
||||
if len(msg.command) <= 1:
|
||||
|
@ -12,150 +12,157 @@ 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 import custom_filters
|
||||
|
||||
# Confirmation =================================================================================================================
|
||||
confirmation_1 = []
|
||||
for pattern in all_locales("confirm", "keyboard"):
|
||||
confirmation_1.append(pattern[0][0])
|
||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(confirmation_1, prefixes=[""]))
|
||||
async def confirm_yes(app: Client, msg: Message, kind: Literal["application", "sponsorship"] = "unknown"):
|
||||
@app.on_message((custom_filters.enabled_applications | custom_filters.enabled_sponsorships) & ~filters.scheduled & filters.private & filters.command(confirmation_1, prefixes=[""]))
|
||||
async def confirm_yes(app: Client, msg: Message, kind: Literal["application", "sponsorship", "unknown"] = "unknown"):
|
||||
|
||||
holo_user = HoloUser(msg.from_user)
|
||||
|
||||
if (kind == "application") or ((holo_user.application_state()[0] == "fill") and (holo_user.application_state()[1] is True)):
|
||||
if configGet("enabled", "features", "applications") is True:
|
||||
|
||||
tmp_application = col_tmp.find_one({"user": holo_user.id, "type": "application"})
|
||||
if (kind == "application") or ((holo_user.application_state()[0] == "fill") and (holo_user.application_state()[1] is True)):
|
||||
|
||||
if tmp_application is None:
|
||||
logWrite(f"Application of {holo_user.id} is nowhere to be found.")
|
||||
return
|
||||
tmp_application = col_tmp.find_one({"user": holo_user.id, "type": "application"})
|
||||
|
||||
if tmp_application["sent"] is True:
|
||||
return
|
||||
if tmp_application is None:
|
||||
logWrite(f"Application of {holo_user.id} is nowhere to be found.")
|
||||
return
|
||||
|
||||
await msg.reply_text(locale("application_sent", "message"), reply_markup=ReplyKeyboardRemove())
|
||||
if tmp_application["sent"] is True:
|
||||
return
|
||||
|
||||
application_content = []
|
||||
i = 1
|
||||
await msg.reply_text(locale("application_sent", "message"), reply_markup=ReplyKeyboardRemove())
|
||||
|
||||
for question in tmp_application['application']:
|
||||
application_content = []
|
||||
i = 1
|
||||
|
||||
if i == 2:
|
||||
age = relativedelta(datetime.now(), tmp_application['application']['2'])
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {tmp_application['application']['2'].strftime('%d.%m.%Y')} ({age.years} р.)")
|
||||
elif i == 3:
|
||||
if tmp_application['application']['3']['countryCode'] == "UA":
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {tmp_application['application']['3']['name']}")
|
||||
for question in tmp_application['application']:
|
||||
|
||||
if i == 2:
|
||||
age = relativedelta(datetime.now(), tmp_application['application']['2'])
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {tmp_application['application']['2'].strftime('%d.%m.%Y')} ({age.years} р.)")
|
||||
elif i == 3:
|
||||
if tmp_application['application']['3']['countryCode'] == "UA":
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {tmp_application['application']['3']['name']}")
|
||||
else:
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {tmp_application['application']['3']['name']} ({tmp_application['application']['3']['adminName1']}, {tmp_application['application']['3']['countryName']})")
|
||||
else:
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {tmp_application['application']['3']['name']} ({tmp_application['application']['3']['adminName1']}, {tmp_application['application']['3']['countryName']})")
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {tmp_application['application'][question]}")
|
||||
|
||||
i += 1
|
||||
|
||||
if tmp_application["reapply"]:
|
||||
await app.send_message(chat_id=configGet("admin_group"), 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_no", "button")), callback_data=f"reapply_no_{holo_user.id}")
|
||||
]
|
||||
]
|
||||
)
|
||||
)
|
||||
else:
|
||||
application_content.append(f"{locale(f'question{i}', 'message', 'question_titles')} {tmp_application['application'][question]}")
|
||||
await app.send_message(chat_id=configGet("admin_group"), 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_no", "button")), callback_data=f"sub_no_{holo_user.id}")
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(text=str(locale("sub_aggressive", "button")), callback_data=f"sub_aggressive_{holo_user.id}")
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(text=str(locale("sub_russian", "button")), callback_data=f"sub_russian_{holo_user.id}")
|
||||
]
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
logWrite(f"User {holo_user.id} sent his application and it will now be reviewed")
|
||||
|
||||
col_tmp.update_one({"user": holo_user.id, "type": "application"}, {"$set": {"sent": True}})
|
||||
|
||||
return
|
||||
|
||||
# configSet(["sent"], True, file=str(holo_user.id))
|
||||
# configSet(["confirmed"], True, file=str(holo_user.id))
|
||||
|
||||
if configGet("enabled", "features", "sponsorships") is True:
|
||||
|
||||
if (kind == "sponsorship") or ((holo_user.sponsorship_state()[0] == "fill") and (holo_user.sponsorship_state()[1] is True)):
|
||||
|
||||
tmp_sponsorship = col_tmp.find_one({"user": holo_user.id, "type": "sponsorship"})
|
||||
|
||||
if tmp_sponsorship is None:
|
||||
logWrite(f"Sponsorship of {holo_user.id} is nowhere to be found.")
|
||||
return
|
||||
|
||||
if tmp_sponsorship["sent"] is True:
|
||||
return
|
||||
|
||||
await msg.reply_text(locale("sponsorship_sent", "message"), reply_markup=ReplyKeyboardRemove())
|
||||
|
||||
sponsorship_content = []
|
||||
|
||||
for question in tmp_sponsorship['sponsorship']:
|
||||
|
||||
if question == "expires":
|
||||
sponsorship_content.append(f"{locale(f'question_{question}', 'message', 'sponsor_titles')} {tmp_sponsorship['sponsorship'][question].strftime('%d.%m.%Y')}")
|
||||
elif question == "proof":
|
||||
filename = uuid1()
|
||||
with open(f"tmp{sep}{filename}.jpg", "wb") as f:
|
||||
f.write(tmp_sponsorship['sponsorship']['proof'])
|
||||
else:
|
||||
sponsorship_content.append(f"{locale(f'question_{question}', 'message', 'sponsor_titles')} {tmp_sponsorship['sponsorship'][question]}")
|
||||
|
||||
i += 1
|
||||
|
||||
if tmp_application["reapply"]:
|
||||
await app.send_message(chat_id=configGet("admin_group"), 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_photo(chat_id=configGet("admin_group"), photo=f"tmp{sep}{filename}.jpg", caption=(locale("sponsor_got", "message")).format(str(holo_user.id), msg.from_user.first_name, msg.from_user.username, "\n".join(sponsorship_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("sponsor_yes", "button")), callback_data=f"sponsor_yes_{holo_user.id}")
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(text=str(locale("reapply_no", "button")), callback_data=f"reapply_no_{holo_user.id}")
|
||||
]
|
||||
]
|
||||
)
|
||||
)
|
||||
else:
|
||||
await app.send_message(chat_id=configGet("admin_group"), 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_no", "button")), callback_data=f"sub_no_{holo_user.id}")
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(text=str(locale("sub_aggressive", "button")), callback_data=f"sub_aggressive_{holo_user.id}")
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(text=str(locale("sub_russian", "button")), callback_data=f"sub_russian_{holo_user.id}")
|
||||
InlineKeyboardButton(text=str(locale("sponsor_no", "button")), callback_data=f"sponsor_no_{holo_user.id}")
|
||||
]
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
logWrite(f"User {holo_user.id} sent his application and it will now be reviewed")
|
||||
remove(f"tmp{sep}{filename}.jpg")
|
||||
|
||||
col_tmp.update_one({"user": holo_user.id, "type": "application"}, {"$set": {"sent": True}})
|
||||
logWrite(f"User {holo_user.id} sent his sponsorship application and it will now be reviewed")
|
||||
|
||||
return
|
||||
col_tmp.update_one({"user": holo_user.id, "type": "sponsorship"}, {"$set": {"sent": True}})
|
||||
|
||||
# configSet(["sent"], True, file=str(holo_user.id))
|
||||
# configSet(["confirmed"], True, file=str(holo_user.id))
|
||||
|
||||
if (kind == "sponsorship") or ((holo_user.sponsorship_state()[0] == "fill") and (holo_user.sponsorship_state()[1] is True)):
|
||||
|
||||
tmp_sponsorship = col_tmp.find_one({"user": holo_user.id, "type": "sponsorship"})
|
||||
|
||||
if tmp_sponsorship is None:
|
||||
logWrite(f"Sponsorship of {holo_user.id} is nowhere to be found.")
|
||||
return
|
||||
|
||||
if tmp_sponsorship["sent"] is True:
|
||||
return
|
||||
|
||||
await msg.reply_text(locale("sponsorship_sent", "message"), reply_markup=ReplyKeyboardRemove())
|
||||
|
||||
sponsorship_content = []
|
||||
|
||||
for question in tmp_sponsorship['sponsorship']:
|
||||
|
||||
if question == "expires":
|
||||
sponsorship_content.append(f"{locale(f'question_{question}', 'message', 'sponsor_titles')} {tmp_sponsorship['sponsorship'][question].strftime('%d.%m.%Y')}")
|
||||
elif question == "proof":
|
||||
filename = uuid1()
|
||||
with open(f"tmp{sep}{filename}.jpg", "wb") as f:
|
||||
f.write(tmp_sponsorship['sponsorship']['proof'])
|
||||
else:
|
||||
sponsorship_content.append(f"{locale(f'question_{question}', 'message', 'sponsor_titles')} {tmp_sponsorship['sponsorship'][question]}")
|
||||
|
||||
await app.send_photo(chat_id=configGet("admin_group"), photo=f"tmp{sep}{filename}.jpg", caption=(locale("sponsor_got", "message")).format(str(holo_user.id), msg.from_user.first_name, msg.from_user.username, "\n".join(sponsorship_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton(text=str(locale("sponsor_yes", "button")), callback_data=f"sponsor_yes_{holo_user.id}")
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(text=str(locale("sponsor_no", "button")), callback_data=f"sponsor_no_{holo_user.id}")
|
||||
]
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
remove(f"tmp{sep}{filename}.jpg")
|
||||
|
||||
logWrite(f"User {holo_user.id} sent his sponsorship application and it will now be reviewed")
|
||||
|
||||
col_tmp.update_one({"user": holo_user.id, "type": "sponsorship"}, {"$set": {"sent": True}})
|
||||
|
||||
return
|
||||
|
||||
confirmation_2 = []
|
||||
for pattern in all_locales("confirm", "keyboard"):
|
||||
confirmation_2.append(pattern[1][0])
|
||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(confirmation_2, prefixes=[""]))
|
||||
async def confirm_no(app: Client, msg: Message, kind: Literal["application", "sponsorship"] = "unknown"):
|
||||
@app.on_message((custom_filters.enabled_applications | custom_filters.enabled_sponsorships) & ~filters.scheduled & filters.private & filters.command(confirmation_2, prefixes=[""]))
|
||||
async def confirm_no(app: Client, msg: Message, kind: Literal["application", "sponsorship", "unknown"] = "unknown"):
|
||||
|
||||
holo_user = HoloUser(msg.from_user)
|
||||
|
||||
if (kind == "application") or ((holo_user.application_state()[0] == "fill") and (holo_user.application_state()[1] is True)):
|
||||
holo_user.application_restart()
|
||||
await welcome_pass(app, msg, once_again=True)
|
||||
logWrite(f"User {msg.from_user.id} restarted the application due to typo in it")
|
||||
return
|
||||
if configGet("enabled", "features", "applications") is True:
|
||||
if (kind == "application") or ((holo_user.application_state()[0] == "fill") and (holo_user.application_state()[1] is True)):
|
||||
holo_user.application_restart()
|
||||
await welcome_pass(app, msg, once_again=True)
|
||||
logWrite(f"User {msg.from_user.id} restarted the application due to typo in it")
|
||||
return
|
||||
|
||||
if (kind == "sponsorship") or ((holo_user.sponsorship_state()[0] == "fill") and (holo_user.sponsorship_state()[1] is True)):
|
||||
holo_user.sponsorship_restart()
|
||||
await app.send_message(holo_user.id, locale(f"sponsor1", "message", locale=holo_user.locale), reply_markup=ForceReply(placeholder=str(locale(f"sponsor1", "force_reply", locale=holo_user.locale))))
|
||||
logWrite(f"User {msg.from_user.id} restarted the sponsorship application due to typo in it")
|
||||
return
|
||||
if configGet("enabled", "features", "sponsorships") is True:
|
||||
if (kind == "sponsorship") or ((holo_user.sponsorship_state()[0] == "fill") and (holo_user.sponsorship_state()[1] is True)):
|
||||
holo_user.sponsorship_restart()
|
||||
await app.send_message(holo_user.id, locale(f"sponsor1", "message", locale=holo_user.locale), reply_markup=ForceReply(placeholder=str(locale(f"sponsor1", "force_reply", locale=holo_user.locale))))
|
||||
logWrite(f"User {msg.from_user.id} restarted the sponsorship application due to typo in it")
|
||||
return
|
||||
# ==============================================================================================================================
|
@ -10,7 +10,7 @@ from classes.holo_user import HoloUser
|
||||
from modules import custom_filters
|
||||
|
||||
# Contact getting ==============================================================================================================
|
||||
@app.on_message(~ filters.scheduled & filters.contact & filters.private & (custom_filters.allowed | custom_filters.admin))
|
||||
@app.on_message(custom_filters.enabled_applications & ~filters.scheduled & filters.contact & filters.private & (custom_filters.allowed | custom_filters.admin))
|
||||
async def get_contact(app: Client, msg: Message):
|
||||
|
||||
holo_user = HoloUser(msg.from_user)
|
||||
|
@ -52,8 +52,12 @@ async def any_stage(app: Client, msg: Message):
|
||||
return
|
||||
|
||||
if msg.text is not None:
|
||||
await holo_user.application_next(msg.text, msg=msg)
|
||||
await holo_user.sponsorship_next(msg.text, msg=msg)
|
||||
|
||||
if configGet("enabled", "features", "applications") is True:
|
||||
await holo_user.application_next(msg.text, msg=msg)
|
||||
|
||||
if configGet("enabled", "features", "sponsorships") is True:
|
||||
await holo_user.sponsorship_next(msg.text, msg=msg)
|
||||
|
||||
# user_stage = configGet("stage", file=str(msg.from_user.id))
|
||||
|
||||
|
@ -4,9 +4,10 @@ from pyrogram.client import Client
|
||||
from modules.utils import configGet, locale
|
||||
from modules.logging import logWrite
|
||||
from classes.holo_user import HoloUser
|
||||
from modules import custom_filters
|
||||
|
||||
# Filter users on join =========================================================================================================
|
||||
@app.on_chat_member_updated(group=configGet("destination_group"))
|
||||
@app.on_chat_member_updated(custom_filters.enabled_invites_check, group=configGet("destination_group"))
|
||||
#@app.on_message(filters.new_chat_members, group=configGet("destination_group"))
|
||||
async def filter_join(app: Client, member: ChatMemberUpdated):
|
||||
|
||||
|
@ -2,10 +2,10 @@ from app import app
|
||||
from pyrogram import filters
|
||||
from pyrogram.types import Message
|
||||
from pyrogram.client import Client
|
||||
|
||||
from classes.holo_user import HoloUser
|
||||
from modules import custom_filters
|
||||
|
||||
@app.on_message(~ filters.scheduled & filters.photo & filters.private)
|
||||
@app.on_message(custom_filters.enabled_sponsorships & ~filters.scheduled & filters.photo & filters.private)
|
||||
async def sponsor_proof(app: Client, msg: Message):
|
||||
|
||||
if msg.via_bot is None:
|
||||
|
@ -5,8 +5,9 @@ from pyrogram.types import Message
|
||||
from pyrogram.client import Client
|
||||
from modules.logging import logWrite
|
||||
from modules.utils import configGet, locale
|
||||
from modules import custom_filters
|
||||
|
||||
@app.on_message(~ filters.scheduled & filters.voice & filters.chat(configGet("destination_group")))
|
||||
@app.on_message(custom_filters.enabled_dinovoice & ~filters.scheduled & filters.voice & filters.chat(configGet("destination_group")))
|
||||
async def voice_message(app: Client, msg: Message):
|
||||
logWrite(f"User {msg.from_user.id} sent voice message in destination group")
|
||||
await msg.reply_text(choice(locale("voice_message", "message")))
|
@ -4,6 +4,7 @@ from pyrogram.types import ForceReply, ReplyKeyboardMarkup, Message
|
||||
from pyrogram.client import Client
|
||||
from classes.holo_user import HoloUser
|
||||
from modules.utils import all_locales, locale, logWrite
|
||||
from modules import custom_filters
|
||||
|
||||
# Welcome check ================================================================================================================
|
||||
welcome_1 = []
|
||||
@ -11,7 +12,7 @@ for pattern in all_locales("welcome", "keyboard"):
|
||||
welcome_1.append(pattern[0][0])
|
||||
for pattern in all_locales("return", "keyboard"):
|
||||
welcome_1.append(pattern[0][0])
|
||||
@app.on_message(~ 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:
|
||||
"""Set user's stage to 1 and start a fresh application
|
||||
|
||||
@ -36,7 +37,7 @@ async def welcome_pass(app: Client, msg: Message, once_again: bool = True) -> No
|
||||
welcome_2 = []
|
||||
for pattern in all_locales("welcome", "keyboard"):
|
||||
welcome_2.append(pattern[1][0])
|
||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(welcome_2, prefixes=[""]))
|
||||
@app.on_message(custom_filters.enabled_applications & ~filters.scheduled & filters.private & filters.command(welcome_2, prefixes=[""]))
|
||||
async def welcome_reject(app: Client, msg: Message):
|
||||
|
||||
logWrite(f"User {msg.from_user.id} rejected to start the application")
|
||||
|
Reference in New Issue
Block a user