2017-11-19 22:16:11 +04:00
|
|
|
|
// i2_bot – Instinct PokememBro Bot
|
2018-04-04 21:33:30 +04:00
|
|
|
|
// Copyright (c) 2017-2018 Vladimir "fat0troll" Hodakov
|
2017-11-19 22:16:11 +04:00
|
|
|
|
|
|
|
|
|
package chatter
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strconv"
|
2018-04-04 21:33:30 +04:00
|
|
|
|
|
|
|
|
|
"github.com/go-telegram-bot-api/telegram-bot-api"
|
2017-11-19 22:16:11 +04:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// GroupsList lists all chats where bot exist
|
|
|
|
|
func (ct *Chatter) GroupsList(update *tgbotapi.Update) string {
|
2018-02-17 07:03:58 +04:00
|
|
|
|
groupChats := c.DataCache.GetAllGroupChats()
|
2017-11-19 22:16:11 +04:00
|
|
|
|
|
2017-12-23 17:03:26 +04:00
|
|
|
|
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)
|
2018-04-04 21:33:30 +04:00
|
|
|
|
gamesChatID, _ := strconv.ParseInt(c.Cfg.SpecialChats.GamesID, 10, 64)
|
2017-11-26 17:28:26 +04:00
|
|
|
|
|
2017-11-19 22:16:11 +04:00
|
|
|
|
message := "*Бот состоит в следующих групповых чатах:*\n"
|
|
|
|
|
|
|
|
|
|
for i := range groupChats {
|
|
|
|
|
message += "---\n"
|
2018-02-17 07:03:58 +04:00
|
|
|
|
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 {
|
2017-11-19 22:16:11 +04:00
|
|
|
|
message += "Статистика отряда:\n"
|
2018-02-17 07:03:58 +04:00
|
|
|
|
message += c.Statistics.SquadStatictics(squad.ID)
|
2017-11-19 22:16:11 +04:00
|
|
|
|
} else {
|
2018-02-17 07:03:58 +04:00
|
|
|
|
if groupChats[i].TelegramID == academyChatID {
|
2017-12-23 17:03:26 +04:00
|
|
|
|
message += "Является академией лиги\n"
|
|
|
|
|
}
|
2018-02-17 07:03:58 +04:00
|
|
|
|
if groupChats[i].TelegramID == bastionChatID {
|
2017-11-26 17:28:26 +04:00
|
|
|
|
message += "Является бастионом лиги\n"
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-17 07:03:58 +04:00
|
|
|
|
if groupChats[i].TelegramID == defaultChatID {
|
2017-11-26 17:28:26 +04:00
|
|
|
|
message += "Является чатом по умолчанию лиги\n"
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-17 07:03:58 +04:00
|
|
|
|
if groupChats[i].TelegramID == hqChatID {
|
2017-11-26 17:28:26 +04:00
|
|
|
|
message += "Является чатом совета лиги\n"
|
|
|
|
|
}
|
2018-04-04 21:33:30 +04:00
|
|
|
|
|
|
|
|
|
if groupChats[i].TelegramID == gamesChatID {
|
|
|
|
|
message += "Является игровым чатом\n"
|
|
|
|
|
}
|
2017-11-19 22:16:11 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
msg := tgbotapi.NewMessage(update.Message.Chat.ID, message)
|
|
|
|
|
msg.ParseMode = "Markdown"
|
|
|
|
|
|
|
|
|
|
c.Bot.Send(msg)
|
|
|
|
|
|
|
|
|
|
return "ok"
|
|
|
|
|
}
|