Merged with cicd/init

This commit is contained in:
Maxim Slipenko 2024-08-15 20:44:40 +03:00
commit 3514234526
8 changed files with 38 additions and 24 deletions

View File

@ -1,8 +1,8 @@
Руководитель проекта:
- Семен Фомченков (@Armatik), e-mail: armatik@alt-gnome.ru
Ведущие разработчики:
- Максим Слипенко (@Maks1m_S), e-mail: maxim@slipenko.com
Участники проекта:
- Илья Женецкий (@ilyazheprog)

14
gitflic-ci.yaml Normal file
View File

@ -0,0 +1,14 @@
stages:
- lint
lint-pre-commit:
stage: lint
image: python:3.12-bullseye
before_script:
- pip install pre-commit
scripts:
- pre-commit run --all-files
cache:
paths:
- .cache/pip
- .cache/pre-commit

View File

@ -2,7 +2,7 @@
## Описание
Подготовленная версия OCAB Lite для интеграции в чат [Альт Линукс](https://t.me/alt_linux)
Подготовленная версия OCAB Lite для интеграции в чат [Альт Линукс](https://t.me/alt_linux)
## Функционал
Список OCAB-модулей используемых в боте:

View File

@ -4,4 +4,4 @@ core:
filters:
approved_chat_id:
- -111111
- -111111

View File

@ -85,7 +85,7 @@ class ConfigManager:
value_type: str,
options: List[Any] = None,
multiple: bool = False,
default_value = None,
default_value=None,
editable: bool = True,
shared: bool = False,
required: bool = False,

View File

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

View File

@ -1 +1 @@
from .main import module_init
from .main import 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 в ответ на сообщение, которое вы хотите отметить как спам.")
return
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)
@ -66,4 +66,4 @@ async def module_init():
if COMMAND_HELPER_MODULE_LOADED:
register_command = get_module("standard.command_helper", "register_command")
register_command("report", "Пожаловаться на спам")
register_command("report", "Пожаловаться на спам")