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/squader/restricters.go

29 lines
803 B
Go
Raw Normal View History

// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package squader
import (
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"github.com/go-telegram-bot-api/telegram-bot-api"
)
// CleanFlood will clean flood from squads
func (s *Squader) CleanFlood(update *tgbotapi.Update, chatRaw *dbmapping.Chat) string {
switch s.IsChatASquadEnabled(chatRaw) {
case "main":
talker, err := c.DataCache.GetPlayerByTelegramID(update.Message.From.ID)
if err != nil {
c.Log.Error(err.Error())
s.deleteFloodMessage(update)
return "fail"
}
if (update.Message.From.UserName != "i2_bot") && (update.Message.From.UserName != "i2_bot_dev") && !s.isUserAnyCommander(talker.ID) {
s.deleteFloodMessage(update)
return "fail"
}
}
return "protection_passed"
}