fix: исправление проблем линтеров

This commit is contained in:
Maxim Slipenko 2024-08-15 19:33:04 +03:00
parent ac72ec7fa4
commit 913d84fb81
7 changed files with 24 additions and 24 deletions

View File

@ -1,7 +1,7 @@
from .filters import (
ChatIDFilter,
ChatModerOrAdminFilter,
ChatNotInApproveFilter,
ChatIDFilter,
chat_not_in_approve,
module_init,
)

View File

@ -1,9 +1,10 @@
from typing import TYPE_CHECKING
from aiogram import Router
from aiogram.filters import Command
from aiogram.types import Message, ChatMemberOwner, ChatMemberAdministrator
from aiogram.types import ChatMemberAdministrator, ChatMemberOwner, Message
from ocab_core.modules_system.public_api import get_module, register_router, log
from ocab_core.modules_system.public_api import get_module, log, register_router
if TYPE_CHECKING:
from ocab_modules.standard.filters import ChatIDFilter as IChatIDFilter
@ -11,41 +12,40 @@ if TYPE_CHECKING:
try:
ChatIDFilter: "type[IChatIDFilter]" = get_module("standard.filters", "ChatIDFilter")
FILTERS_MODULE_LOADED = True
except Exception as e:
except Exception:
FILTERS_MODULE_LOADED = False
pass
try:
register_command = get_module("standard.command_helper", "register_command")
COMMAND_HELPER_MODULE_LOADED = True
except Exception as e:
except Exception:
COMMAND_HELPER_MODULE_LOADED = False
pass
def can_moderate(admin: ChatMemberOwner | ChatMemberAdministrator) -> bool:
if isinstance(admin, ChatMemberOwner):
return True
return (
admin.user.is_bot == False and
(
admin.can_delete_messages and
admin.can_restrict_members
)
return admin.user.is_bot is False and (
admin.can_delete_messages and admin.can_restrict_members
)
async def report(message: Message):
try:
if message.reply_to_message is None:
await message.reply("Пожалуйста, используйте команду /report в ответ на сообщение, которое вы хотите отметить как спам.")
await message.reply(
"Пожалуйста, используйте команду /report в ответ на сообщение"
", которое вы хотите отметить как спам."
)
return
admins = await message.chat.get_administrators()
admin_usernames = [
admin.user.mention_html()
for admin in admins
if can_moderate(admin)
admin.user.mention_html() for admin in admins if can_moderate(admin)
]
if admin_usernames:
ping_message = "⚠️ Внимание, жалоба на спам! " + ", ".join(admin_usernames)