mirror of
https://gitflic.ru/project/alt-gnome/karkas.git
synced 2024-12-23 16:23:02 +03:00
Merged with fix/hotfix-spam
This commit is contained in:
commit
3018bd217f
@ -20,10 +20,6 @@
|
||||
"name": "Gnomik",
|
||||
"path": "src/gnomik"
|
||||
},
|
||||
{
|
||||
"name": "ALT Linux",
|
||||
"path": "src/altlinux"
|
||||
},
|
||||
{
|
||||
"name": "Karkas Lite",
|
||||
"path": "src/karkas_lite"
|
||||
|
@ -1,25 +0,0 @@
|
||||
FROM python:3.12-slim as builder
|
||||
|
||||
RUN pip install poetry
|
||||
RUN mkdir -p /app
|
||||
COPY . /app
|
||||
|
||||
# Fix
|
||||
|
||||
RUN sed -i '/karkas-core = {/{s/, develop = true//}' /app/src/altlinux/pyproject.toml && \
|
||||
sed -i '/karkas-blocks = {/{s/, develop = true//}' /app/src/altlinux/pyproject.toml && \
|
||||
sed -i '/karkas-core = {/{s/, develop = true//}' /app/src/karkas_blocks/pyproject.toml
|
||||
|
||||
WORKDIR /app/src/altlinux
|
||||
|
||||
RUN poetry lock && poetry install
|
||||
|
||||
FROM python:3.12-slim as base
|
||||
|
||||
# Copy the virtual environment separately to improve caching
|
||||
COPY --from=builder /app/src/altlinux/.venv /app/.venv
|
||||
COPY --from=builder /app/src/altlinux /app
|
||||
|
||||
WORKDIR /app
|
||||
ENV PATH="/app/.venv/bin:$PATH"
|
||||
CMD ["python", "-m", "altlinux"]
|
@ -1,14 +0,0 @@
|
||||
**/Dockerfile
|
||||
**/*.dockerignore
|
||||
**/docker-compose.yml
|
||||
|
||||
**/.git
|
||||
**/.gitignore
|
||||
|
||||
**/.venv
|
||||
|
||||
**/.mypy_cache
|
||||
**/__pycache__/
|
||||
|
||||
src/gnomik/config.yaml
|
||||
src/gnomik/database/*
|
@ -1,55 +0,0 @@
|
||||
# ALT Linux
|
||||
|
||||
## Описание
|
||||
|
||||
Бот, созданный на основе платформы «Каркас» и подготовленный для интеграции в чат [Альт Линукс](https://t.me/alt_linux)
|
||||
|
||||
## Функционал
|
||||
|
||||
Список блоков, используемых в боте:
|
||||
|
||||
- `report` — вызов администрации чата одной командой;
|
||||
- `welcome` — автоматическая вариативная проверка пользователей на признаки бота или другой рекламной системы;
|
||||
- `help` — получение справки о боте.
|
||||
|
||||
## Запуск
|
||||
|
||||
### Через Docker образ
|
||||
|
||||
1. Соберите Docker образ:
|
||||
|
||||
```shell
|
||||
docker build -t altlinux -f Dockerfile ../..
|
||||
```
|
||||
|
||||
2. Запустите контейнер:
|
||||
|
||||
```shell
|
||||
docker run -v ./config.yaml:/app/config.yaml altlinux
|
||||
```
|
||||
|
||||
Замените `./config.yaml` на путь к локальному файлу конфигурации.
|
||||
|
||||
### Вручную
|
||||
|
||||
1. Активируйте виртуальное окружение:
|
||||
|
||||
```shell
|
||||
poetry shell
|
||||
```
|
||||
|
||||
2. Запустите бота:
|
||||
|
||||
```shell
|
||||
python -m altlinux
|
||||
```
|
||||
|
||||
## Конфигурация
|
||||
|
||||
Конфигурация хранится в файле `config.yaml`.
|
||||
|
||||
Пример конфигурации бота находится в файле [`config-example.yaml`](./config-example.yaml).
|
||||
|
||||
## Блоки
|
||||
|
||||
Список загружаемых блоков указан в файле [`__main__.py`](./altlinux/__main__.py).
|
@ -1,25 +0,0 @@
|
||||
import asyncio
|
||||
from importlib.metadata import version
|
||||
|
||||
from karkas_blocks import block_loader
|
||||
from karkas_core import Karkas
|
||||
|
||||
|
||||
async def main():
|
||||
karkas = Karkas()
|
||||
# Argument `safe` has a value `False` because of `super().__init__()`
|
||||
await karkas.init_app(
|
||||
[
|
||||
block_loader("standard", "config", safe=False),
|
||||
block_loader("standard", "command_helper"),
|
||||
block_loader("standard", "filters", safe=False),
|
||||
block_loader("standard", "report"),
|
||||
block_loader("standard", "welcome", safe=False),
|
||||
block_loader("standard", "help"),
|
||||
],
|
||||
metainfo={"app_version": version("altlinux")},
|
||||
)
|
||||
await karkas.start()
|
||||
|
||||
|
||||
asyncio.run(main())
|
@ -1,7 +0,0 @@
|
||||
core:
|
||||
mode: LONG_POLLING
|
||||
token: xxx
|
||||
|
||||
filters:
|
||||
approved_chat_id:
|
||||
- -111111
|
@ -1,9 +0,0 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: src/altlinux/Dockerfile
|
||||
volumes:
|
||||
- ./config.yaml:/app/config.yaml
|
2902
src/altlinux/poetry.lock
generated
2902
src/altlinux/poetry.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,2 +0,0 @@
|
||||
[virtualenvs]
|
||||
in-project = true
|
@ -1,22 +0,0 @@
|
||||
[tool.poetry]
|
||||
name = "altlinux"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = [
|
||||
"Максим Слипенко <maxim@slipenko.com>"
|
||||
]
|
||||
readme = "README.md"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.10,<3.13"
|
||||
karkas-core = { extras=["webhook"], path = "../karkas_core", develop = true }
|
||||
karkas-blocks = { path = "../karkas_blocks", develop = true }
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
|
||||
[[tool.poetry.source]]
|
||||
name = "pytorch-cpu"
|
||||
url = "https://download.pytorch.org/whl/cpu"
|
||||
priority = "explicit"
|
@ -64,7 +64,7 @@ async def delete_spam_by_request(message: "Message", bot: "Bot"):
|
||||
if message.reply_to_message.from_user.id in (message.from_user.id, bot.id):
|
||||
return
|
||||
|
||||
await delete_spam(message.reply_to_message)
|
||||
await delete_spam(message.reply_to_message, bot)
|
||||
|
||||
await bot.delete_message(
|
||||
chat_id=message.chat.id,
|
||||
|
Loading…
Reference in New Issue
Block a user