This commit closes #45
This commit is contained in:
parent
154db69f20
commit
6bd1234d3d
18
modules/custom_filters.py
Normal file
18
modules/custom_filters.py
Normal 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)
|
@ -3,9 +3,14 @@ from pyrogram.client import Client
|
|||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
|
|
||||||
from classes.pyroclient import PyroClient
|
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):
|
async def cmd_start(app: PyroClient, msg: Message):
|
||||||
user = await app.find_user(msg.from_user)
|
user = await app.find_user(msg.from_user)
|
||||||
|
|
||||||
@ -16,7 +21,9 @@ async def cmd_start(app: PyroClient, msg: Message):
|
|||||||
|
|
||||||
|
|
||||||
@Client.on_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):
|
async def cmd_rules(app: PyroClient, msg: Message):
|
||||||
user = await app.find_user(msg.from_user)
|
user = await app.find_user(msg.from_user)
|
||||||
|
@ -4,10 +4,12 @@ from pyrogram.client import Client
|
|||||||
from pyrogram.types import Message, User
|
from pyrogram.types import Message, User
|
||||||
|
|
||||||
from classes.pyroclient import PyroClient
|
from classes.pyroclient import PyroClient
|
||||||
|
from modules import custom_filters
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(
|
@Client.on_message(
|
||||||
~filters.scheduled
|
custom_filters.mode_post
|
||||||
|
& ~filters.scheduled
|
||||||
& filters.chat(sync.config_get("comments", "posting"))
|
& filters.chat(sync.config_get("comments", "posting"))
|
||||||
& filters.reply
|
& filters.reply
|
||||||
& filters.command(["report"], prefixes=["", "/"])
|
& filters.command(["report"], prefixes=["", "/"])
|
||||||
|
@ -13,6 +13,7 @@ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
|
|||||||
from classes.enums.submission_types import SubmissionType
|
from classes.enums.submission_types import SubmissionType
|
||||||
from classes.exceptions import SubmissionDuplicatesError, SubmissionUnsupportedError
|
from classes.exceptions import SubmissionDuplicatesError, SubmissionUnsupportedError
|
||||||
from classes.pyroclient import PyroClient
|
from classes.pyroclient import PyroClient
|
||||||
|
from modules import custom_filters
|
||||||
from modules.database import col_submitted
|
from modules.database import col_submitted
|
||||||
from modules.utils import USERS_WITH_CONTEXT
|
from modules.utils import USERS_WITH_CONTEXT
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
@Client.on_message(
|
@Client.on_message(
|
||||||
~filters.scheduled & filters.private & filters.photo
|
custom_filters.mode_submit & ~filters.scheduled & filters.private & filters.photo
|
||||||
| filters.video
|
| filters.video
|
||||||
# | filters.animation
|
# | filters.animation
|
||||||
| filters.document
|
| filters.document
|
||||||
|
Reference in New Issue
Block a user