poshbotio / PoshBot

Powershell-based bot framework
MIT License
536 stars 108 forks source link

Duplicate command execution in Slack #170

Closed RamblingCookieMonster closed 5 years ago

RamblingCookieMonster commented 5 years ago

Replying to a command message (!command, not the output from poshbot) in a thread causes PoshBot to reprocess the command.

Thanks to Adrian Andersson for tasking about this in Slack!

Expected Behavior

PoshBot does not reprocess commands

Current Behavior

Poshbot reprocesses commands if you reply to a command in a thread

Possible Solution

Look at the code (sorry, it's bedtime, but didn't want to forget to submit this)

Steps to Reproduce (for bugs)

Your Environment

RamblingCookieMonster commented 5 years ago

Hah. "bedtime"

Here's the original message:


DataTime : 2019-06-20 01:18:31Z
Class    : SlackBackend
Method   : ReceiveMessage
Severity : Normal
LogLevel : Debug
Message  : Received message
Data     : {"client_msg_id":"REDACTED","suppress_notification":false,"type":"message","text":"!u REDACTED","user":"REDACTED","team":"REDACTED","user_team":"REDACTED","source_team":"REDACTED","channel":"REDACTED","event_ts":"1560993511.393900","ts":"1560993511.393900"}

And the duplicate sent to the realtime API when I start or add to a thread looks like this:

DataTime : 2019-06-20 01:48:11Z
Class    : SlackBackend
Method   : ReceiveMessage
Severity : Normal
LogLevel : Debug
Message  : Received message
Data     : {"type":"message","subtype":"message_replied","hidden":true,"message":{"client_msg_id":"REDACTED","type":"message","text":"!u REDACTED","user":"REDACTED","ts":"1560993511.393900","thread_ts":"1560993511.393900","reply_count":1,"reply_users_count":1,"latest_reply":"1560995291.394400","reply
           _users":["REDACTED"],"replies":[{"user":"REDACTED","ts":"1560995291.394400"}]},"channel":"REDACTED","event_ts":"1560995291.394500","ts":"1560995291.394500"
           }

It looks like subtype message_replied, or hidden true may be worth investigating as properties to watch for (these seem to indicate messages to ignore), and the lack of suppress_notification false may be another flag.

Cheers!

devblackops commented 5 years ago

This should be fixed in 263970f71ec4bfae2b50439119bc833c982a9134 now.