Skip to content
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
20 changes: 11 additions & 9 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 14 additions & 2 deletions handlers/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
}()
Expand Down