fix routes
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-03-28 20:10:12 +05:00
parent 9e1e5c16da
commit 4183875ff8
4 changed files with 13 additions and 15 deletions

View File

@@ -2,14 +2,15 @@ from aiogram import Bot, Dispatcher, types
from aiogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
from aiogram.utils import executor
from aiogram.dispatcher.filters import Text
from pomodoro_bot.user_manager import user_manager
from pomodoro_bot.timer_manager import timer_manager
from .user_manager import user_manager
from .timer_manager import TimerManager
import os
API_TOKEN = os.getenv("BOT_TOKEN")
bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)
timer_manager = TimerManager(bot)
menu_kb = InlineKeyboardMarkup(row_width=2)
menu_kb.add(

View File

@@ -1,6 +1,6 @@
import asyncio
from pomodoro_bot.bot import run_bot
from pomodoro_bot.redis_client import init_redis
from .bot import run_bot
from .redis_client import init_redis
if __name__ == '__main__':
asyncio.run(init_redis())

View File

@@ -1,13 +1,10 @@
import asyncio
from pomodoro_bot.user_manager import user_manager
from pomodoro_bot.models import UserState
from aiogram import Bot
import os
bot = Bot(token=os.getenv("BOT_TOKEN"))
from .user_manager import user_manager
from .models import UserState
class TimerManager:
def __init__(self):
def __init__(self, bot):
self.bot = bot
self.tasks = {}
async def start_timer(self, user_id, duration, chat_id, label):
@@ -17,7 +14,7 @@ class TimerManager:
await asyncio.sleep(duration)
if label == 'Pomodoro':
await user_manager.increment_pomodoros(user_id)
await bot.send_message(chat_id, f"{label} завершён!")
await self.bot.send_message(chat_id, f"{label} завершён!")
task = asyncio.create_task(timer())
user = user_manager.get_user(user_id)
@@ -31,4 +28,4 @@ class TimerManager:
user.task.cancel()
user.task = None
user.current_timer = None
self.tasks.pop(user_id, None)
self.tasks.pop(user_id, None)

View File

@@ -1,5 +1,5 @@
from pomodoro_bot.models import UserState
from pomodoro_bot.redis_client import r as redis
from .models import UserState
from .redis_client import r as redis
class UserManager:
def __init__(self):