mirror of
https://gitflic.ru/project/alt-gnome/karkas.git
synced 2024-12-24 08:34:42 +03:00
fix: исправление проблем линтеров
This commit is contained in:
parent
ac72ec7fa4
commit
913d84fb81
@ -1,7 +1,7 @@
|
|||||||
from .filters import (
|
from .filters import (
|
||||||
|
ChatIDFilter,
|
||||||
ChatModerOrAdminFilter,
|
ChatModerOrAdminFilter,
|
||||||
ChatNotInApproveFilter,
|
ChatNotInApproveFilter,
|
||||||
ChatIDFilter,
|
|
||||||
chat_not_in_approve,
|
chat_not_in_approve,
|
||||||
module_init,
|
module_init,
|
||||||
)
|
)
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from aiogram import Router
|
from aiogram import Router
|
||||||
from aiogram.filters import Command
|
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:
|
if TYPE_CHECKING:
|
||||||
from ocab_modules.standard.filters import ChatIDFilter as IChatIDFilter
|
from ocab_modules.standard.filters import ChatIDFilter as IChatIDFilter
|
||||||
@ -11,41 +12,40 @@ if TYPE_CHECKING:
|
|||||||
try:
|
try:
|
||||||
ChatIDFilter: "type[IChatIDFilter]" = get_module("standard.filters", "ChatIDFilter")
|
ChatIDFilter: "type[IChatIDFilter]" = get_module("standard.filters", "ChatIDFilter")
|
||||||
FILTERS_MODULE_LOADED = True
|
FILTERS_MODULE_LOADED = True
|
||||||
except Exception as e:
|
except Exception:
|
||||||
FILTERS_MODULE_LOADED = False
|
FILTERS_MODULE_LOADED = False
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
register_command = get_module("standard.command_helper", "register_command")
|
register_command = get_module("standard.command_helper", "register_command")
|
||||||
COMMAND_HELPER_MODULE_LOADED = True
|
COMMAND_HELPER_MODULE_LOADED = True
|
||||||
except Exception as e:
|
except Exception:
|
||||||
COMMAND_HELPER_MODULE_LOADED = False
|
COMMAND_HELPER_MODULE_LOADED = False
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def can_moderate(admin: ChatMemberOwner | ChatMemberAdministrator) -> bool:
|
def can_moderate(admin: ChatMemberOwner | ChatMemberAdministrator) -> bool:
|
||||||
if isinstance(admin, ChatMemberOwner):
|
if isinstance(admin, ChatMemberOwner):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return (
|
return admin.user.is_bot is False and (
|
||||||
admin.user.is_bot == False and
|
admin.can_delete_messages and admin.can_restrict_members
|
||||||
(
|
|
||||||
admin.can_delete_messages and
|
|
||||||
admin.can_restrict_members
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def report(message: Message):
|
async def report(message: Message):
|
||||||
try:
|
try:
|
||||||
if message.reply_to_message is None:
|
if message.reply_to_message is None:
|
||||||
await message.reply("Пожалуйста, используйте команду /report в ответ на сообщение, которое вы хотите отметить как спам.")
|
await message.reply(
|
||||||
|
"Пожалуйста, используйте команду /report в ответ на сообщение"
|
||||||
|
", которое вы хотите отметить как спам."
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
admins = await message.chat.get_administrators()
|
admins = await message.chat.get_administrators()
|
||||||
|
|
||||||
admin_usernames = [
|
admin_usernames = [
|
||||||
admin.user.mention_html()
|
admin.user.mention_html() for admin in admins if can_moderate(admin)
|
||||||
for admin in admins
|
|
||||||
if can_moderate(admin)
|
|
||||||
]
|
]
|
||||||
if admin_usernames:
|
if admin_usernames:
|
||||||
ping_message = "⚠️ Внимание, жалоба на спам! " + ", ".join(admin_usernames)
|
ping_message = "⚠️ Внимание, жалоба на спам! " + ", ".join(admin_usernames)
|
||||||
|
Loading…
Reference in New Issue
Block a user