Feat: renotify bot btn and handler
This commit is contained in:
		| @@ -1,10 +1,18 @@ | |||||||
| {{ define "addbot" }} | {{ define "addbot" }} | ||||||
| <div> | <div> | ||||||
|  |   {{ if eq .Room.BlueTeam.Mime "" }} | ||||||
|   <button hx-get="/add-bot?team=blue&role=mime" hx-target="#addbot" class="bg-blue-400 text-black px-4 py-2 rounded">Add Bot Mime</button> |   <button hx-get="/add-bot?team=blue&role=mime" hx-target="#addbot" class="bg-blue-400 text-black px-4 py-2 rounded">Add Bot Mime</button> | ||||||
|  |   {{ end }} | ||||||
|  |   {{ if eq .Room.RedTeam.Mime "" }} | ||||||
|   <button hx-get="/add-bot?team=red&role=mime" hx-target="#addbot" class="bg-red-400 text-black px-4 py-2 rounded">Add Bot Mime</button> |   <button hx-get="/add-bot?team=red&role=mime" hx-target="#addbot" class="bg-red-400 text-black px-4 py-2 rounded">Add Bot Mime</button> | ||||||
|  |   {{ end }} | ||||||
| </div> | </div> | ||||||
| <div> | <div> | ||||||
|  |   {{ if not .Room.BlueTeam.Guessers }} | ||||||
|   <button hx-get="/add-bot?team=blue&role=guesser" hx-target="#addbot" class="bg-blue-300 text-black px-4 py-2 rounded">Add Bot Guesser</button> |   <button hx-get="/add-bot?team=blue&role=guesser" hx-target="#addbot" class="bg-blue-300 text-black px-4 py-2 rounded">Add Bot Guesser</button> | ||||||
|  |   {{ end }} | ||||||
|  |   {{ if not .Room.RedTeam.Guessers }} | ||||||
|   <button hx-get="/add-bot?team=red&role=guesser" hx-target="#addbot" class="bg-red-300 text-black px-4 py-2 rounded">Add Bot Guesser</button> |   <button hx-get="/add-bot?team=red&role=guesser" hx-target="#addbot" class="bg-red-300 text-black px-4 py-2 rounded">Add Bot Guesser</button> | ||||||
|  |   {{ end }} | ||||||
| </div> | </div> | ||||||
| {{end}} | {{end}} | ||||||
|   | |||||||
| @@ -56,6 +56,11 @@ | |||||||
|     {{template "mimeclue"}} |     {{template "mimeclue"}} | ||||||
|     {{end}} |     {{end}} | ||||||
|   </div> |   </div> | ||||||
|  |   <div> | ||||||
|  |     {{if and (eq .State.Username .Room.CreatorName) (.Room.IsRunning)}} | ||||||
|  |       <button hx-get="/renotify-bot" class="bg-amber-100 text-black px-4 py-2 rounded">Btn in case llm call failed</button> | ||||||
|  |     {{end}} | ||||||
|  |   </div> | ||||||
|   <div hx-get="/actionhistory" hx-trigger="sse:backlog_{{.Room.ID}}"> |   <div hx-get="/actionhistory" hx-trigger="sse:backlog_{{.Room.ID}}"> | ||||||
|   {{template "actionhistory" .Room.ActionHistory}} |   {{template "actionhistory" .Room.ActionHistory}} | ||||||
|   </div> |   </div> | ||||||
|   | |||||||
| @@ -260,3 +260,12 @@ func HandleGiveClue(w http.ResponseWriter, r *http.Request) { | |||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func HandleRenotifyBot(w http.ResponseWriter, r *http.Request) { | ||||||
|  | 	fi, err := getFullInfoByCtx(r.Context()) | ||||||
|  | 	if err != nil { | ||||||
|  | 		abortWithError(w, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	notifyBotIfNeeded(fi) | ||||||
|  | } | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								main.go
									
									
									
									
									
								
							| @@ -43,6 +43,8 @@ func ListenToRequests(port string) error { | |||||||
| 	mux.HandleFunc("GET /word/show-color", handlers.HandleShowColor) | 	mux.HandleFunc("GET /word/show-color", handlers.HandleShowColor) | ||||||
| 	mux.HandleFunc("POST /check/name", handlers.HandleNameCheck) | 	mux.HandleFunc("POST /check/name", handlers.HandleNameCheck) | ||||||
| 	mux.HandleFunc("GET /add-bot", handlers.HandleAddBot) | 	mux.HandleFunc("GET /add-bot", handlers.HandleAddBot) | ||||||
|  | 	// special | ||||||
|  | 	mux.HandleFunc("GET /renotify-bot", handlers.HandleRenotifyBot) | ||||||
| 	// sse | 	// sse | ||||||
| 	mux.Handle("GET /sub/sse", handlers.Notifier) | 	mux.Handle("GET /sub/sse", handlers.Notifier) | ||||||
| 	slog.Info("Listening", "addr", port) | 	slog.Info("Listening", "addr", port) | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								todos.md
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								todos.md
									
									
									
									
									
								
							| @@ -1,17 +1,17 @@ | |||||||
| ### feats | ### feats | ||||||
| - auto close room if nothing is going on there (hmm) for ~1h; | - auto close room if nothing is going on there (hmm) for ~1h; | ||||||
| - words database (file) load and form random 25 words; | - words database (file) load and form random 25 words; + | ||||||
| - different files for each supported lang; | - different files for each supported lang; | ||||||
| - mark cards (instead of opening them (right click?); | - mark cards (instead of opening them (right click?); | ||||||
| - invite link; | - invite link; + | ||||||
| - login with invite link; | - login with invite link; + | ||||||
| - add html icons of whos turn it is (like an image of big ? when mime is thinking); | - add html icons of whos turn it is (like an image of big ? when mime is thinking); | ||||||
| - there two places for bot to check if its its move: start-game; end-turn; | - there three places for bot to check if its its move: start-game; end-turn, after mime gave clue; | ||||||
| - remove bot button (if game is not running); | - remove bot button (if game is not running, or bot already added); | ||||||
| - show in backlog (and with that in prompt to llm) how many cards are left to open, also additional comment: if guess was right; | - show in backlog (and with that in prompt to llm) how many cards are left to open, also additional comment: if guess was right; | ||||||
| - if bot already added; remove add bot button; | - if bot already added; remove add bot button; | ||||||
| - hide clue input for mime when it's not their turn; | - hide clue input for mime when it's not their turn; | ||||||
| - needs resend to llm btn; | - needs resend to llm btn; + | ||||||
|  |  | ||||||
| #### sse points | #### sse points | ||||||
| - clue sse update; | - clue sse update; | ||||||
| @@ -30,3 +30,5 @@ | |||||||
| - sse hangs / fails connection which causes to wait for cards to open a few seconds (on local machine); | - sse hangs / fails connection which causes to wait for cards to open a few seconds (on local machine); | ||||||
| - after starting a new game (after old one) blue mime has no clue input; | - after starting a new game (after old one) blue mime has no clue input; | ||||||
| - gameover to backlog; | - gameover to backlog; | ||||||
|  | - remove verbs from word file; | ||||||
|  | - invite link gets cutoff; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder