Enha: bot guesser

This commit is contained in:
Grail Finder
2025-05-29 11:46:40 +03:00
parent 9ebce0a7d0
commit 7fab000d20
4 changed files with 64 additions and 28 deletions

View File

@ -74,9 +74,6 @@ func saveFullInfo(fi *models.FullInfo) error {
if err := saveState(fi.State.Username, fi.State); err != nil {
return err
}
// if fi.Room == nil { // can be null on exit
// return nil
// }
if err := saveRoom(fi.Room); err != nil {
return err
}
@ -85,14 +82,6 @@ func saveFullInfo(fi *models.FullInfo) error {
func notifyBotIfNeeded(fi *models.FullInfo) {
if botName := fi.Room.WhichBotToMove(); botName != "" {
// // get bot from memcache
// bot, err := loadBot(botName, fi.Room.ID)
// if err != nil {
// log.Error("failed to load bot", "bot_name", botName, "room_id", fi.Room.ID)
// // abortWithError(w, err.Error())
// // return
// }
// send signal to bot
llmapi.SignalChanMap[botName] <- true
}
log.Debug("no bot", "room_id", fi.Room.ID)

View File

@ -2,6 +2,7 @@ package handlers
import (
"errors"
"fmt"
"golias/llmapi"
"golias/models"
"html/template"
@ -147,7 +148,8 @@ func HandleAddBot(w http.ResponseWriter, r *http.Request) {
}
// TODO: what if bot exists already?
// control number and names of bots
bot, err := llmapi.NewBot(role, team, "bot1", fi.Room.ID, cfg)
botname := fmt.Sprintf("bot_%d", len(llmapi.SignalChanMap)+1) // what if many rooms?
bot, err := llmapi.NewBot(role, team, botname, fi.Room.ID, cfg)
if err != nil {
abortWithError(w, err.Error())
return