diff options
author | Vishnunarayan K I <31964688+vn-ki@users.noreply.github.com> | 2018-07-02 12:30:42 +0530 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-07-02 10:00:42 +0300 |
commit | 68db26bcace31297471641fe95f8882e301f5699 (patch) | |
tree | 77809244075380d292657b282b73d6cfa7a8eca0 /ui | |
parent | cf3f3e51d127f12b0d4b602cf446c1befde9cd79 (diff) |
Emojify message (#65)
Diffstat (limited to 'ui')
-rw-r--r-- | ui/commands.go | 11 | ||||
-rw-r--r-- | ui/view-main.go | 8 |
2 files changed, 14 insertions, 5 deletions
diff --git a/ui/commands.go b/ui/commands.go index 60ab1f1..2827666 100644 --- a/ui/commands.go +++ b/ui/commands.go @@ -19,10 +19,11 @@ package ui import ( "encoding/json" "fmt" - "github.com/lucasb-eyer/go-colorful" - "maunium.net/go/gomuks/debug" "strings" "unicode" + + "github.com/lucasb-eyer/go-colorful" + "maunium.net/go/gomuks/debug" ) func cmdMe(cmd *Command) { @@ -184,7 +185,7 @@ func cmdSetState(cmd *Command) { func cmdToggle(cmd *Command) { if len(cmd.Args) == 0 { - cmd.Reply("Usage: /toggle <rooms/users/baremessages/images/typingnotif>") + cmd.Reply("Usage: /toggle <rooms/users/baremessages/images/typingnotif/emojis>") return } switch cmd.Args[0] { @@ -198,8 +199,10 @@ func cmdToggle(cmd *Command) { cmd.Config.Preferences.DisableImages = !cmd.Config.Preferences.DisableImages case "typingnotif": cmd.Config.Preferences.DisableTypingNotifs = !cmd.Config.Preferences.DisableTypingNotifs + case "emojis": + cmd.Config.Preferences.DisableEmojis = !cmd.Config.Preferences.DisableEmojis default: - cmd.Reply("Usage: /toggle <rooms/users/baremessages/images/typingnotif>") + cmd.Reply("Usage: /toggle <rooms/users/baremessages/images/typingnotif/emojis>") return } // is there a reason this is called twice? diff --git a/ui/view-main.go b/ui/view-main.go index ef0f5d7..f38043a 100644 --- a/ui/view-main.go +++ b/ui/view-main.go @@ -21,7 +21,11 @@ import ( "time" "unicode" + "github.com/kyokomi/emoji" + "bufio" + "os" + "maunium.net/go/gomatrix" "maunium.net/go/gomuks/config" "maunium.net/go/gomuks/debug" @@ -33,7 +37,6 @@ import ( "maunium.net/go/gomuks/ui/widget" "maunium.net/go/tcell" "maunium.net/go/tview" - "os" ) type MainView struct { @@ -143,6 +146,9 @@ func (view *MainView) SendMessage(roomView *RoomView, text string) { func (view *MainView) sendTempMessage(roomView *RoomView, tempMessage ifc.Message, text string) { defer debug.Recover() debug.Print("Sending message", tempMessage.Type(), text) + if !roomView.config.Preferences.DisableEmojis { + text = emoji.Sprint(text) + } eventID, err := view.matrix.SendMarkdownMessage(roomView.Room.ID, tempMessage.Type(), text) if err != nil { tempMessage.SetState(ifc.MessageStateFailed) |