Skip to content
Merged
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
15 changes: 13 additions & 2 deletions telegram_bot_project/bot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from messages import MESSAGES
from service.idea import IdeaService
from service.user import UserService
from bot.buttons import get_language_keyboard, menu_reply_keyboard, idea_reply_keyboard
from bot.buttons import get_language_keyboard, menu_reply_keyboard, idea_reply_keyboard, task_menu_keyboard
from states import DialogStates

# Start Command Handler
Expand Down Expand Up @@ -130,4 +130,15 @@ async def task_command(message: types.Message, state: FSMContext):
print(f"--[INFO] - User with id: {user_id} - opened /task.")

await message.answer(MESSAGES[language]['TASK_ADD'])
await state.set_state(DialogStates.confirm_task)
await state.set_state(DialogStates.confirm_task)

# Open task menu handler
async def task_menu_command(message: types.Message):
user_id: int = message.from_user.id
user_find: Any = await UserService.get_user_by_id(user_id)
language: str = await UserService.get_user_language(user_id)

if not user_find:
await message.answer(MESSAGES['ENGLISH']['AUTHORIZATION_PROBLEM'])
else:
await message.answer(MESSAGES[language]['TASK_MENU'], reply_markup=task_menu_keyboard())
44 changes: 39 additions & 5 deletions telegram_bot_project/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,42 @@
from aiogram import Dispatcher, Bot, F
from aiogram.filters import Command
from aiogram.fsm.storage.memory import MemoryStorage
from aiogram.types import CallbackQuery
from aiogram.types import CallbackQuery, Message
from aiogram.fsm.context import FSMContext
from bot.callbacks import (
start_callback_language,
callback_idea_process,
callback_task_deadline
)
from bot.commands import (
start_command,
help_command,
menu_command,
language_command,
idea_command,
ideas_command,
delete_idea_command,
update_idea_command,
task_command,
task_menu_command
)
from bot.handlers import (
process_idea_save,
process_idea_delete,
process_idea_update,
process_save_updated_idea_text,
process_task_save,
process_task_deadline
)
from config import TOKEN
from bot.commands import *
from bot.handlers import *
from bot.callbacks import start_callback_language, callback_idea_process, callback_task_deadline
from messages import *
from messages import (
MENU_BUTTON,
BUTTON_IDEA,
ALL_IDEAS,
DEL_IDEA_BUTTON,
UPDATE_IDEA_BUTTON,
BUTTON_ADD_TASK
)
from states import DialogStates

storage: MemoryStorage = MemoryStorage()
Expand Down Expand Up @@ -57,6 +87,10 @@ async def task(message: Message, state: FSMContext):
async def add_task(message: Message, state: FSMContext):
await task_command(message, state)

@dp.message(Command("/taskmenu"))
async def task_menu(message: Message):
await task_menu_command(message)

@dp.callback_query(F.data.in_({"lang_ua", "lang_en"}))
async def callback_language(callback_query: CallbackQuery):
await start_callback_language(callback_query)
Expand Down
2 changes: 2 additions & 0 deletions telegram_bot_project/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"TASK_DEADLINE_NO": "Гаразд, без крайнього терміну. Ваше завдання збережено.",
"TASK_DEADLINE_INVALID": "Недійсний термін. Будь ласка, спробуйте ще раз.",
"TASK_SAVED": "Задачу збережено.",
"TASK_MENU": "Меню задач",
"LANGUAGE_ASK": (
"🌐 **Оберіть мову інтерфейсу:**\n"
"Натисніть кнопку нижче, щоб продовжити:"
Expand Down Expand Up @@ -80,6 +81,7 @@
"TASK_DEADLINE_NO": "Ok, no deadline. Your task saved.",
"TASK_DEADLINE_INVALID": "Invalid deadline. Please try again.",
"TASK_SAVED": "Task saved successfully.",
"TASK_MENU": "Task menu",
"LANGUAGE_ASK": (
"🌐 **Please choose your interface language:**\n"
"Tap a button below to continue:"
Expand Down