aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2024-06-02 20:28:22 -0400
committerXe Iaso <me@xeiaso.net>2024-06-02 20:28:22 -0400
commitc6f795c732794c17ebf0addcaf829287d8b64c61 (patch)
tree39f4be08f9f7e471cc826782218f0048e4d1bddc /cmd
parentab9673316f45207598f1960887002f6135013bd9 (diff)
downloadx-c6f795c732794c17ebf0addcaf829287d8b64c61.tar.xz
x-c6f795c732794c17ebf0addcaf829287d8b64c61.zip
cmd/tourian: make mimi render HTML and have moods
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/tourian/main.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd/tourian/main.go b/cmd/tourian/main.go
index cd09241..debc8b0 100644
--- a/cmd/tourian/main.go
+++ b/cmd/tourian/main.go
@@ -8,6 +8,7 @@ import (
"flag"
"log"
"log/slog"
+ "math/rand"
"net/http"
"github.com/a-h/templ"
@@ -235,7 +236,10 @@ func (s *Server) WebsocketHandler(w http.ResponseWriter, r *http.Request) {
buf.Reset()
- if err := s.ExecTemplate(r.Context(), conn, chatBubble(avatarURL, mid, "Mimi", olresp.Message.Content)); err != nil {
+ moods := []string{"coffee", "happy", "think", "yawn"}
+ mood := moods[rand.Intn(len(moods))]
+
+ if err := s.ExecTemplate(r.Context(), conn, chatBubble(mimiAvatar(mood), mid, "Mimi", mdToHTML([]byte(olresp.Message.Content)))); err != nil {
slog.Error("failed to execute template", "err", err)
break
}