Archived
1
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues or pull requests.
i2_bot/lib/orders/responders.go

46 lines
1.2 KiB
Go
Raw Normal View History

// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package orders
import (
"strconv"
2018-05-02 07:25:39 +04:00
"github.com/go-telegram-bot-api/telegram-bot-api"
)
// ListAllOrders returns to user all orders in database
func (o *Orders) ListAllOrders(update *tgbotapi.Update) string {
orders, ok := o.GetAllOrders()
if !ok {
return "fail"
}
message := "*Приказы на атаку*\n"
for i := range orders {
message += "\\[" + strconv.Itoa(orders[i].ID) + "] " + orders[i].TargetSquads + " → "
if orders[i].Target == "M" {
message += "🈳 МИСТИКА "
} else {
message += "🈵 ОТВАГА "
}
if orders[i].Scheduled {
message += "запланировано на "
message += orders[i].ScheduledAt.Time.Format("02.01.2006 15:04:05")
}
if orders[i].Status == "sent" {
message += "\nПросмотреть выполнение приказа: /show\\_order" + strconv.Itoa(orders[i].ID)
} else {
message += "\nОтправить приказ прямо сейчас: /send\\_order" + strconv.Itoa(orders[i].ID)
}
message += "\n"
}
msg := tgbotapi.NewMessage(update.Message.Chat.ID, message)
msg.ParseMode = "Markdown"
c.Bot.Send(msg)
return "ok"
}