diff --git a/README.md b/README.md index b857d11..a2547e0 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,10 @@ Setup // value as: "mention", default is turned off: "" "notify": "", + // OPTIONAL: display sender and message content in notifications, set + // the value as: false, default is to hide message content: true + "notify_private": true, + // OPTIONAL: define custom key mappings, defaults are: "key_map": { "command": { diff --git a/config/config.go b/config/config.go index abde6e4..5e60540 100644 --- a/config/config.go +++ b/config/config.go @@ -16,12 +16,13 @@ const ( // Config is the definition of a Config struct type Config struct { - SlackToken string `json:"slack_token"` - Notify string `json:"notify"` - SidebarWidth int `json:"sidebar_width"` - MainWidth int `json:"-"` - KeyMap map[string]keyMapping `json:"key_map"` - Theme Theme `json:"theme"` + SlackToken string `json:"slack_token"` + Notify string `json:"notify"` + NotifyPrivate bool `json:"notify_private"` + SidebarWidth int `json:"sidebar_width"` + MainWidth int `json:"-"` + KeyMap map[string]keyMapping `json:"key_map"` + Theme Theme `json:"theme"` } type keyMapping map[string]string @@ -66,9 +67,10 @@ func NewConfig(filepath string) (*Config, error) { func getDefaultConfig() Config { return Config{ - SidebarWidth: 1, - MainWidth: 11, - Notify: "", + SidebarWidth: 1, + MainWidth: 11, + Notify: "", + NotifyPrivate: true, KeyMap: map[string]keyMapping{ "command": { "i": "mode-insert", diff --git a/handlers/event.go b/handlers/event.go index 4d5473f..ac2e857 100644 --- a/handlers/event.go +++ b/handlers/event.go @@ -501,10 +501,22 @@ func createNotifyMessage(ctx *context.AppContext, ev *slack.MessageEvent) { notifyTimer = time.NewTimer(time.Second * 2) <-notifyTimer.C + var title string + var msg string + + if ctx.Config.NotifyPrivate { + title = "slack-term" + msg = ctx.Service.CreateNotifyMessage(ev.Channel) + } else { + title = ctx.Service.GetChannelName(ev.Channel) + msg = ev.Text + } + // Only actually notify when time expires ctx.Notify.Push( - "slack-term", - ctx.Service.CreateNotifyMessage(ev.Channel), "", + title, + msg, + "", notificator.UR_NORMAL, ) }()