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

55 lines
1.8 KiB
Go
Raw Normal View History

// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package chatter
import (
"github.com/go-telegram-bot-api/telegram-bot-api"
"strconv"
)
// GroupsList lists all chats where bot exist
func (ct *Chatter) GroupsList(update *tgbotapi.Update) string {
groupChats := c.DataCache.GetAllGroupChats()
academyChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.AcademyID, 10, 64)
2017-11-26 17:28:26 +04:00
bastionChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.BastionID, 10, 64)
defaultChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.DefaultID, 10, 64)
hqChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.HeadquartersID, 10, 64)
message := "*Бот состоит в следующих групповых чатах:*\n"
for i := range groupChats {
message += "---\n"
message += "\\[#" + strconv.Itoa(groupChats[i].ID) + "] _" + c.Users.FormatUsername(groupChats[i].Name) + "_\n"
message += "Telegram ID: " + strconv.FormatInt(groupChats[i].TelegramID, 10) + "\n"
squad, squadExistErr := c.DataCache.GetSquadByChatID(groupChats[i].ID)
if squadExistErr == nil {
message += "Статистика отряда:\n"
message += c.Statistics.SquadStatictics(squad.ID)
} else {
if groupChats[i].TelegramID == academyChatID {
message += "Является академией лиги\n"
}
if groupChats[i].TelegramID == bastionChatID {
2017-11-26 17:28:26 +04:00
message += "Является бастионом лиги\n"
}
if groupChats[i].TelegramID == defaultChatID {
2017-11-26 17:28:26 +04:00
message += "Является чатом по умолчанию лиги\n"
}
if groupChats[i].TelegramID == hqChatID {
2017-11-26 17:28:26 +04:00
message += "Является чатом совета лиги\n"
}
}
}
msg := tgbotapi.NewMessage(update.Message.Chat.ID, message)
msg.ParseMode = "Markdown"
c.Bot.Send(msg)
return "ok"
}