-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a3d547d
Showing
8 changed files
with
1,318 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
doc/source/generated | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# dotenv | ||
.env | ||
.venv | ||
|
||
# virtualenv | ||
venv/ | ||
ENV/ | ||
env/ | ||
.env.bak | ||
.envrc | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# IDEs | ||
.vscode/ | ||
.idea/ | ||
|
||
# Logs | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM python:3.10-slim | ||
|
||
ENV PYTHONDONTWRITEBYTECODE 1 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
WORKDIR /app | ||
|
||
RUN pip install poetry | ||
|
||
COPY pyproject.toml poetry.lock /app/ | ||
|
||
RUN poetry config virtualenvs.create false && poetry install --no-dev --no-interaction --no-ansi | ||
|
||
COPY . /app/ | ||
|
||
EXPOSE 5000 | ||
|
||
CMD ["poetry", "run", "python", "main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
.PHONY: format build run stop restart clean logs shell prune help | ||
|
||
# Formatting commands | ||
format: | ||
isort --force-single-line-imports . | ||
autoflake --remove-all-unused-imports --recursive --remove-unused-variables --in-place . --exclude=__init__.py | ||
black . | ||
isort --recursive --apply . | ||
|
||
# Docker commands | ||
build: | ||
docker build -t tg-bot . | ||
|
||
run: | ||
docker run --env-file .env -p 5000:5000 --name tg-bot tg-bot | ||
|
||
stop: | ||
docker stop tg-bot | ||
docker rm tg-bot | ||
|
||
restart: stop build run | ||
|
||
clean: | ||
docker rmi tg-bot | ||
|
||
logs: | ||
docker logs -f tg-bot | ||
|
||
shell: | ||
docker exec -it tg-bot /bin/sh | ||
|
||
prune: | ||
docker system prune -f | ||
docker volume prune -f | ||
|
||
# Default goal | ||
.DEFAULT_GOAL := help | ||
|
||
# Help target to list available commands | ||
help: | ||
@echo "Available commands:" | ||
@echo " format - Run code formatting tools" | ||
@echo " build - Build the Docker image" | ||
@echo " run - Run the Docker container" | ||
@echo " stop - Stop and remove the Docker container" | ||
@echo " restart - Stop, rebuild and run the Docker container" | ||
@echo " clean - Remove the Docker image" | ||
@echo " logs - Show logs of the running container" | ||
@echo " shell - Open a shell inside the running container" | ||
@echo " prune - Remove all unused Docker objects" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# AntiToxicBot 🤖🚫 | ||
|
||
AntiToxicBot — это Telegram-бот, который борется с токсичностью в чатах. Он использует Perspective API для анализа сообщений и выдает муты за токсичное поведение. | ||
|
||
## Установка и настройка 🛠️ | ||
|
||
### С использованием Poetry | ||
|
||
1. Клонируйте репозиторий: | ||
```bash | ||
git clone https://github.com/yourusername/AntiToxicBot.git | ||
``` | ||
2. Перейдите в директорию проекта: | ||
```bash | ||
cd AntiToxicBot | ||
``` | ||
3. Установите зависимости: | ||
```bash | ||
poetry install | ||
``` | ||
4. Создайте файл `.env` и добавьте ваши ключи API: | ||
```env | ||
PERSPECTIVE_API_KEY=your_perspective_api_key | ||
TELEGRAM_BOT_TOKEN=your_telegram_bot_token | ||
``` | ||
|
||
### С использованием Docker | ||
|
||
1. Клонируйте репозиторий: | ||
```bash | ||
git clone https://github.com/0niel/anti-toxic-bot.git | ||
``` | ||
2. Перейдите в директорию проекта: | ||
```bash | ||
cd anti-toxic-bot | ||
``` | ||
3. Соберите Docker-образ: | ||
```bash | ||
docker build -t tg-bot . | ||
``` | ||
4. Создайте файл `.env` и добавьте ваши ключи API: | ||
```env | ||
PERSPECTIVE_API_KEY=your_perspective_api_key | ||
TELEGRAM_BOT_TOKEN=your_telegram_bot_token | ||
``` | ||
5. Запустите контейнер: | ||
```bash | ||
docker run --env-file .env -p 5000:5000 --name tg-bot tg-bot | ||
``` | ||
|
||
## Запуск 🚀 | ||
|
||
### С использованием Poetry | ||
|
||
1. Запустите бота: | ||
```bash | ||
poetry run python main.py | ||
``` | ||
|
||
### С использованием Docker | ||
|
||
1. Запустите контейнер: | ||
```bash | ||
docker run --env-file .env -p 5000:5000 --name tg-bot tg-bot | ||
``` | ||
|
||
## Команды 📋 | ||
|
||
- `/start` — приветственное сообщение. | ||
- `/muted_users` — получить список замученных пользователей. | ||
|
||
## Makefile команды 🛠️ | ||
|
||
- `make format` — Запуск инструментов форматирования кода. | ||
- `make build` — Сборка Docker-образа. | ||
- `make run` — Запуск Docker-контейнера. | ||
- `make stop` — Остановка и удаление Docker-контейнера. | ||
- `make restart` — Остановка, пересборка и запуск Docker-контейнера. | ||
- `make clean` — Удаление Docker-образа. | ||
- `make logs` — Показ логов работающего контейнера. | ||
- `make shell` — Открытие шелла внутри работающего контейнера. | ||
- `make prune` — Удаление всех неиспользуемых объектов Docker. | ||
|
||
## Лицензия 📜 | ||
|
||
Этот проект лицензируется на условиях лицензии MIT. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import os | ||
|
||
from dotenv import load_dotenv | ||
from pydantic_settings import BaseSettings | ||
|
||
load_dotenv() | ||
|
||
|
||
class Config(BaseSettings): | ||
PERSPECTIVE_API_KEY: str = os.getenv("PERSPECTIVE_API_KEY") | ||
TELEGRAM_BOT_TOKEN: str = os.getenv("TELEGRAM_BOT_TOKEN") | ||
|
||
|
||
config = Config() |
Oops, something went wrong.