Add more information with integrations

Fixes #179
This commit is contained in:
erroneousboat 2019-05-11 11:31:08 +02:00
parent 3ea9a9f1f8
commit 9d5e850495

View File

@ -403,16 +403,19 @@ func (s *SlackService) CreateMessage(message slack.Message, channelID string) co
// Get username from cache
name, ok := s.UserCache[message.User]
name, ok = s.UserCache[message.BotID]
// Name not in cache
if !ok {
if message.BotID != "" {
// Name not found, perhaps a bot, use Username
name, ok = s.UserCache[message.BotID]
if !ok {
// Not found in cache, add it
name = message.Username
s.UserCache[message.BotID] = message.Username
// Bot, not in cache get bot info
bot, err := s.Client.GetBotInfo(message.BotID)
if err != nil {
name = "unkown"
s.UserCache[message.BotID] = name
} else {
name = bot.Name
s.UserCache[message.BotID] = bot.Name
}
} else {
// Not a bot, not in cache, get user info
@ -587,6 +590,20 @@ func (s *SlackService) CreateMessageFromAttachments(atts []slack.Attachment) []c
)
}
if att.Pretext != "" {
msgs = append(
msgs,
components.Message{
Content: fmt.Sprintf("%s", att.Pretext),
StyleTime: s.Config.Theme.Message.Time,
StyleThread: s.Config.Theme.Message.Thread,
StyleName: s.Config.Theme.Message.Name,
StyleText: s.Config.Theme.Message.Text,
FormatTime: s.Config.Theme.Message.TimeFormat,
},
)
}
if att.Text != "" {
msgs = append(
msgs,