Feat: nullable roomid
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user