mirror of
https://gitflic.ru/project/alt-gnome/karkas.git
synced 2024-12-24 00:33:06 +03:00
добавлена фильтрация по чатам
This commit is contained in:
parent
9ca32cfa28
commit
c01dbcbe6b
@ -13,9 +13,6 @@ from ocab_core.modules_system.public_api import get_module, log, register_router
|
||||
|
||||
from .utils import MultiKeyDict, get_plural_form, key_from_poll, key_from_user_chat
|
||||
from .verifications_methods.base import BaseTask, VerificationCallback
|
||||
|
||||
# from .verifications_methods.simple import SimpleInlineButtonsMethod
|
||||
# from .verifications_methods.iamhuman import IAmHumanButton
|
||||
from .verifications_methods.math import MathInlineButtonsTask, MathPollTask
|
||||
from .verifications_methods.question import QuestionInlineButtonsTask, QuestionPollTask
|
||||
from .verifications_methods.simple import (
|
||||
@ -24,7 +21,18 @@ from .verifications_methods.simple import (
|
||||
)
|
||||
from .verifications_methods.utils import user_mention
|
||||
|
||||
# from .verifications_methods.question import QuestionButtonsVerification
|
||||
if TYPE_CHECKING:
|
||||
from ocab_modules.standard.config import IConfig
|
||||
from ocab_modules.standard.filters import ChatIDFilter as IChatIDFilter
|
||||
|
||||
config: "IConfig" = get_module("standard.config", "config")
|
||||
|
||||
try:
|
||||
ChatIDFilter: "type[IChatIDFilter]" = get_module("standard.filters", "ChatIDFilter")
|
||||
FILTERS_MODULE_LOADED = True
|
||||
except Exception:
|
||||
FILTERS_MODULE_LOADED = False
|
||||
pass
|
||||
|
||||
all_tasks = [
|
||||
MathInlineButtonsTask,
|
||||
@ -69,9 +77,6 @@ class TaskManager:
|
||||
verification_tasks = MultiKeyDict()
|
||||
last_success = {}
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ocab_modules.standard.config import IConfig
|
||||
|
||||
|
||||
async def new_member_handler(event: ChatMemberUpdated, bot: Bot):
|
||||
# НЕ СРАБОТАЕТ, ЕСЛИ ЧЕЛОВЕК УЖЕ ОГРАНИЧЕН В ПРАВАХ (RESTRICTED)
|
||||
@ -332,14 +337,23 @@ async def module_init():
|
||||
|
||||
router = Router()
|
||||
|
||||
router.chat_member(ChatMemberUpdatedFilter(JOIN_TRANSITION))(new_member_handler)
|
||||
router.chat_member(ChatMemberUpdatedFilter(LEAVE_TRANSITION))(left_member_handler)
|
||||
router.callback_query(VerificationCallback.filter())(
|
||||
common_filters_pre = []
|
||||
|
||||
if FILTERS_MODULE_LOADED:
|
||||
common_filters_pre.append(ChatIDFilter())
|
||||
|
||||
router.chat_member(*common_filters_pre, ChatMemberUpdatedFilter(JOIN_TRANSITION))(
|
||||
new_member_handler
|
||||
)
|
||||
router.chat_member(*common_filters_pre, ChatMemberUpdatedFilter(LEAVE_TRANSITION))(
|
||||
left_member_handler
|
||||
)
|
||||
router.callback_query(*common_filters_pre, VerificationCallback.filter())(
|
||||
handle_inline_button_verification
|
||||
)
|
||||
router.poll_answer()(handle_poll_verification)
|
||||
|
||||
# router.message()(handle_input_verification)
|
||||
# Нельзя применить ChatIDFilter из-за отстутсвия id чата
|
||||
router.poll_answer()(handle_poll_verification)
|
||||
|
||||
register_router(router)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user