Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.0 #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ celerybeat.pid
*.sage.py

# Environments
.env.*
*.env
*.venv
env/
Expand Down
34 changes: 34 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Use the official Python image as the base image
FROM python:3.10

# Install necessary dependencies for Chrome and ChromeDriver
RUN apt-get update && apt-get install -y wget gnupg
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list
RUN apt-get update && apt-get install -y google-chrome-stable

# Create a new non-root user with a home directory
RUN useradd -m -s /bin/bash spellsbot

# Set the working directory to /app
WORKDIR /app

# Copy the requirements file into the container at /app
COPY requirements.txt .

# Install project dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the rest of the application code
COPY . /app

# Change the ownership of the /app directory to the newly created user
RUN chown -R spellsbot:spellsbot /app
# Set the user for subsequent commands
USER spellsbot

ENV CHROME_HEADLESS=1
ENV PYTHONPATH=/app

# Run the run.py script
CMD ["python", "spells_bot/run.py"]
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
Pathfinder Spellbook for Telegram.

Available at [@SpellsBot](https://t.me/SpellsBot).

### Run
Build
```
docker build --rm -t spellsbot .
```

Run the container providing `--env-file` and `-v` mounts for database file and table data directory
```
docker run -d --name spellsbot-dev \
--env-file .env.dev \
-v /botdata/db_files:/db_data \
-v /botdata/data:/table_data \
spellsbot

```

### Telegram Commands
`/start` - Приветствие

`/menu` - Поиск по классам и кругам

`/spellbook` - Моя книга заклинаний

`/help` - Как пользоваться книгой

`/settings` - Настройки поиска
164 changes: 0 additions & 164 deletions bot.py

This file was deleted.

14 changes: 10 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
pydantic[dotenv]==1.9.0
python-telegram-bot==13.4.1
SQLAlchemy==1.4.31
requests-html==0.10.0
git+https://github.com/aiogram/[email protected]
pydantic==2.1.1
pydantic-settings==2.0.1
SQLAlchemy==2.0.18
aiohttp==3.8.5
beautifulsoup4==4.12.2
cachetools==5.3.1
types-cachetools==5.3.0.5
html2image==2.0.3
certifi==2023.7.22
Empty file added spells_bot/__init__.py
Empty file.
Empty file added spells_bot/bot/__init__.py
Empty file.
53 changes: 53 additions & 0 deletions spells_bot/bot/callback_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from aiogram.filters.callback_data import CallbackData


class MenuClassCallback(CallbackData, prefix="MENU_CLS"):
""""""


class BaseClassesCallback(CallbackData, prefix="CLS"):
id: int


class ClassesTableCallback(BaseClassesCallback, prefix="CLS_TABLE"):
""""""


class ClassesSpellsCallback(BaseClassesCallback, prefix="CLS_SPELL"):
""""""
spell_level: int
page: int | None = 0


class SpellTablesCallback(CallbackData, prefix="SPELL_TABLE"):
spell_id: int


class SpellbookReadCallback(CallbackData, prefix="BOOK_R"):
index: int
spell_id: int | None = None
extended: bool = False


class SpellbookCreateCallback(CallbackData, prefix="BOOK_C"):
spell_id: int | None = None


class SpellbookPromptDeleteCallback(SpellbookReadCallback, prefix="BOOK_TRY_D"):
""""""


class SpellbookConfirmDeleteCallback(SpellbookReadCallback, prefix="BOOK_D"):
spell_id: int


class ChatSettingsAddFilterCallback(CallbackData, prefix="SETTINGS_ADD"):
rulebook_id: int


class ChatSettingsRemoveFilterCallback(CallbackData, prefix="SETTINGS_REMOVE"):
rulebook_id: int


class EmptyCallback(CallbackData, prefix="IGNORE"):
""""""
Empty file.
Loading