parent
8af708b00b
commit
fd5d8bdf8a
@ -35,7 +35,7 @@ Setup
|
|||||||
1. Get a slack token, click [here](https://api.slack.com/docs/oauth-test-tokens)
|
1. Get a slack token, click [here](https://api.slack.com/docs/oauth-test-tokens)
|
||||||
|
|
||||||
2. Create a `.slack-term` file, and place it in your home directory. Below is
|
2. Create a `.slack-term` file, and place it in your home directory. Below is
|
||||||
an an example file, you can leave out the `OPTIONAL` parts, you are only
|
an example file, you can leave out the `OPTIONAL` parts, you are only
|
||||||
required to specify a `slack_token`. Remember that your file should be
|
required to specify a `slack_token`. Remember that your file should be
|
||||||
a valid json file so don't forget to remove the comments.
|
a valid json file so don't forget to remove the comments.
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ Setup
|
|||||||
"sidebar_width": 1,
|
"sidebar_width": 1,
|
||||||
|
|
||||||
// OPTIONAL: turn on desktop notifications for all incoming messages, set
|
// OPTIONAL: turn on desktop notifications for all incoming messages, set
|
||||||
// the value as: "all", and for only mentions and im messages set the
|
// the value as: "all". For only mentions and im messages set the
|
||||||
// value as: "mention", default is turned off: ""
|
// value as: "mention", default is turned off: ""
|
||||||
"notify": "",
|
"notify": "",
|
||||||
|
|
||||||
@ -112,7 +112,8 @@ Setup
|
|||||||
"message": {
|
"message": {
|
||||||
"time": "",
|
"time": "",
|
||||||
"name": "",
|
"name": "",
|
||||||
"text": ""
|
"text": "",
|
||||||
|
"time_format": "15:04"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -139,7 +140,7 @@ $ slack-term -config [path-to-config-file]
|
|||||||
Default Key Mapping
|
Default Key Mapping
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
Below are the default key-mapping for `slack-term`, you can change them
|
Below are the default key-mappings for `slack-term`, you can change them
|
||||||
in your `slack-term.json` file.
|
in your `slack-term.json` file.
|
||||||
|
|
||||||
| mode | key | action |
|
| mode | key | action |
|
||||||
|
@ -19,6 +19,8 @@ type Message struct {
|
|||||||
StyleTime string
|
StyleTime string
|
||||||
StyleName string
|
StyleName string
|
||||||
StyleText string
|
StyleText string
|
||||||
|
|
||||||
|
FormatTime string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Chat is the definition of a Chat component
|
// Chat is the definition of a Chat component
|
||||||
@ -54,7 +56,11 @@ func (c *Chat) Buffer() termui.Buffer {
|
|||||||
if (msg.Time != time.Time{} && msg.Name != "") {
|
if (msg.Time != time.Time{} && msg.Name != "") {
|
||||||
// Time
|
// Time
|
||||||
cells = append(cells, termui.DefaultTxBuilder.Build(
|
cells = append(cells, termui.DefaultTxBuilder.Build(
|
||||||
fmt.Sprintf("[[%s]](%s) ", msg.Time.Format("15:04"), msg.StyleTime),
|
fmt.Sprintf(
|
||||||
|
"[[%s]](%s) ",
|
||||||
|
msg.Time.Format(msg.FormatTime),
|
||||||
|
msg.StyleTime,
|
||||||
|
),
|
||||||
termui.ColorDefault, termui.ColorDefault)...,
|
termui.ColorDefault, termui.ColorDefault)...,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -124,9 +124,10 @@ func getDefaultConfig() Config {
|
|||||||
Text: "",
|
Text: "",
|
||||||
},
|
},
|
||||||
Message: Message{
|
Message: Message{
|
||||||
Time: "",
|
Time: "",
|
||||||
Name: "",
|
TimeFormat: "15:04",
|
||||||
Text: "",
|
Name: "",
|
||||||
|
Text: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,10 @@ type View struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Message struct {
|
type Message struct {
|
||||||
Time string `json:"time"`
|
Time string `json:"time"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
|
TimeFormat string `json:"time_format"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Channel struct {
|
type Channel struct {
|
||||||
|
@ -453,12 +453,13 @@ func (s *SlackService) CreateMessage(message slack.Message) []components.Message
|
|||||||
|
|
||||||
// Format message
|
// Format message
|
||||||
msg := components.Message{
|
msg := components.Message{
|
||||||
Time: time.Unix(intTime, 0),
|
Time: time.Unix(intTime, 0),
|
||||||
Name: name,
|
Name: name,
|
||||||
Content: parseMessage(s, message.Text),
|
Content: parseMessage(s, message.Text),
|
||||||
StyleTime: s.Config.Theme.Message.Time,
|
StyleTime: s.Config.Theme.Message.Time,
|
||||||
StyleName: s.Config.Theme.Message.Name,
|
StyleName: s.Config.Theme.Message.Name,
|
||||||
StyleText: s.Config.Theme.Message.Text,
|
StyleText: s.Config.Theme.Message.Text,
|
||||||
|
FormatTime: s.Config.Theme.Message.TimeFormat,
|
||||||
}
|
}
|
||||||
|
|
||||||
msgs = append(msgs, msg)
|
msgs = append(msgs, msg)
|
||||||
@ -525,12 +526,13 @@ func (s *SlackService) CreateMessageFromMessageEvent(message *slack.MessageEvent
|
|||||||
|
|
||||||
// Format message
|
// Format message
|
||||||
msg := components.Message{
|
msg := components.Message{
|
||||||
Time: time.Unix(intTime, 0),
|
Time: time.Unix(intTime, 0),
|
||||||
Name: name,
|
Name: name,
|
||||||
Content: parseMessage(s, message.Text),
|
Content: parseMessage(s, message.Text),
|
||||||
StyleTime: s.Config.Theme.Message.Time,
|
StyleTime: s.Config.Theme.Message.Time,
|
||||||
StyleName: s.Config.Theme.Message.Name,
|
StyleName: s.Config.Theme.Message.Name,
|
||||||
StyleText: s.Config.Theme.Message.Text,
|
StyleText: s.Config.Theme.Message.Text,
|
||||||
|
FormatTime: s.Config.Theme.Message.TimeFormat,
|
||||||
}
|
}
|
||||||
|
|
||||||
msgs = append(msgs, msg)
|
msgs = append(msgs, msg)
|
||||||
@ -663,9 +665,10 @@ func (s *SlackService) CreateMessageFromAttachments(atts []slack.Attachment) []c
|
|||||||
att.Fields[i].Title,
|
att.Fields[i].Title,
|
||||||
att.Fields[i].Value,
|
att.Fields[i].Value,
|
||||||
),
|
),
|
||||||
StyleTime: s.Config.Theme.Message.Time,
|
StyleTime: s.Config.Theme.Message.Time,
|
||||||
StyleName: s.Config.Theme.Message.Name,
|
StyleName: s.Config.Theme.Message.Name,
|
||||||
StyleText: s.Config.Theme.Message.Text,
|
StyleText: s.Config.Theme.Message.Text,
|
||||||
|
FormatTime: s.Config.Theme.Message.TimeFormat,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -674,10 +677,11 @@ func (s *SlackService) CreateMessageFromAttachments(atts []slack.Attachment) []c
|
|||||||
msgs = append(
|
msgs = append(
|
||||||
msgs,
|
msgs,
|
||||||
components.Message{
|
components.Message{
|
||||||
Content: fmt.Sprintf("%s", att.Text),
|
Content: fmt.Sprintf("%s", att.Text),
|
||||||
StyleTime: s.Config.Theme.Message.Time,
|
StyleTime: s.Config.Theme.Message.Time,
|
||||||
StyleName: s.Config.Theme.Message.Name,
|
StyleName: s.Config.Theme.Message.Name,
|
||||||
StyleText: s.Config.Theme.Message.Text,
|
StyleText: s.Config.Theme.Message.Text,
|
||||||
|
FormatTime: s.Config.Theme.Message.TimeFormat,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -686,10 +690,11 @@ func (s *SlackService) CreateMessageFromAttachments(atts []slack.Attachment) []c
|
|||||||
msgs = append(
|
msgs = append(
|
||||||
msgs,
|
msgs,
|
||||||
components.Message{
|
components.Message{
|
||||||
Content: fmt.Sprintf("%s", att.Title),
|
Content: fmt.Sprintf("%s", att.Title),
|
||||||
StyleTime: s.Config.Theme.Message.Time,
|
StyleTime: s.Config.Theme.Message.Time,
|
||||||
StyleName: s.Config.Theme.Message.Name,
|
StyleName: s.Config.Theme.Message.Name,
|
||||||
StyleText: s.Config.Theme.Message.Text,
|
StyleText: s.Config.Theme.Message.Text,
|
||||||
|
FormatTime: s.Config.Theme.Message.TimeFormat,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user