This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Telegram/modules/custom_filters.py

56 lines
2.3 KiB
Python
Raw Normal View History

2023-01-03 14:02:39 +02:00
"""Custom message filters made to improve commands
usage in context of Holo Users."""
2023-01-04 20:58:54 +02:00
from os import path
2022-12-27 19:46:17 +02:00
from app import isAnAdmin
2023-01-04 20:58:54 +02:00
from modules.utils import configGet, jsonLoad
2023-01-04 22:57:11 +02:00
from modules.database import col_applications, col_tmp
2022-12-27 19:46:17 +02:00
from pyrogram import filters
2023-01-03 14:17:59 +02:00
from pyrogram.types import Message
2022-12-27 19:46:17 +02:00
2023-01-03 14:17:59 +02:00
async def admin_func(_, __, msg: Message):
return await isAnAdmin(msg.from_user.id)
2022-12-27 19:46:17 +02:00
2023-01-04 20:58:54 +02:00
async def member_func(_, __, msg: Message):
return True if (msg.from_user.id in jsonLoad(path.join(configGet("cache", "locations"), "group_members"))) else False
2023-01-03 14:17:59 +02:00
async def allowed_func(_, __, msg: Message):
2023-01-09 13:54:00 +02:00
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
2022-12-27 19:46:17 +02:00
2023-01-03 22:46:16 +02:00
async def enabled_general_func(_, __, msg: Message):
return configGet("enabled", "features", "general")
2023-01-03 21:48:35 +02:00
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")
2023-01-03 21:33:53 +02:00
2023-01-04 22:57:11 +02:00
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
2022-12-27 19:46:17 +02:00
admin = filters.create(admin_func)
2023-01-04 20:58:54 +02:00
member = filters.create(member_func)
2023-01-03 21:33:53 +02:00
allowed = filters.create(allowed_func)
2023-01-03 22:46:16 +02:00
enabled_general = filters.create(enabled_general_func)
2023-01-03 21:48:35 +02:00
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)
2023-01-04 22:57:11 +02:00
enabled_dinovoice = filters.create(enabled_dinovoice_func)
filling_sponsorship = filters.create(filling_sponsorship_func)