Fix: notify bot
This commit is contained in:
		| @@ -92,6 +92,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { | ||||
| 	case "white", string(oppositeColor): | ||||
| 		// end turn | ||||
| 		fi.Room.TeamTurn = oppositeColor | ||||
| 		fi.Room.MimeDone = false | ||||
| 	} | ||||
| 	// check if no cards left => game over | ||||
| 	if fi.Room.BlueCounter == 0 { | ||||
| @@ -110,6 +111,8 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	// get mime bot for opp team and notify it | ||||
| 	notifyBotIfNeeded(fi) | ||||
| 	notify(models.NotifyRoomUpdatePrefix+fi.Room.ID, "") | ||||
| 	if err := tmpl.ExecuteTemplate(w, "cardword", cardword); err != nil { | ||||
| 		log.Error("failed to execute cardword template", "error", err) | ||||
| @@ -136,16 +139,19 @@ func HandleAddBot(w http.ResponseWriter, r *http.Request) { | ||||
| 	// get team; // get role; make up a name | ||||
| 	team := r.URL.Query().Get("team") | ||||
| 	role := r.URL.Query().Get("role") | ||||
| 	log.Debug("got add-bot request", "team", team, "role", role) | ||||
| 	fi, err := getFullInfoByCtx(r.Context()) | ||||
| 	if err != nil { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	// TODO: what if bot exists already? | ||||
| 	// control number and names of bots | ||||
| 	bot, err := llmapi.NewBot(role, team, "bot1", fi.Room.ID, cfg) | ||||
| 	if err != nil { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	bot.StartBot() | ||||
| 	go bot.StartBot() | ||||
| 	notify(models.NotifyRoomUpdatePrefix+fi.Room.ID, "") | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder