Spoilers, major command system improvements #4
@ -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,16 +12,19 @@ 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 configGet("enabled", "features", "applications") is True:
|
||||
|
||||
if (kind == "application") or ((holo_user.application_state()[0] == "fill") and (holo_user.application_state()[1] is True)):
|
||||
|
||||
tmp_application = col_tmp.find_one({"user": holo_user.id, "type": "application"})
|
||||
@ -93,6 +96,8 @@ async def confirm_yes(app: Client, msg: Message, kind: Literal["application", "s
|
||||
# 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"})
|
||||
@ -142,17 +147,19 @@ async def confirm_yes(app: Client, msg: Message, kind: Literal["application", "s
|
||||
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 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 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))))
|
||||
|
@ -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,7 +52,11 @@ async def any_stage(app: Client, msg: Message):
|
||||
return
|
||||
|
||||
if msg.text is not None:
|
||||
|
||||
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