Skip to content

Commit

Permalink
Add order status notifications
Browse files Browse the repository at this point in the history
A user will recieve a notification when their order has a status update.
  • Loading branch information
w1png committed Jan 5, 2023
1 parent ee25eb4 commit 4ea13e9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,12 @@ async def process_callback(callback_query: types.CallbackQuery):
elif call_data.startswith("changeOrderStatusProcessing"):
order = ordr.Order(call_data[27:])
order.set_status(0)

await bot.send_message(
text=f"Статус заказа #{order.get_order_id()} был изменен на \"{tt.processing}\"",
chat_id=order.get_user_id()
)

await bot.edit_message_text(
text=tt.get_order_template(order),
chat_id=chat_id,
Expand All @@ -1356,6 +1362,12 @@ async def process_callback(callback_query: types.CallbackQuery):
elif call_data.startswith("changeOrderStatusDelivery"):
order = ordr.Order(call_data[25:])
order.set_status(1)

await bot.send_message(
text=f"Статус заказа #{order.get_order_id()} был изменен на \"{tt.delivery}\"",
chat_id=order.get_user_id()
)

await bot.edit_message_text(
text=tt.get_order_template(order),
chat_id=chat_id,
Expand All @@ -1365,6 +1377,12 @@ async def process_callback(callback_query: types.CallbackQuery):
elif call_data.startswith("changeOrderStatusDone"):
order = ordr.Order(call_data[21:])
order.set_status(2)

await bot.send_message(
text=f"Статус заказа #{order.get_order_id()} был изменен на \"{tt.done}\"",
chat_id=order.get_user_id()
)

await bot.edit_message_text(
text=tt.get_order_template(order),
chat_id=chat_id,
Expand All @@ -1374,6 +1392,12 @@ async def process_callback(callback_query: types.CallbackQuery):
elif call_data.startswith("changeOrderStatusCancel"):
order = ordr.Order(call_data[23:])
order.set_status(-1)

await bot.send_message(
text=f"Заказ #{order.get_order_id()} был отменён.",
chat_id=order.get_user_id()
)

await bot.edit_message_text(
text=tt.get_order_template(order),
chat_id=chat_id,
Expand Down

0 comments on commit 4ea13e9

Please sign in to comment.