diff --git a/docs/changelog.txt b/docs/changelog.txt index 1b86480..111b571 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog -- next ++ Quick mention @alias. + + Image descriptions. ++ Search. I hate it already. diff --git a/fun.go b/fun.go index 9086c1e..e770d6f 100644 --- a/fun.go +++ b/fun.go @@ -346,6 +346,32 @@ func obfusbreak(s string) string { return s } +var re_quickmention = regexp.MustCompile("(^| )@[[:alnum:]]+ ") + +func quickrename(s string, userid int64) string { + return re_quickmention.ReplaceAllStringFunc(s, func(m string) string { + prefix := "" + if m[0] == ' ' { + prefix = " " + m = m[1:] + } + prefix += "@" + m = m[1:] + m = m[:len(m)-1] + + row := stmtOneHonker.QueryRow(m, userid) + var xid string + err := row.Scan(&xid) + if err == nil { + _, name := handles(xid) + if name != "" { + m = name + } + } + return prefix + m + " " + }) +} + func mentionize(s string) string { s = re_mentions.ReplaceAllStringFunc(s, func(m string) string { where := gofish(m) diff --git a/honk.go b/honk.go index db701cc..3a3591b 100644 --- a/honk.go +++ b/honk.go @@ -1186,6 +1186,7 @@ func savehonk(w http.ResponseWriter, r *http.Request) { noise = noise[idx+1:] } } + noise = quickrename(noise, userinfo.UserID) noise = hooterize(noise) noise = strings.TrimSpace(noise) honk.Precis = strings.TrimSpace(honk.Precis) @@ -1801,7 +1802,7 @@ var stmtOneXonk, stmtPublicHonks, stmtUserHonks, stmtHonksByCombo, stmtHonksByCo var stmtHonksByOntology, stmtHonksForUser, stmtHonksForMe, stmtSaveDub, stmtHonksByXonker *sql.Stmt var stmtHonksBySearch, stmtHonksByHonker, stmtSaveHonk, stmtFileData, stmtWhatAbout *sql.Stmt var stmtOneBonk, stmtFindZonk, stmtFindXonk, stmtSaveDonk, stmtFindFile, stmtSaveFile *sql.Stmt -var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover *sql.Stmt +var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover, stmtOneHonker *sql.Stmt var stmtHasHonker, stmtThumbBiters, stmtZonkIt, stmtZonkDonks, stmtSaveZonker *sql.Stmt var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDeleteXonker *sql.Stmt var stmtSelectOnts, stmtSaveOnts, stmtUpdateFlags, stmtClearFlags *sql.Stmt @@ -1820,6 +1821,7 @@ func prepareStatements(db *sql.DB) { stmtUpdateFlavor = preparetodie(db, "update honkers set flavor = ? where userid = ? and xid = ? and flavor = ?") stmtUpdateCombos = preparetodie(db, "update honkers set combos = ? where honkerid = ? and userid = ?") stmtHasHonker = preparetodie(db, "select honkerid from honkers where xid = ? and userid = ?") + stmtOneHonker = preparetodie(db, "select xid from honkers where name = ? and userid = ?") stmtDubbers = preparetodie(db, "select honkerid, userid, name, xid, flavor from honkers where userid = ? and flavor = 'dub'") selecthonks := "select honks.honkid, honks.userid, username, what, honker, oonker, honks.xid, rid, dt, url, audience, noise, precis, convoy, whofore, flags, onts from honks join users on honks.userid = users.userid "