one more try

This commit is contained in:
skkiesel 2017-11-17 10:30:15 -05:00
parent 95d99fa94d
commit 7841da0f48
1 changed files with 5 additions and 3 deletions

View File

@ -230,7 +230,9 @@ func (s *Slack) SendMessageType(channel, message string, meMessage bool) (string
type MessageResponse struct { type MessageResponse struct {
OK bool `json:"ok"` OK bool `json:"ok"`
Timestamp string `json:"ts"` Timestamp string `json:"ts"`
BotID string `json:"message.bot_id"` Message struct {
BotID string `json:"bot_id"`
} `json:"message"`
} }
var mr MessageResponse var mr MessageResponse
@ -243,7 +245,7 @@ func (s *Slack) SendMessageType(channel, message string, meMessage bool) (string
return "", errors.New("failure response received") return "", errors.New("failure response received")
} }
s.myBotID = mr.BotID s.myBotID = mr.Message.BotID
return mr.Timestamp, err return mr.Timestamp, err
} }
@ -397,7 +399,7 @@ func (s *Slack) Serve() error {
} }
switch msg.Type { switch msg.Type {
case "message": case "message":
isItMe := s.myBotID != "" && msg.BotID != s.myBotID isItMe := msg.BotID != "" && msg.BotID == s.myBotID
if !isItMe && !msg.Hidden && msg.ThreadTs == "" { if !isItMe && !msg.Hidden && msg.ThreadTs == "" {
m := s.buildMessage(msg) m := s.buildMessage(msg)
if m.Time.Before(s.lastRecieved) { if m.Time.Before(s.lastRecieved) {