feat: color-coded & formatted emotes (#428)
This commit is contained in:
parent
9d001a522e
commit
d9026d3dd8
4 changed files with 12 additions and 6 deletions
|
|
@ -111,6 +111,7 @@ graphics = true
|
|||
|
||||
[theme.messages_text]
|
||||
author_color = "aqua"
|
||||
emote_color = "green"
|
||||
reply_indicator = "╭ "
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ func (mt *MessagesText) createBody(w io.Writer, m discord.Message, isReply bool)
|
|||
if isReply {
|
||||
fmt.Fprint(w, "[::d]")
|
||||
}
|
||||
fmt.Fprint(w, markdown.Parse(tview.Escape(body)))
|
||||
fmt.Fprint(w, markdown.Parse(tview.Escape(body), cfg.Theme.MessagesText.EmoteColor))
|
||||
if isReply {
|
||||
fmt.Fprint(w, "[::-]")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ type (
|
|||
|
||||
MessagesTextTheme struct {
|
||||
AuthorColor string `toml:"author_color"`
|
||||
EmoteColor string `toml:"emote_color"`
|
||||
ReplyIndicator string `toml:"reply_indicator"`
|
||||
}
|
||||
)
|
||||
|
|
@ -41,6 +42,7 @@ func defaultTheme() Theme {
|
|||
},
|
||||
MessagesText: MessagesTextTheme{
|
||||
AuthorColor: "aqua",
|
||||
EmoteColor: "green",
|
||||
ReplyIndicator: string(tview.BoxDrawingsLightArcDownAndRight) + " ",
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,16 @@ var (
|
|||
underlineRe = regexp.MustCompile(`(?ms)__(.*?)__`)
|
||||
strikethroughRe = regexp.MustCompile(`(?ms)~~(.*?)~~`)
|
||||
codeblockRe = regexp.MustCompile("(?ms)`" + `([^` + "`" + `\n]+)` + "`")
|
||||
emoteRe = regexp.MustCompile(`<(:[a-zA-Z0-9]+:)[0-9]+>`)
|
||||
)
|
||||
|
||||
func Parse(input string) string {
|
||||
func Parse(input string, emoteColor string) string {
|
||||
input = boldRe.ReplaceAllString(input, "[::b]$1[::B]")
|
||||
input = italicRe.ReplaceAllString(input, "[::i]$1[::I]")
|
||||
input = underlineRe.ReplaceAllString(input, "[::u]$1[::U]")
|
||||
input = strikethroughRe.ReplaceAllString(input, "[::s]$1[::S]")
|
||||
input = codeblockRe.ReplaceAllString(input, "[::r]$1[::R]")
|
||||
input = emoteRe.ReplaceAllString(input, "[" + emoteColor + "]$1[-:-:-]")
|
||||
|
||||
return input
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue