Add the order handler.
continuous-integration/drone/push Build is passing Details

main
KKlochko 2 years ago
parent b5c58984c5
commit 472fcf4f9d

@ -6,6 +6,7 @@ from src.handlers.city import city_list_handler, select_city_handler
from src.handlers.company import company_list_handler, select_company_handler
from src.handlers.category import category_list_handler
from src.handlers.cart import cart_list_handler, add_item_handler
from src.handlers.cart import order_handler
from src.handlers.user import register_handler
from src.fmt.city_formatter import CityFormatter
@ -62,3 +63,6 @@ def setup(bot: botlib.Bot, prefix: str):
count = int(count)
await add_item_handler(bot=bot, room_id=room.room_id, sender=message.sender, admin_id=bot.config.admin_id, item_name=name, count=count)
if match.command('order'):
await order_handler(bot=bot, room_id=room.room_id, sender=message.sender, admin_id=bot.config.admin_id)

@ -8,6 +8,7 @@ from src.api.v2.cart_api import CartAPI
from src.fetcher.v2.api_fetcher import ApiFetcher
from src.fmt.item_formatter import ItemFormatter
from src.fmt.cart_item_formatter import CartItemFormatter
from src.fmt.order_formatter import OrderFormatter
dots_bot_api_config = DotsBotApiConfig()
@ -22,6 +23,17 @@ async def cart_list_handler(room_id: str, bot: botlib.Bot, sender: str, admin_id
await bot.api.send_markdown_message(room_id=room_id, message=msg)
async def order_handler(room_id: str, bot: botlib.Bot, sender: str, admin_id: str):
session = aiohttp.ClientSession(json_serialize=ujson.dumps)
apiFetcher = ApiFetcher(dots_bot_api_config.get_base_url(), session)
formatter = OrderFormatter()
cartAPI = CartAPI(apiFetcher, formatter)
msg: str = await cartAPI.get_order_message(sender)
await bot.api.send_markdown_message(room_id=room_id, message=msg)
async def add_item_handler(room_id: str, bot: botlib.Bot, sender: str, admin_id: str, item_name: str, count: int):
session = aiohttp.ClientSession(json_serialize=ujson.dumps)

Loading…
Cancel
Save