default /get includes broadcast message if no personal message and MySecretWord

master v0.1.11
bel 2023-04-01 11:38:13 -06:00
parent 3c70e42819
commit e864f2a9f5
1 changed files with 11 additions and 5 deletions

View File

@ -77,12 +77,18 @@ func (v01 *V01) serveHTTP(w http.ResponseWriter, r *http.Request) {
}
func (v01 *V01) getUserFeedback(w http.ResponseWriter, r *http.Request) {
user, ok := v01.cfg.Users[r.URL.Query().Get("user")]
if !ok {
w.Write([]byte(v01.cfg.Broadcast.Message))
return
user := v01.cfg.Users[r.URL.Query().Get("user")]
msg := user.State.Message
if msg == "" {
msg = v01.cfg.Broadcast.Message
}
w.Write([]byte(user.State.Message))
if user.State.GM.Alias != "" {
msg = fmt.Sprintf("%s (Your secret word is '%s'. Make **someone else** say it!)", msg, user.State.GM.Alias)
}
w.Write([]byte(msg))
}
func (v01 *V01) servePutBroadcast(w http.ResponseWriter, r *http.Request) {