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.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
from aiogram.utils import executor from aiogram.utils import executor
from aiogram.dispatcher.filters import Text from aiogram.dispatcher.filters import Text
from pomodoro_bot.user_manager import user_manager from .user_manager import user_manager
from pomodoro_bot.timer_manager import timer_manager from .timer_manager import TimerManager
import os import os
API_TOKEN = os.getenv("BOT_TOKEN") API_TOKEN = os.getenv("BOT_TOKEN")
bot = Bot(token=API_TOKEN) bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot) dp = Dispatcher(bot)
timer_manager = TimerManager(bot)
menu_kb = InlineKeyboardMarkup(row_width=2) menu_kb = InlineKeyboardMarkup(row_width=2)
menu_kb.add( menu_kb.add(

View File

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

View File

@@ -1,13 +1,10 @@
import asyncio import asyncio
from pomodoro_bot.user_manager import user_manager from .user_manager import user_manager
from pomodoro_bot.models import UserState from .models import UserState
from aiogram import Bot
import os
bot = Bot(token=os.getenv("BOT_TOKEN"))
class TimerManager: class TimerManager:
def __init__(self): def __init__(self, bot):
self.bot = bot
self.tasks = {} self.tasks = {}
async def start_timer(self, user_id, duration, chat_id, label): async def start_timer(self, user_id, duration, chat_id, label):
@@ -17,7 +14,7 @@ class TimerManager:
await asyncio.sleep(duration) await asyncio.sleep(duration)
if label == 'Pomodoro': if label == 'Pomodoro':
await user_manager.increment_pomodoros(user_id) 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()) task = asyncio.create_task(timer())
user = user_manager.get_user(user_id) user = user_manager.get_user(user_id)

View File

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