@@ -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)
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user