Archived
1

Squads: invite link on addition

Hope it works.
This commit is contained in:
Vladimir Hodakov 2018-02-17 16:37:06 +04:00
parent 5e4ce71ff8
commit ce553aea58

View File

@ -58,14 +58,11 @@ func (s *Squader) getPlayersForSquad(squadID int) ([]dbmapping.SquadPlayerFull,
} }
func (s *Squader) isUserAnyCommander(playerID int) bool { func (s *Squader) isUserAnyCommander(playerID int) bool {
squadPlayers := []dbmapping.SquadPlayer{} userRoles := c.DataCache.GetUserRolesInSquads(playerID)
err := c.Db.Select(&squadPlayers, c.Db.Rebind("SELECT * FROM squads_players WHERE player_id=? AND user_type='commander'"), playerID) for i := range userRoles {
if err != nil { if userRoles[i].UserRole == "commander" {
c.Log.Debug(err.Error()) return true
} }
if len(squadPlayers) > 0 {
return true
} }
return false return false
@ -191,5 +188,13 @@ func (s *Squader) AddUserToSquad(update *tgbotapi.Update, adderRaw *dbmapping.Pl
return s.squadUserAdditionFailure(update) return s.squadUserAdditionFailure(update)
} }
message := "Привет! Тебя добавили в отряд «" + squadRaw.Chat.Name + "»\n"
message += "Присоединиться к чату отряда тут: " + squadRaw.Squad.InviteLink
msg := tgbotapi.NewMessage(int64(playerRaw.TelegramID), message)
msg.ParseMode = "Markdown"
c.Bot.Send(msg)
return s.squadUserAdditionSuccess(update) return s.squadUserAdditionSuccess(update)
} }