Archived
1

Broadcast message to all Instinkt players

Closes #7
This commit is contained in:
2017-11-25 03:00:34 +04:00
parent b038d5b10d
commit ac0292ab6f
12 changed files with 81 additions and 50 deletions

View File

@@ -15,6 +15,7 @@ type ChatterInterface interface {
GetOrCreateChat(update *tgbotapi.Update) (dbmapping.Chat, bool)
GetChatByID(chatID int64) (dbmapping.Chat, bool)
GetAllPrivateChats() ([]dbmapping.Chat, bool)
GetLeaguePrivateChats() ([]dbmapping.Chat, bool)
GetAllGroupChats() ([]dbmapping.Chat, bool)
UpdateChatTitle(chatRaw *dbmapping.Chat, newTitle string) (*dbmapping.Chat, bool)

View File

@@ -115,6 +115,19 @@ func (ct *Chatter) GetAllPrivateChats() ([]dbmapping.Chat, bool) {
return privateChats, true
}
// GetLeaguePrivateChats returns all private chats which profiles are in our league
func (ct *Chatter) GetLeaguePrivateChats() ([]dbmapping.Chat, bool) {
privateChats := []dbmapping.Chat{}
err := c.Db.Select(&privateChats, "SELECT c.* FROM chats c, players p WHERE c.chat_type='private' AND p.telegram_id = c.telegram_id AND p.league_id = 1")
if err != nil {
c.Log.Error(err)
return privateChats, false
}
return privateChats, true
}
// GetAllGroupChats returns all group chats
func (ct *Chatter) GetAllGroupChats() ([]dbmapping.Chat, bool) {
groupChats := []dbmapping.Chat{}
@@ -126,4 +139,4 @@ func (ct *Chatter) GetAllGroupChats() ([]dbmapping.Chat, bool) {
}
return groupChats, true
}
}