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,15 +58,12 @@ func (s *Squader) getPlayersForSquad(squadID int) ([]dbmapping.SquadPlayerFull,
}
func (s *Squader) isUserAnyCommander(playerID int) bool {
squadPlayers := []dbmapping.SquadPlayer{}
err := c.Db.Select(&squadPlayers, c.Db.Rebind("SELECT * FROM squads_players WHERE player_id=? AND user_type='commander'"), playerID)
if err != nil {
c.Log.Debug(err.Error())
}
if len(squadPlayers) > 0 {
userRoles := c.DataCache.GetUserRolesInSquads(playerID)
for i := range userRoles {
if userRoles[i].UserRole == "commander" {
return true
}
}
return false
}
@ -191,5 +188,13 @@ func (s *Squader) AddUserToSquad(update *tgbotapi.Update, adderRaw *dbmapping.Pl
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)
}