Skip to content

Commit b051eea

Browse files
authored
Merge pull request #18 from gnatykdm/Task-Configuration
Task-Configuration[Task-Menu] C:5
2 parents bb097ae + d746665 commit b051eea

File tree

3 files changed

+54
-7
lines changed

3 files changed

+54
-7
lines changed

telegram_bot_project/bot/commands.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from messages import MESSAGES
77
from service.idea import IdeaService
88
from service.user import UserService
9-
from bot.buttons import get_language_keyboard, menu_reply_keyboard, idea_reply_keyboard
9+
from bot.buttons import get_language_keyboard, menu_reply_keyboard, idea_reply_keyboard, task_menu_keyboard
1010
from states import DialogStates
1111

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

132132
await message.answer(MESSAGES[language]['TASK_ADD'])
133-
await state.set_state(DialogStates.confirm_task)
133+
await state.set_state(DialogStates.confirm_task)
134+
135+
# Open task menu handler
136+
async def task_menu_command(message: types.Message):
137+
user_id: int = message.from_user.id
138+
user_find: Any = await UserService.get_user_by_id(user_id)
139+
language: str = await UserService.get_user_language(user_id)
140+
141+
if not user_find:
142+
await message.answer(MESSAGES['ENGLISH']['AUTHORIZATION_PROBLEM'])
143+
else:
144+
await message.answer(MESSAGES[language]['TASK_MENU'], reply_markup=task_menu_keyboard())

telegram_bot_project/main.py

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,42 @@
22
from aiogram import Dispatcher, Bot, F
33
from aiogram.filters import Command
44
from aiogram.fsm.storage.memory import MemoryStorage
5-
from aiogram.types import CallbackQuery
5+
from aiogram.types import CallbackQuery, Message
6+
from aiogram.fsm.context import FSMContext
7+
from bot.callbacks import (
8+
start_callback_language,
9+
callback_idea_process,
10+
callback_task_deadline
11+
)
12+
from bot.commands import (
13+
start_command,
14+
help_command,
15+
menu_command,
16+
language_command,
17+
idea_command,
18+
ideas_command,
19+
delete_idea_command,
20+
update_idea_command,
21+
task_command,
22+
task_menu_command
23+
)
24+
from bot.handlers import (
25+
process_idea_save,
26+
process_idea_delete,
27+
process_idea_update,
28+
process_save_updated_idea_text,
29+
process_task_save,
30+
process_task_deadline
31+
)
632
from config import TOKEN
7-
from bot.commands import *
8-
from bot.handlers import *
9-
from bot.callbacks import start_callback_language, callback_idea_process, callback_task_deadline
10-
from messages import *
33+
from messages import (
34+
MENU_BUTTON,
35+
BUTTON_IDEA,
36+
ALL_IDEAS,
37+
DEL_IDEA_BUTTON,
38+
UPDATE_IDEA_BUTTON,
39+
BUTTON_ADD_TASK
40+
)
1141
from states import DialogStates
1242

1343
storage: MemoryStorage = MemoryStorage()
@@ -57,6 +87,10 @@ async def task(message: Message, state: FSMContext):
5787
async def add_task(message: Message, state: FSMContext):
5888
await task_command(message, state)
5989

90+
@dp.message(Command("/taskmenu"))
91+
async def task_menu(message: Message):
92+
await task_menu_command(message)
93+
6094
@dp.callback_query(F.data.in_({"lang_ua", "lang_en"}))
6195
async def callback_language(callback_query: CallbackQuery):
6296
await start_callback_language(callback_query)

telegram_bot_project/messages.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"TASK_DEADLINE_NO": "Гаразд, без крайнього терміну. Ваше завдання збережено.",
3535
"TASK_DEADLINE_INVALID": "Недійсний термін. Будь ласка, спробуйте ще раз.",
3636
"TASK_SAVED": "Задачу збережено.",
37+
"TASK_MENU": "Меню задач",
3738
"LANGUAGE_ASK": (
3839
"🌐 **Оберіть мову інтерфейсу:**\n"
3940
"Натисніть кнопку нижче, щоб продовжити:"
@@ -80,6 +81,7 @@
8081
"TASK_DEADLINE_NO": "Ok, no deadline. Your task saved.",
8182
"TASK_DEADLINE_INVALID": "Invalid deadline. Please try again.",
8283
"TASK_SAVED": "Task saved successfully.",
84+
"TASK_MENU": "Task menu",
8385
"LANGUAGE_ASK": (
8486
"🌐 **Please choose your interface language:**\n"
8587
"Tap a button below to continue:"

0 commit comments

Comments
 (0)