Skip to content

Commit

Permalink
Add option to show emojis by converting their string/aliases to unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
hloeung committed Oct 29, 2023
1 parent 753f26e commit e44577d
Show file tree
Hide file tree
Showing 9 changed files with 2,265 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/google/gops v0.3.27
github.com/grokify/html-strip-tags-go v0.0.1
github.com/hashicorp/golang-lru v0.6.0
github.com/kenshaw/emoji v0.3.3
github.com/matterbridge/logrus-prefixed-formatter v0.5.3-0.20200523233437-d971309a77ba
github.com/matterbridge/matterclient v0.0.0-20230909230346-007c5c33c54c
github.com/mattermost/mattermost-server/v6 v6.7.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,8 @@ github.com/kataras/neffos v0.0.14/go.mod h1:8lqADm8PnbeFfL7CLXh1WHw53dG27MC3pgi2
github.com/kataras/pio v0.0.2/go.mod h1:hAoW0t9UmXi4R5Oyq5Z4irTbaTsOemSrDGUtaTl7Dro=
github.com/kataras/sitemap v0.0.5/go.mod h1:KY2eugMKiPwsJgx7+U103YZehfvNGOXURubcGyk0Bz8=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kenshaw/emoji v0.3.3 h1:hnCZ1UMxgw81UBYqMgbO65s+PbzBT+DDAM7W3nGdpgI=
github.com/kenshaw/emoji v0.3.3/go.mod h1:UHZHpun22ziHK9+1SuVYWq+rdFzQJLy5xtNC3k6Qbyw=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
Expand Down
2 changes: 2 additions & 0 deletions matterircd.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ ShortenRepliesTo = 0
Unicode = false
# Disable showing reactions
HideReactions = false
# Convert emoji strings/aliases to their unicode equivalent
#ShowEmoji = false

#Only join direct/group messages when someone talks. This stops from cluttering your
#irc client with lots of windows.
Expand Down
16 changes: 16 additions & 0 deletions mm-go-irckit/userbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/42wim/matterircd/bridge/slack"
"github.com/alecthomas/chroma/v2/quick"
"github.com/davecgh/go-spew/spew"
"github.com/kenshaw/emoji"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/muesli/reflow/wordwrap"
"github.com/sorcix/irc"
Expand Down Expand Up @@ -169,6 +170,10 @@ func (u *User) handleDirectMessageEvent(event *bridge.DirectMessageEvent) {
text = markdown2irc(text)
}

if u.v.GetBool(u.br.Protocol()+".showemoji") && !codeBlockBackTick && !codeBlockTilde { //nolint:goconst
text = emoji.ReplaceAliases(text)
}

if showContext {
text = prefix + text + suffix
}
Expand Down Expand Up @@ -325,6 +330,10 @@ func (u *User) handleChannelMessageEvent(event *bridge.ChannelMessageEvent) {
text = markdown2irc(text)
}

if u.v.GetBool(u.br.Protocol()+".showemoji") && !codeBlockBackTick && !codeBlockTilde {
text = emoji.ReplaceAliases(text)
}

if showContext {
text = prefix + text + suffix
}
Expand Down Expand Up @@ -458,6 +467,13 @@ func (u *User) handleReactionEvent(event interface{}) {
return
}

if u.v.GetBool(u.br.Protocol() + ".showemoji") {
reactionEmoji := emoji.FromAlias(reaction)
if reactionEmoji != nil {
reaction = fmt.Sprintf("%s", reactionEmoji)
}
}

if channelType == "D" {
e := &bridge.DirectMessageEvent{
Text: "\x1d" + text + reaction + "\x1d" + message,
Expand Down
21 changes: 21 additions & 0 deletions vendor/github.com/kenshaw/emoji/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions vendor/github.com/kenshaw/emoji/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e44577d

Please sign in to comment.