コード例 #1
0
def notify_new_order(order: Order, total_sum: float, count_orders: int):
    notification_chats = notifyservice.get_all_notification_chats()
    notification_message = strings.from_order_notification(order, total_sum, count_orders)
    markup = InlineKeyboardMarkup()
    markup.add(InlineKeyboardButton(strings.get_string('notifications.accept'), callback_data='accept' + str(order.id)))
    markup.add(InlineKeyboardButton(strings.get_string('notifications.cancel'), callback_data='cancel' + str(order.id)))
    for chat in notification_chats:
        try:
            telegram_bot.send_message(chat.chat_id, notification_message, reply_markup=markup, parse_mode='HTML')
            if order.location:
                telegram_bot.send_location(chat.chat_id, order.location.latitude, order.location.longitude)
        except ApiException:
            pass
コード例 #2
0
def notify_new_order(order: Order, total_sum: float):
    notification_chats = notifyservice.get_all_notification_chats()
    notification_message = strings.from_order_notification(order, total_sum)
    for chat in notification_chats:
        try:
            telegram_bot.send_message(chat.chat_id,
                                      notification_message,
                                      parse_mode='HTML')
            if order.location:
                telegram_bot.send_location(chat.chat_id,
                                           order.location.latitude,
                                           order.location.longitude)
        except ApiException:
            pass