Enha: bot names avoid collision
This commit is contained in:
@ -294,7 +294,14 @@ func HandleAddBot(w http.ResponseWriter, r *http.Request) {
|
||||
abortWithError(w, err.Error())
|
||||
return
|
||||
}
|
||||
botname := fmt.Sprintf("bot_%d", len(llmapi.SignalChanMap)+1) // what if many rooms?
|
||||
var botname string
|
||||
maxID, err := repo.PlayerGetMaxID(r.Context())
|
||||
if err != nil {
|
||||
log.Warn("failed to get players max id")
|
||||
botname = fmt.Sprintf("bot_%d", len(llmapi.SignalChanMap)+1) // what if many rooms?
|
||||
} else {
|
||||
botname = fmt.Sprintf("bot_%d", maxID+1) // what if many rooms?
|
||||
}
|
||||
_, err = llmapi.NewBot(role, team, botname, fi.Room.ID, cfg, false)
|
||||
if err != nil {
|
||||
abortWithError(w, err.Error())
|
||||
|
Reference in New Issue
Block a user