Wiper for Bastion
This commit is contained in:
@@ -594,3 +594,29 @@ func (s *Squader) ProtectBastion(update *tgbotapi.Update, newUser *tgbotapi.User
|
||||
|
||||
return "ok"
|
||||
}
|
||||
|
||||
// FilterBastion kicks already joined user if he changed league
|
||||
func (s *Squader) FilterBastion(update *tgbotapi.Update) string {
|
||||
user := update.Message.From
|
||||
chatRaw, ok := c.Chatter.GetOrCreateChat(update)
|
||||
if !ok {
|
||||
return "fail"
|
||||
}
|
||||
|
||||
playerRaw, playerOK := c.Users.GetOrCreatePlayer(update.Message.From.ID)
|
||||
if !playerOK {
|
||||
s.kickUserFromSquadChat(user, &chatRaw)
|
||||
return "fail"
|
||||
}
|
||||
_, profileOK := c.Users.GetProfile(playerRaw.ID)
|
||||
if !profileOK {
|
||||
s.kickUserFromSquadChat(user, &chatRaw)
|
||||
return "fail"
|
||||
}
|
||||
if playerRaw.LeagueID != 1 {
|
||||
s.kickUserFromSquadChat(user, &chatRaw)
|
||||
return "fail"
|
||||
}
|
||||
|
||||
return "ok"
|
||||
}
|
||||
|
@@ -28,4 +28,5 @@ type SquaderInterface interface {
|
||||
|
||||
ProcessMessage(update *tgbotapi.Update, chatRaw *dbmapping.Chat) string
|
||||
ProtectBastion(update *tgbotapi.Update, newUser *tgbotapi.User) string
|
||||
FilterBastion(update *tgbotapi.Update) string
|
||||
}
|
||||
|
Reference in New Issue
Block a user