Feat: remove bot
This commit is contained in:
		| @@ -194,3 +194,18 @@ func HandleAddBot(w http.ResponseWriter, r *http.Request) { | ||||
| 	// go bot.StartBot() | ||||
| 	notify(models.NotifyRoomUpdatePrefix+fi.Room.ID, "") | ||||
| } | ||||
|  | ||||
| func HandleRemoveBot(w http.ResponseWriter, r *http.Request) { | ||||
| 	botName := r.URL.Query().Get("bot") | ||||
| 	log.Debug("got remove-bot request", "bot_name", botName) | ||||
| 	fi, err := getFullInfoByCtx(r.Context()) | ||||
| 	if err != nil { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	if err := llmapi.RemoveBot(botName, fi.Room); err != nil { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	notify(models.NotifyRoomUpdatePrefix+fi.Room.ID, "") | ||||
| } | ||||
|   | ||||
| @@ -8,6 +8,7 @@ import ( | ||||
| 	"html/template" | ||||
| 	"net/http" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| ) | ||||
|  | ||||
| func HandleCreateRoom(w http.ResponseWriter, r *http.Request) { | ||||
| @@ -248,12 +249,20 @@ func HandleGiveClue(w http.ResponseWriter, r *http.Request) { | ||||
| 		abortWithError(w, "your team already has a clue") | ||||
| 		return | ||||
| 	} | ||||
| 	// check if the clue is the same as one of the existing words | ||||
| 	for _, card := range fi.Room.Cards { | ||||
| 		if strings.EqualFold(card.Word, clue) { | ||||
| 			msg := fmt.Sprintf("cannot use existing word (%s) as a clue", clue) | ||||
| 			abortWithError(w, msg) | ||||
| 			return | ||||
| 		} | ||||
| 	} | ||||
| 	// === | ||||
| 	action := models.Action{ | ||||
| 		Actor:      fi.State.Username, | ||||
| 		ActorColor: string(fi.State.Team), | ||||
| 		WordColor:  string(fi.State.Team), | ||||
| 		Action:     "gave clue", | ||||
| 		Action:     models.ActionTypeClue, | ||||
| 		Word:       clue, | ||||
| 		Number:     num, | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder