allow setting context by hand

This commit is contained in:
Ted Unangst 2023-03-25 14:46:11 -04:00
parent 31a9ea6a08
commit b5470175c7
2 changed files with 13 additions and 1 deletions

2
fun.go
View File

@ -425,6 +425,8 @@ func herdofemus(noise string) []Emu {
var re_memes = regexp.MustCompile("meme: ?([^\n]+)") var re_memes = regexp.MustCompile("meme: ?([^\n]+)")
var re_avatar = regexp.MustCompile("avatar: ?([^\n]+)") var re_avatar = regexp.MustCompile("avatar: ?([^\n]+)")
var re_banner = regexp.MustCompile("banner: ?([^\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) { func memetize(honk *Honk) {
repl := func(x string) string { repl := func(x string) string {

12
web.go
View File

@ -1612,7 +1612,18 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk {
} }
} }
var convoy string
noise = strings.Replace(noise, "\r", "", -1) 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 = quickrename(noise, userinfo.UserID)
noise = hooterize(noise) noise = hooterize(noise)
honk.Noise = noise honk.Noise = noise
@ -1620,7 +1631,6 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk {
noise = honk.Noise noise = honk.Noise
translate(honk) translate(honk)
var convoy string
if rid != "" { if rid != "" {
xonk := getxonk(userinfo.UserID, rid) xonk := getxonk(userinfo.UserID, rid)
if xonk == nil { if xonk == nil {