diff --git a/bot/handlers.go b/bot/handlers.go index 81e9154..234e85e 100644 --- a/bot/handlers.go +++ b/bot/handlers.go @@ -63,8 +63,12 @@ func (b *bot) SendAction(channel, message string) string { return b.conn.SendAction(channel, message) } -func (b *bot) ReplyToMessage(channel, message, identifier string) (string, bool) { - return b.conn.ReplyToMessage(channel, message, identifier) +func (b *bot) ReplyToMessageIdentifier(channel, message, identifier string) (string, bool) { + return b.conn.ReplyToMessageIdentifier(channel, message, identifier) +} + +func (b *bot) ReplyToMessage(channel, message string, replyTo msg.Message) (string, bool) { + return b.conn.ReplyToMessage(channel, message, replyTo) } func (b *bot) React(channel, reaction string, message msg.Message) bool { diff --git a/bot/interfaces.go b/bot/interfaces.go index d1e374a..2e76e93 100644 --- a/bot/interfaces.go +++ b/bot/interfaces.go @@ -17,7 +17,8 @@ type Bot interface { AddHandler(string, Handler) SendMessage(string, string) string SendAction(string, string) string - ReplyToMessage(channel, message, identifier string) (string, bool) + ReplyToMessageIdentifier(string, string, string) (string, bool) + ReplyToMessage(string, string, msg.Message) (string, bool) React(string, string, msg.Message) bool Edit(string, string, string) bool MsgReceived(msg.Message) @@ -35,7 +36,8 @@ type Connector interface { SendMessage(channel, message string) string SendAction(channel, message string) string - ReplyToMessage(channel, message, identifier string) (string, bool) + ReplyToMessageIdentifier(string, string, string) (string, bool) + ReplyToMessage(string, string, msg.Message) (string, bool) React(string, string, msg.Message) bool Edit(string, string, string) bool GetEmojiList() map[string]string diff --git a/bot/mock.go b/bot/mock.go index fdb5178..1286e3f 100644 --- a/bot/mock.go +++ b/bot/mock.go @@ -39,7 +39,8 @@ func (mb *MockBot) SendAction(ch string, msg string) string { mb.Actions = append(mb.Actions, msg) return fmt.Sprintf("a-%d", len(mb.Actions)-1) } -func (mb *MockBot) ReplyToMessage(channel, message, identifier string) (string, bool) { return "", false } +func (mb *MockBot) ReplyToMessageIdentifier(channel, message, identifier string) (string, bool) { return "", false } +func (mb *MockBot) ReplyToMessage(channel, message string, replyTo msg.Message) (string, bool) { return "", false } func (mb *MockBot) MsgReceived(msg msg.Message) {} func (mb *MockBot) EventReceived(msg msg.Message) {} func (mb *MockBot) Filter(msg msg.Message, s string) string { return "" } diff --git a/irc/irc.go b/irc/irc.go index 4d7b3bf..d348610 100644 --- a/irc/irc.go +++ b/irc/irc.go @@ -101,7 +101,11 @@ func (i *Irc) SendAction(channel, message string) string { return "NO_IRC_IDENTIFIERS" } -func (i *Irc) ReplyToMessage(channel, message, identifier string) (string, bool) { +func (i *Irc) ReplyToMessageIdentifier(channel, message, identifier string) (string, bool) { + return "NO_IRC_IDENTIFIERS", false +} + +func (i *Irc) ReplyToMessage(channel, message string, replyTo msg.Message) (string, bool) { return "NO_IRC_IDENTIFIERS", false } diff --git a/plugins/rpgORdie/rpgORdie.go b/plugins/rpgORdie/rpgORdie.go index 5c5b619..2733d7b 100644 --- a/plugins/rpgORdie/rpgORdie.go +++ b/plugins/rpgORdie/rpgORdie.go @@ -33,7 +33,7 @@ func (p *RPGPlugin) Message(message msg.Message) bool { } p.Bot.Edit(message.Channel, "HECK YES", ts) - p.Bot.ReplyToMessage(message.Channel, "How's this reply?", ts) + p.Bot.ReplyToMessageIdentifier(message.Channel, "How's this reply?", ts) } return false } diff --git a/slack/slack.go b/slack/slack.go index 29e5ef9..b00ed3e 100644 --- a/slack/slack.go +++ b/slack/slack.go @@ -247,7 +247,7 @@ func (s *Slack) SendAction(channel, message string) string { return identifier } -func (s *Slack) ReplyToMessage(channel, message, identifier string) (string, bool) { +func (s *Slack) ReplyToMessageIdentifier(channel, message, identifier string) (string, bool) { resp, err := http.PostForm("https://slack.com/api/chat.postMessage", url.Values{"token": {s.config.Slack.Token}, "channel": {channel}, @@ -288,6 +288,10 @@ func (s *Slack) ReplyToMessage(channel, message, identifier string) (string, boo return mr.Timestamp, err == nil } +func (s *Slack) ReplyToMessage(channel, message string, replyTo msg.Message) (string, bool) { + return s.ReplyToMessageIdentifier(channel, message, replyTo.AdditionalData["RAW_SLACK_TIMESTAMP"]) +} + func (s *Slack) React(channel, reaction string, message msg.Message) bool { log.Printf("Reacting in %s: %s", channel, reaction) resp, err := http.PostForm("https://slack.com/api/reactions.add",