question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Shouldn't "say()" automatically handle threads?

See original GitHub issue

Description

A user triggers activity within a thread, but the bot, using say() responds to the main conversation. At worst, say() should accept parameters that would allow me to chose whether response should be in a thread or the main conversation. At best, say() should automatically respond in the thread, while still providing parameters to control automatic respond-in-thread and also-post-to-channel.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I’ve read and understood the Contributing guidelines and have done my best effort to follow them.
  • I’ve read and agree to the Code of Conduct.
  • I’ve searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version: v2.1.1

node version: v12

OS version(s): Alpine Linux (docker container)

Steps to reproduce:

  1. Write a handler such as this:
// respond to ping message
app.message(directMention(), /PING$/i, ({ message, say }) => {
  console.debug(JSON.stringify(message));
  say('PONG');
});
  1. Have someone say this in a thread: @botname PING
  2. See bot respond outside of the thread PONG

Expected result:

If a user is @ mentioning the bot within a thread, I would expect the provided “say()” function to respond within that thread

Actual result:

Bot responded to thread in main conversation

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
stevengillcommented, Jul 31, 2020

Hey @iancward

I chatted with the team and it seems this is already possible with say. You need to provide the thread_ts argument when calling it.

// respond to ping message in thread
app.message(directMention(), /PING$/i, ({ message, say }) => {
  console.debug(JSON.stringify(message));
  say({ text: 'PONG', thread_ts: message.ts });
});

You can find out more about thread_ts at https://api.slack.com/methods/chat.postMessage#arg_thread_ts

Let me know if this works for you.

We aren’t going to change the default behaviour of say to respond to threads first. If you are interested in a more reusable solution for responding to threads, I can suggest a middleware based solution. Let me know.

1reaction
stevengillcommented, Jul 28, 2020

Hey @iancward

Thanks for reporting this! I think you are correct that say doesn’t currently support this. It is worth looking into adding this support I think. We will get back to you after some investigation and discussion with the other maintainers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Top 20 C++ multithreading mistakes and how to avoid them
Mistake # 1: Not using join() to wait for background threads before ... ( UI thread handling rendering) can cause the application to...
Read more >
Java Concurrency issues and Thread Synchronization
Whenever any thread modifies a shared variable, it automatically establishes a happens-before relationship with subsequent reads and writes of ...
Read more >
(Not) using std::thread | Andrzej's C++ blog
This post is about std::thread but not about threads or multi-threading. This is not an introduction to C++ threads.
Read more >
What happens if you call exit(0) while other threads are still ...
Technically SIGTERM handler shouldn't kill the threads. ... The thread class handles the stop() and that can happen in its destructor:
Read more >
Thread.Sleep is a sign of a poorly designed program.
Thread.Sleep has been used for many things it shouldn't be used for. ... I use thread.sleep() while flashing an embbedded controller.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found