Feat: nullable roomid

This commit is contained in:
Grail Finder
2025-07-03 12:29:39 +03:00
parent 2a593739ae
commit d8338fe382
6 changed files with 25 additions and 14 deletions

View File

@ -300,11 +300,14 @@ func recoverBots() {
func recoverBot(bm models.Player) error {
// check if room still exists
if _, err := repo.RoomGetByID(context.Background(), bm.RoomID); err != nil {
return fmt.Errorf("no such room: %s; err: %w", bm.RoomID, err)
if bm.RoomID == nil {
return errors.New("bot has no room id")
}
if _, err := repo.RoomGetByID(context.Background(), *bm.RoomID); err != nil {
return fmt.Errorf("no such room: %s; err: %w", *bm.RoomID, err)
}
log.Debug("recovering bot", "bot", bm)
_, err := llmapi.NewBot(string(bm.Role), string(bm.Team), bm.Username, bm.RoomID, cfg, true)
_, err := llmapi.NewBot(string(bm.Role), string(bm.Team), bm.Username, *bm.RoomID, cfg, true)
if err != nil {
return err
}