mirror of
https://github.com/Alexander-D-Karpov/scripts.git
synced 2024-11-21 19:46:38 +03:00
minor election status fixes
This commit is contained in:
parent
762c9ae286
commit
783bd23798
|
@ -1,10 +1,18 @@
|
||||||
FROM python:3.9-slim
|
ARG PYTHON_VERSION=3.11-slim
|
||||||
|
FROM python:${PYTHON_VERSION} as python
|
||||||
|
|
||||||
|
|
||||||
|
FROM python as python-build-stage
|
||||||
|
|
||||||
|
ARG BUILD_ENVIRONMENT=local
|
||||||
|
RUN mkdir "/app"
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
ARG BUILD_ENVIRONMENT=local
|
||||||
|
|
||||||
COPY requirements.txt .
|
ADD requirements.txt requirements.txt
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
ADD main.py main.py
|
||||||
|
ADD subscribed_chats.json subscribed_chats.json
|
||||||
|
|
||||||
COPY bot.py .
|
RUN pip install -r requirements.txt
|
||||||
|
|
||||||
CMD ["python", "main.py"]
|
CMD ["python", "main.py"]
|
|
@ -1,6 +1,7 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
from os import getenv
|
from os import getenv
|
||||||
|
|
||||||
from aiogram import Bot, Dispatcher, html, F
|
from aiogram import Bot, Dispatcher, html, F
|
||||||
|
@ -293,6 +294,8 @@ async def unsubscribe_callback(callback: CallbackQuery):
|
||||||
|
|
||||||
@dp.message(Command("get_data"))
|
@dp.message(Command("get_data"))
|
||||||
async def get_data_handler(message: Message):
|
async def get_data_handler(message: Message):
|
||||||
|
global subjects_data
|
||||||
|
|
||||||
chat_id = str(message.chat.id)
|
chat_id = str(message.chat.id)
|
||||||
if chat_id not in subscribed_chats or not subscribed_chats[chat_id]:
|
if chat_id not in subscribed_chats or not subscribed_chats[chat_id]:
|
||||||
await message.answer(
|
await message.answer(
|
||||||
|
@ -303,6 +306,9 @@ async def get_data_handler(message: Message):
|
||||||
limits_data = await get_itmo_limits()
|
limits_data = await get_itmo_limits()
|
||||||
response = "Информация о выбранных вариантах:\n\n"
|
response = "Информация о выбранных вариантах:\n\n"
|
||||||
|
|
||||||
|
if not subjects_data:
|
||||||
|
subjects_data = await get_itmo_data()
|
||||||
|
|
||||||
for item_id in subscribed_chats[chat_id]:
|
for item_id in subscribed_chats[chat_id]:
|
||||||
item = next(
|
item = next(
|
||||||
(
|
(
|
||||||
|
@ -368,6 +374,11 @@ async def update_token_handler(message: Message) -> None:
|
||||||
global ITMO_TOKEN
|
global ITMO_TOKEN
|
||||||
ITMO_TOKEN = new_token
|
ITMO_TOKEN = new_token
|
||||||
|
|
||||||
|
if not new_token:
|
||||||
|
await message.answer("Пожалуйста, укажите новый токен после команды.")
|
||||||
|
return
|
||||||
|
|
||||||
|
if os.path.exists(".env"):
|
||||||
with open(".env", "r") as file:
|
with open(".env", "r") as file:
|
||||||
lines = file.readlines()
|
lines = file.readlines()
|
||||||
with open(".env", "w") as file:
|
with open(".env", "w") as file:
|
||||||
|
@ -381,10 +392,20 @@ async def update_token_handler(message: Message) -> None:
|
||||||
|
|
||||||
|
|
||||||
async def periodic_updates(bot: Bot):
|
async def periodic_updates(bot: Bot):
|
||||||
|
global subjects_data
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
limits_data = await get_itmo_limits()
|
limits_data = await get_itmo_limits()
|
||||||
|
if not limits_data:
|
||||||
|
logging.error("Ошибка при получении лимитов")
|
||||||
|
await asyncio.sleep(300)
|
||||||
|
continue
|
||||||
for chat_id, subscribed_items in subscribed_chats.items():
|
for chat_id, subscribed_items in subscribed_chats.items():
|
||||||
response = "Обновленная информация о выбранных вариантах:\n\n"
|
response = "Обновленная информация о выбранных вариантах:\n\n"
|
||||||
|
|
||||||
|
if not subjects_data:
|
||||||
|
subjects_data = await get_itmo_data()
|
||||||
|
|
||||||
for item_id in subscribed_items:
|
for item_id in subscribed_items:
|
||||||
item = next(
|
item = next(
|
||||||
(
|
(
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
aiogram==3.10.0
|
aiogram==3.10.0
|
||||||
python-dotenv==1.0.1
|
python-dotenv==1.0.1
|
||||||
httpx==0.27.2
|
aiohttp==3.9.5
|
Loading…
Reference in New Issue
Block a user