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/chatter/responders.go
2018-02-17 07:03:58 +04:00

55 lines
1.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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)
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 {
message += "Является бастионом лиги\n"
}
if groupChats[i].TelegramID == defaultChatID {
message += "Является чатом по умолчанию лиги\n"
}
if groupChats[i].TelegramID == hqChatID {
message += "Является чатом совета лиги\n"
}
}
}
msg := tgbotapi.NewMessage(update.Message.Chat.ID, message)
msg.ParseMode = "Markdown"
c.Bot.Send(msg)
return "ok"
}