Skip to content
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
12 changes: 0 additions & 12 deletions .idea/dataSources.xml

This file was deleted.

7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM python:3.10
WORKDIR /app
COPY requirements.txt requirements.txt
COPY admins_id.txt admins_id.txt
RUN python3 -m pip install --upgrade pip
RUN pip install -r requirements.txt
COPY . .
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
generate:
alembic revision --m="$(NAME)" --autogenerate

migrate:
alembic upgrade head

File renamed without changes.
2 changes: 1 addition & 1 deletion alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ version_path_separator = os # Use os.pathsep. Default configuration used for ne
# are written from script.py.mako
# output_encoding = utf-8

sqlalchemy.url = postgresql+asyncpg://kts_user:kts_pass@localhost:5432/kts
sqlalchemy.url = postgresql+asyncpg://kts_user:kts_pass@db:5432/kts


[post_write_hooks]
Expand Down
8 changes: 4 additions & 4 deletions app/store/bot/keyboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def get_but(text, color):
}


keyboard_admin = {
"one_time": True,
keyboard = {
"one_time": False,
"buttons": [
[
get_but("Регистрация!", "primary"),
Expand All @@ -34,5 +34,5 @@ def get_but(text, color):
],
}

keyboard_admin = json.dumps(keyboard_admin, ensure_ascii=False).encode("utf-8")
keyboard_admin = str(keyboard_admin.decode("utf-8"))
keyboard = json.dumps(keyboard, ensure_ascii=False).encode("utf-8")
keyboard = str(keyboard.decode("utf-8"))
15 changes: 9 additions & 6 deletions app/store/bot/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from sqlalchemy import insert
from sqlalchemy.sql import select, update as refresh, delete

from app.store.bot.keyboards import keyboard_admin
from app.store.bot.keyboards import keyboard
from app.store.bot.lexicon import (
commands_for_users,
commands_for_admins,
Expand Down Expand Up @@ -35,7 +35,7 @@ def __init__(
self.time_end = {}
self.storage = {}
self.reader = open(
"/home/olred/PycharmProjects/kts_project_template/app/store/bot/admins_id.txt",
"admins_id.txt",
"r",
encoding="utf-8",
)
Expand Down Expand Up @@ -100,8 +100,7 @@ async def handle_updates(self, update):
)
if (
len(update.object.body.split()) == 2
and f"{lexicon_for_messages['ID_GROUP']} Исключить"
in update.object.body.split()
and "Исключить" in update.object.body.split()
):
await self.command_kick_from_game(
update.object.body.split()[1], update, game
Expand Down Expand Up @@ -223,7 +222,7 @@ async def command_list_of_commands(self, update, game):
"keyboard",
update.object.chat_id,
lexicon_for_messages["COMMANDS"],
keyboard_admin,
keyboard,
)
)
else:
Expand All @@ -235,7 +234,7 @@ async def command_list_of_commands(self, update, game):
"keyboard",
update.object.chat_id,
lexicon_for_messages["COMMANDS"],
keyboard_user,
keyboard,
)
)
else:
Expand Down Expand Up @@ -734,13 +733,17 @@ async def command_start_game(self, update, game):
)
)
elif len(game["users"]["participants"]) == 1:
game["kicked_users"]["kicked"] = []
await self.set_kicked(update, game["kicked_users"], game)
self.out_queue.put_nowait(
(
"message",
update.object.chat_id,
lexicon_for_messages["LITTLE_PEOPLE"],
)
)
game["kicked_users"]["kicked"] = []
await self.set_kicked(update, game["kicked_users"], game)
else:
for i in range(3, 0, -1):
self.out_queue.put_nowait(
Expand Down
2 changes: 1 addition & 1 deletion app/store/database/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, app: "Application"):
async def connect(self, *_: list, **__: dict) -> None:
self._db = db
self._engine = create_async_engine(
"postgresql+asyncpg://kts_user:kts_pass@localhost:5432/kts",
"postgresql+asyncpg://kts_user:kts_pass@db:5432/kts",
echo=True,
)
self.session = sessionmaker(
Expand Down
2 changes: 0 additions & 2 deletions app/store/vk_api/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def _build_query(host: str, method: str, params: dict) -> str:
if "v" not in params:
params["v"] = "5.132"
url += "&".join([f"{k}={v}" for k, v in params.items()])
print(url)
return url

async def _get_long_poll_service(self):
Expand Down Expand Up @@ -163,7 +162,6 @@ async def send_message(
"access_token": self.app.config.bot.token,
}
else:
print(1)
parametrs = {
"random_id": random.randint(1, 2**32),
"peer_id": message.chat_id,
Expand Down
26 changes: 26 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3.5'

services:
db:
container_name: db
restart: on-failure
ports:
- "5433:5432"
environment:
- POSTGRES_PASSWORD=kts_pass
- POSTGRES_USER=kts_user
- POSTGRES_DB=kts
image: postgres
volumes:
- pgdata:/var/lib/postgresql/data
bot:
image: olred/vk_bot_project:my-image
command: sh -c "make migrate && python run_bot.py"
restart: always
depends_on:
- db

volumes:
pgdata:


10 changes: 0 additions & 10 deletions etc/config.yaml

This file was deleted.

15 changes: 14 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,53 @@
aio-pika==9.0.4
aiohttp==3.8.3
aiohttp-apispec==2.2.3
aiohttp-session==2.12.0
aiormq==6.7.2
aiosignal==1.3.1
alembic==1.9.3
apispec==3.3.2
async-timeout==4.0.2
asyncpg==0.27.0
attrs==22.2.0
black==22.6.0
cffi==1.15.1
charset-normalizer==2.1.1
click==8.1.3
coverage==7.1.0
cryptography==39.0.1
exceptiongroup==1.1.0
frozenlist==1.3.3
greenlet==2.0.2
idna==3.4
iniconfig==2.0.0
Jinja2==3.1.2
Mako==1.2.4
MarkupSafe==2.1.2
marshmallow==3.19.0
multidict==6.0.4
mypy-extensions==1.0.0
packaging==23.0
pamqp==3.2.1
pathspec==0.11.0
pika==1.3.1
platformdirs==3.0.0
pluggy==1.0.0
py==1.11.0
pycparser==2.21
pyparsing==3.0.9
pytest==7.2.1
pytest-aiohttp==1.0.4
pytest-asyncio==0.20.3
pytest-cov==4.0.0
pytest-env==0.6.2
pytest-mock==3.10.0
python-dateutil==2.8.2
python-dotenv==0.21.1
PyYAML==6.0
simplejson==3.18.3
six==1.16.0
SQLAlchemy==2.0.3
tomli==2.0.1
typing_extensions==4.4.0
webargs==5.5.3
yarl==1.8.2
docker-compose=1.29.2-1