This commit closes #45

This commit is contained in:
Profitroll 2023-10-15 17:40:56 +02:00
parent 154db69f20
commit 6bd1234d3d
Signed by: profitroll
GPG Key ID: FA35CAB49DACD3B2
4 changed files with 32 additions and 4 deletions

18
modules/custom_filters.py Normal file
View File

@ -0,0 +1,18 @@
"""Custom message filters"""
from pyrogram import filters
from pyrogram.types import Message
from classes.pyroclient import PyroClient
async def _mode_post_func(_, __: PyroClient, message: Message):
return __.config["mode"]["post"]
async def _mode_submit_func(_, __: PyroClient, message: Message):
return __.config["mode"]["submit"]
mode_post = filters.create(_mode_post_func)
mode_submit = filters.create(_mode_submit_func)

View File

@ -3,9 +3,14 @@ from pyrogram.client import Client
from pyrogram.types import Message
from classes.pyroclient import PyroClient
from modules import custom_filters
@Client.on_message(~filters.scheduled & filters.command(["start"], prefixes="/"))
@Client.on_message(
custom_filters.mode_submit
& ~filters.scheduled
& filters.command(["start"], prefixes="/")
)
async def cmd_start(app: PyroClient, msg: Message):
user = await app.find_user(msg.from_user)
@ -16,7 +21,9 @@ async def cmd_start(app: PyroClient, msg: Message):
@Client.on_message(
~filters.scheduled & filters.command(["rules", "help"], prefixes="/")
custom_filters.mode_submit
& ~filters.scheduled
& filters.command(["rules", "help"], prefixes="/")
)
async def cmd_rules(app: PyroClient, msg: Message):
user = await app.find_user(msg.from_user)

View File

@ -4,10 +4,12 @@ from pyrogram.client import Client
from pyrogram.types import Message, User
from classes.pyroclient import PyroClient
from modules import custom_filters
@Client.on_message(
~filters.scheduled
custom_filters.mode_post
& ~filters.scheduled
& filters.chat(sync.config_get("comments", "posting"))
& filters.reply
& filters.command(["report"], prefixes=["", "/"])

View File

@ -13,6 +13,7 @@ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
from classes.enums.submission_types import SubmissionType
from classes.exceptions import SubmissionDuplicatesError, SubmissionUnsupportedError
from classes.pyroclient import PyroClient
from modules import custom_filters
from modules.database import col_submitted
from modules.utils import USERS_WITH_CONTEXT
@ -20,7 +21,7 @@ logger = logging.getLogger(__name__)
@Client.on_message(
~filters.scheduled & filters.private & filters.photo
custom_filters.mode_submit & ~filters.scheduled & filters.private & filters.photo
| filters.video
# | filters.animation
| filters.document