@@ -250,6 +250,12 @@ protected function isBot()
250250 */
251251 public function buildServicePayload ($ message , $ matchingMessage , $ additionalParameters = [])
252252 {
253+ // If the matching message is in a thread, reply there
254+ $ thread_ts = $ matchingMessage ->getPayload ()->get ('thread_ts ' );
255+ if (! empty ($ thread_ts )) {
256+ $ additionalParameters ['thread_ts ' ] = $ thread_ts ;
257+ }
258+
253259 $ parameters = array_replace_recursive ([
254260 'channel ' => $ matchingMessage ->getRecipient () ?: $ matchingMessage ->getSender (),
255261 'as_user ' => true ,
@@ -269,7 +275,7 @@ public function buildServicePayload($message, $matchingMessage, $additionalParam
269275 ],
270276 ]);
271277
272- // else check if is a path
278+ // else check if is a path
273279 } elseif ($ attachment instanceof BotManFile && file_exists ($ attachment ->getUrl ())) {
274280 $ this ->file = (new File ())
275281 ->setTitle (basename ($ attachment ->getUrl ()))
@@ -301,16 +307,14 @@ public function sendPayload($payload)
301307 }
302308
303309 /**
304- * @param $message
310+ * @param $message
305311 * @param array $additionalParameters
306312 * @param IncomingMessage $matchingMessage
307313 * @return SlackRTMDriver
308314 */
309315 public function replyInThread ($ message , $ additionalParameters , $ matchingMessage )
310316 {
311- $ additionalParameters ['thread_ts ' ] = ! empty ($ matchingMessage ->getPayload ()->get ('thread_ts ' ))
312- ? $ matchingMessage ->getPayload ()->get ('thread_ts ' )
313- : $ matchingMessage ->getPayload ()->get ('ts ' );
317+ $ additionalParameters ['thread_ts ' ] = $ matchingMessage ->getPayload ()->get ('ts ' );
314318
315319 return $ this ->reply ($ message , $ matchingMessage , $ additionalParameters );
316320 }
@@ -406,7 +410,7 @@ public function getClient()
406410 /**
407411 * Low-level method to perform driver specific API requests.
408412 *
409- * @param $endpoint
413+ * @param $endpoint
410414 * @param array $parameters
411415 * @param IncomingMessage $matchingMessage
412416 * @return \React\Promise\PromiseInterface
0 commit comments