/send_all feature for administrators
This commit is contained in:
@@ -54,3 +54,16 @@ func (g *Getters) GetOrCreateChat(telegramUpdate *tgbotapi.Update) (dbmapping.Ch
|
||||
|
||||
return chatRaw, true
|
||||
}
|
||||
|
||||
// GetAllPrivateChats returns all private chats
|
||||
func (g *Getters) GetAllPrivateChats() ([]dbmapping.Chat, bool) {
|
||||
privateChats := []dbmapping.Chat{}
|
||||
|
||||
err := c.Db.Select(&privateChats, "SELECT * FROM chats WHERE chat_type='private'")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return privateChats, false
|
||||
}
|
||||
|
||||
return privateChats, true
|
||||
}
|
||||
|
@@ -15,8 +15,10 @@ type GettersInterface interface {
|
||||
Init()
|
||||
GetOrCreateChat(update *tgbotapi.Update) (dbmapping.Chat, bool)
|
||||
GetChatByID(chatID int) (dbmapping.Chat, bool)
|
||||
GetAllPrivateChats() ([]dbmapping.Chat, bool)
|
||||
GetOrCreatePlayer(telegramID int) (dbmapping.Player, bool)
|
||||
GetPlayerByID(playerID int) (dbmapping.Player, bool)
|
||||
PlayerBetterThan(playerRaw *dbmapping.Player, powerLevel string) bool
|
||||
GetProfile(playerID int) (dbmapping.Profile, bool)
|
||||
GetPokememes() ([]dbmapping.PokememeFull, bool)
|
||||
GetBestPokememes(playerID int) ([]dbmapping.PokememeFull, bool)
|
||||
|
@@ -50,3 +50,21 @@ func (g *Getters) GetOrCreatePlayer(telegramID int) (dbmapping.Player, bool) {
|
||||
|
||||
return playerRaw, true
|
||||
}
|
||||
|
||||
// PlayerBetterThan return true, if profile is more or equal powerful than
|
||||
// provided power level
|
||||
func (g *Getters) PlayerBetterThan(playerRaw *dbmapping.Player, powerLevel string) bool {
|
||||
var isBetter = false
|
||||
switch playerRaw.Status {
|
||||
case "owner":
|
||||
isBetter = true
|
||||
case "admin":
|
||||
if powerLevel != "owner" {
|
||||
isBetter = true
|
||||
}
|
||||
default:
|
||||
isBetter = false
|
||||
}
|
||||
|
||||
return isBetter
|
||||
}
|
||||
|
Reference in New Issue
Block a user