mirror of https://github.com/velour/catbase.git
Merge pull request #197 from velour/reaction_log
slackApp: handle bot IDs
This commit is contained in:
commit
a9015e27ea
|
@ -420,7 +420,11 @@ func (s *SlackApp) buildMessage(m *slackevents.MessageEvent) msg.Message {
|
||||||
isAction := m.SubType == "me_message"
|
isAction := m.SubType == "me_message"
|
||||||
|
|
||||||
// We have to try a few layers to get a valid name for the user because Slack
|
// We have to try a few layers to get a valid name for the user because Slack
|
||||||
name := s.getUser(m.User, "unknown")
|
defaultName := "unknown"
|
||||||
|
if m.BotID != "" {
|
||||||
|
defaultName = m.Username
|
||||||
|
}
|
||||||
|
name := s.getUser(m.User, defaultName)
|
||||||
if m.Username != "" && name == "unknown" {
|
if m.Username != "" && name == "unknown" {
|
||||||
name = m.Username
|
name = m.Username
|
||||||
}
|
}
|
||||||
|
@ -517,6 +521,9 @@ func (s *SlackApp) Who(id string) []string {
|
||||||
|
|
||||||
ret := []string{}
|
ret := []string{}
|
||||||
for _, m := range members {
|
for _, m := range members {
|
||||||
|
if m == "" {
|
||||||
|
log.Error().Msg("empty member")
|
||||||
|
}
|
||||||
u := s.getUser(m, "unknown")
|
u := s.getUser(m, "unknown")
|
||||||
if u != "unknown" {
|
if u != "unknown" {
|
||||||
log.Error().
|
log.Error().
|
||||||
|
@ -610,7 +617,11 @@ func (s *SlackApp) reactionReceived(event *slack.ReactionAddedEvent) error {
|
||||||
case nil:
|
case nil:
|
||||||
case *slackevents.MessageEvent:
|
case *slackevents.MessageEvent:
|
||||||
if m.TimeStamp == event.Item.Timestamp {
|
if m.TimeStamp == event.Item.Timestamp {
|
||||||
u := s.getUser(m.User, "unknown")
|
defaultName := "unknown"
|
||||||
|
if m.BotID != "" {
|
||||||
|
defaultName = m.Username
|
||||||
|
}
|
||||||
|
u := s.getUser(m.User, defaultName)
|
||||||
body = fmt.Sprintf("%s: %s", u, m.Text)
|
body = fmt.Sprintf("%s: %s", u, m.Text)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue