Skip to content
Open
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
1 change: 1 addition & 0 deletions aiogram_calendar/dialog_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,5 @@ async def process_selection(self, query: CallbackQuery, data: DialogCalendarCall

if data.act == DialogCalAct.cancel:
await query.message.delete_reply_markup()
return False, 'cancel'
return return_data
1 change: 1 addition & 0 deletions aiogram_calendar/simple_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,6 @@ async def process_selection(self, query: CallbackQuery, data: SimpleCalendarCall
await query.answer(cache_time=60)
if data.act == SimpleCalAct.cancel:
await query.message.delete_reply_markup()
return False, 'cancel'
# at some point user clicks DAY button, returning date
return return_data
2 changes: 1 addition & 1 deletion aiogram_calendar/tests/test_dialog_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def test_start_calendar_params(year, expected1, expected2):
(DialogCalendarCallback(**{'act': 'SET-MONTH', 'year': '2022', 'month': '8', 'day': '1'}), (False, None)),
(DialogCalendarCallback(**{'act': 'SET-YEAR', 'year': '2021', 'month': '8', 'day': '0'}), (False, None)),
(DialogCalendarCallback(**{'act': 'START', 'year': '2021', 'month': '8', 'day': '0'}), (False, None)),
(DialogCalendarCallback(**{'act': 'CANCEL', 'year': '2021', 'month': '8', 'day': '0'}), (False, None)),
(DialogCalendarCallback(**{'act': 'CANCEL', 'year': '2021', 'month': '8', 'day': '0'}), (False, 'cancel')),
]


Expand Down
2 changes: 1 addition & 1 deletion aiogram_calendar/tests/test_simple_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ async def test_start_calendar_params(year, month, expected, expected_2):
(SimpleCalendarCallback(**{'act': 'PREV-MONTH', 'year': '2021', 'month': '8', 'day': '0'}), (False, None)),
(SimpleCalendarCallback(**{'act': 'NEXT-YEAR', 'year': '2022', 'month': '8', 'day': '1'}), (False, None)),
(SimpleCalendarCallback(**{'act': 'NEXT-MONTH', 'year': '2021', 'month': '8', 'day': '0'}), (False, None)),
(SimpleCalendarCallback(**{'act': 'CANCEL', 'year': '2021', 'month': '8', 'day': '0'}), (False, None)),
(SimpleCalendarCallback(**{'act': 'CANCEL', 'year': '2021', 'month': '8', 'day': '0'}), (False, 'cancel')),
(SimpleCalendarCallback(**{'act': 'TODAY', 'year': '2021', 'month': '8', 'day': '1'}), (False, None)),
]

Expand Down
6 changes: 6 additions & 0 deletions example_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ async def process_simple_calendar(callback_query: CallbackQuery, callback_data:
f'You selected {date.strftime("%d/%m/%Y")}',
reply_markup=start_kb
)
else:
if date == 'cancel':
await callback_query.message.answer("Cancelled")


@dp.message(F.text.lower() == 'dialog calendar')
Expand Down Expand Up @@ -127,6 +130,9 @@ async def process_dialog_calendar(callback_query: CallbackQuery, callback_data:
f'You selected {date.strftime("%d/%m/%Y")}',
reply_markup=start_kb
)
else:
if date == 'cancel':
await callback_query.message.answer("Cancelled")


async def main() -> None:
Expand Down