From b5470175c78450ddb55ebd78f7e47d404f20e3e3 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sat, 25 Mar 2023 14:46:11 -0400 Subject: [PATCH] allow setting context by hand --- fun.go | 2 ++ web.go | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/fun.go b/fun.go index b5b9148..d168ef1 100644 --- a/fun.go +++ b/fun.go @@ -425,6 +425,8 @@ func herdofemus(noise string) []Emu { var re_memes = regexp.MustCompile("meme: ?([^\n]+)") var re_avatar = regexp.MustCompile("avatar: ?([^\n]+)") var re_banner = regexp.MustCompile("banner: ?([^\n]+)") +var re_convoy = regexp.MustCompile("convoy: ?([^\n]+)") +var re_convalidate = regexp.MustCompile("^(https?|tag|data):") func memetize(honk *Honk) { repl := func(x string) string { diff --git a/web.go b/web.go index fefc55c..f6135a5 100644 --- a/web.go +++ b/web.go @@ -1612,7 +1612,18 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk { } } + var convoy string noise = strings.Replace(noise, "\r", "", -1) + if updatexid == "" && rid == "" { + noise = re_convoy.ReplaceAllStringFunc(noise, func(m string) string { + convoy = m[7:] + convoy = strings.TrimSpace(convoy) + if !re_convalidate.MatchString(convoy) { + convoy = "" + } + return "" + }) + } noise = quickrename(noise, userinfo.UserID) noise = hooterize(noise) honk.Noise = noise @@ -1620,7 +1631,6 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk { noise = honk.Noise translate(honk) - var convoy string if rid != "" { xonk := getxonk(userinfo.UserID, rid) if xonk == nil {