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
17 changes: 16 additions & 1 deletion telegram_bot_project/bot/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,19 @@ def task_reply_keyboard() -> InlineKeyboardMarkup:
button_no: InlineKeyboardButton = InlineKeyboardButton(text=BUTTON_NO, callback_data="no_task")

inline_markup.inline_keyboard.append([button_yes, button_no])
return inline_markup
return inline_markup

def task_menu_keyboard() -> ReplyKeyboardMarkup:
task_menu_keyboard = ReplyKeyboardMarkup(keyboard=[], resize_keyboard=True, row_width=2)

button_menu = KeyboardButton(text=MENU_BUTTON)
button_add = KeyboardButton(text=BUTTON_ADD_TASK)
button_status = KeyboardButton(text=BUTTON_TOGGLE_STATUS)
button_delete = KeyboardButton(text=BUTTON_DELETE_TASK)
button_update = KeyboardButton(text=BUTTON_EDIT_TASK)

task_menu_keyboard.keyboard.append([button_add, button_status])
task_menu_keyboard.keyboard.append([button_delete, button_update])
task_menu_keyboard.keyboard.append([button_menu])

return task_menu_keyboard
4 changes: 2 additions & 2 deletions telegram_bot_project/bot/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from aiogram import types
from aiogram.fsm.context import FSMContext

from bot.buttons import menu_reply_keyboard, idea_reply_keyboard
from bot.buttons import menu_reply_keyboard, idea_reply_keyboard, task_menu_keyboard
from messages import MESSAGES
from service.idea import IdeaService
from service.task import TaskService
Expand Down Expand Up @@ -102,7 +102,7 @@ async def callback_task_deadline(callback_query: types.CallbackQuery, state: FSM
print(f"--[INFO] - User {user_id} ({user_name}) saved task: {saved_task}")

await TaskService.create_task(user_id, saved_task, False)
await callback_query.message.answer(MESSAGES[language]["TASK_DEADLINE_NO"], reply_markup=menu_reply_keyboard())
await callback_query.message.answer(MESSAGES[language]["TASK_DEADLINE_NO"], reply_markup=task_menu_keyboard())
await state.clear()
case _:
print(f"--[INFO] - User {user_id} ({user_name}) sent invalid callback: {callback_query.data}")
Expand Down
6 changes: 3 additions & 3 deletions telegram_bot_project/bot/handlers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from aiogram.fsm.context import FSMContext
from aiogram.types import Message

from bot.buttons import get_idea_conf_keyboard, menu_reply_keyboard, idea_reply_keyboard, task_reply_keyboard
from bot.buttons import get_idea_conf_keyboard, menu_reply_keyboard, idea_reply_keyboard, task_reply_keyboard, task_menu_keyboard
from messages import MESSAGES
from service.idea import IdeaService
from service.task import TaskService
Expand Down Expand Up @@ -185,8 +185,8 @@ async def process_task_deadline(message: Message, state: FSMContext):
print(f"--[INFO] User with id: {user_id} provided deadline: {deadline_dt}")

await TaskService.create_task(user_id, task, False, deadline_dt)
await message.answer(MESSAGES[language]['TASK_SAVED'], reply_markup=menu_reply_keyboard())
await message.answer(MESSAGES[language]['TASK_SAVED'], reply_markup=task_menu_keyboard())
await state.clear()

except ValueError:
await message.answer(MESSAGES[language]['TASK_DEADLINE_INVALID'])
await message.answer(MESSAGES[language]['TASK_DEADLINE_INVALID'])
4 changes: 4 additions & 0 deletions telegram_bot_project/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ async def update_idea(message: Message, state: FSMContext):
async def task(message: Message, state: FSMContext):
await task_command(message, state)

@dp.message(lambda m: m.text == BUTTON_ADD_TASK)
async def add_task(message: Message, state: FSMContext):
await task_command(message, state)

@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
6 changes: 6 additions & 0 deletions telegram_bot_project/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,9 @@
ALL_IDEAS: str = "📋 View All Ideas"
BUTTON_YES: str = "Yes"
BUTTON_NO: str = "No"
BUTTON_DELETE_TASK = "Delete Task"
BUTTON_EDIT_TASK = "Edit Task"
BUTTON_TOGGLE_STATUS = "Complete"
BUTTON_ALL_TASKS = "All tasks"