quick mention @alias
This commit is contained in:
parent
ea877a4f2f
commit
4f7f82d916
|
@ -2,6 +2,8 @@ changelog
|
|||
|
||||
-- next
|
||||
|
||||
+ Quick mention @alias.
|
||||
|
||||
+ Image descriptions.
|
||||
|
||||
++ Search. I hate it already.
|
||||
|
|
26
fun.go
26
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)
|
||||
|
|
4
honk.go
4
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 "
|
||||
|
|
Loading…
Reference in New Issue