Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show emojis by converting their string/aliases to unicode #564

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 4 additions & 0 deletions matterircd.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ ShortenRepliesTo = 0
Unicode = false
# Disable showing reactions
HideReactions = false
# Disable converting Mattermost markdown of text emphasis to IRC text emphasis
#DisableIRCEmphasis
# Disable converting emoji strings/aliases to their unicode equivalent. Best with fonts-noto-color-emoji installed.
#DisableEmoji = true

#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()+".disableemoji") && !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()+".disableemoji") && !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() + ".disableemoji") {
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
Loading