98 lines
2.8 KiB
Python
98 lines
2.8 KiB
Python
"""Custom message filters made to improve commands
|
|
usage in context of Holo Users."""
|
|
|
|
from os import path
|
|
from app import isAnAdmin
|
|
from modules.utils import configGet, jsonLoad
|
|
from modules.database import col_applications, col_tmp, col_bans
|
|
from pyrogram import filters
|
|
from pyrogram.types import Message
|
|
|
|
|
|
async def admin_func(_, __, msg: Message):
|
|
return await isAnAdmin(msg.from_user.id)
|
|
|
|
|
|
async def member_func(_, __, msg: Message):
|
|
return (
|
|
True
|
|
if (
|
|
msg.from_user.id
|
|
in jsonLoad(path.join(configGet("cache", "locations"), "group_members"))
|
|
)
|
|
else False
|
|
)
|
|
|
|
|
|
async def allowed_func(_, __, msg: Message):
|
|
output = False
|
|
output = (
|
|
True
|
|
if (col_applications.find_one({"user": msg.from_user.id}) is not None)
|
|
else False
|
|
)
|
|
if path.exists(path.join(configGet("cache", "locations"), "group_members")) and (
|
|
msg.from_user.id
|
|
not in jsonLoad(path.join(configGet("cache", "locations"), "group_members"))
|
|
):
|
|
output = False
|
|
return output
|
|
|
|
|
|
async def banned_func(_, __, msg: Message):
|
|
return True if col_bans.find_one({"user": msg.from_user.id}) is not None else False
|
|
|
|
|
|
async def enabled_general_func(_, __, msg: Message):
|
|
return configGet("enabled", "features", "general")
|
|
|
|
|
|
async def enabled_applications_func(_, __, msg: Message):
|
|
return configGet("enabled", "features", "applications")
|
|
|
|
|
|
async def enabled_sponsorships_func(_, __, msg: Message):
|
|
return configGet("enabled", "features", "sponsorships")
|
|
|
|
|
|
async def enabled_warnings_func(_, __, msg: Message):
|
|
return configGet("enabled", "features", "warnings")
|
|
|
|
|
|
async def enabled_invites_check_func(_, __, msg: Message):
|
|
return configGet("enabled", "features", "invites_check")
|
|
|
|
|
|
async def enabled_dinovoice_func(_, __, msg: Message):
|
|
return configGet("enabled", "features", "dinovoice")
|
|
|
|
|
|
async def enabled_spoilers_func(_, __, msg: Message):
|
|
return configGet("enabled", "features", "spoilers")
|
|
|
|
|
|
async def filling_sponsorship_func(_, __, msg: Message):
|
|
return (
|
|
True
|
|
if col_tmp.find_one({"user": msg.from_user.id, "type": "sponsorship"})
|
|
is not None
|
|
else False
|
|
)
|
|
|
|
|
|
admin = filters.create(admin_func)
|
|
member = filters.create(member_func)
|
|
allowed = filters.create(allowed_func)
|
|
|
|
banned = filters.create(banned_func)
|
|
|
|
enabled_general = filters.create(enabled_general_func)
|
|
enabled_applications = filters.create(enabled_applications_func)
|
|
enabled_sponsorships = filters.create(enabled_sponsorships_func)
|
|
enabled_warnings = filters.create(enabled_warnings_func)
|
|
enabled_invites_check = filters.create(enabled_invites_check_func)
|
|
enabled_dinovoice = filters.create(enabled_dinovoice_func)
|
|
enabled_spoilers = filters.create(enabled_spoilers_func)
|
|
|
|
filling_sponsorship = filters.create(filling_sponsorship_func)
|