errbotio / errbot

Errbot is a chatbot, a daemon that connects to your favorite chat service and bring your tools and some fun into the conversation.
http://errbot.io
GNU General Public License v3.0
3.12k stars 614 forks source link

send_card and send_stream_request don't reply in-thread #1549

Closed torgeirl closed 8 months ago

torgeirl commented 2 years ago

I am...

I am running...

Errbot version: 6.1.8 OS version: Debian (python:3.9-slim container) Python version: 3.9 Using a virtual environment: no (using Docker instead) Backend: Slack

Issue description

When invoked in a Slack thread, send_card and send_stream_request replies in thread's channel instead of in the thread itself.

Steps to reproduce

Write a bot command that replies using either send_card and send_stream_request, and invoke it in a Slack thread. The command reply will appear in the channel instead of in the thread where it were invoked.

sijis commented 2 years ago

Would you be able to provide a small plugin sample code on how you are using these?

torgeirl commented 2 years ago

Would you be able to provide a small plugin sample code on how you are using these?

Pseudo code below; working example code can be found here (the !card and !sutcliffe commands).

from errbot import BotPlugin, botcmd
from PIL import Image

@botcmd
def image(self, msg, args):
    image_data = get_image_by_name(args) # get image data from an external API
    body = '{} ({})'.format(image_data['name'], image_data['year_taken'])
    self.send_card(title=image_data['name'], body=body, image=image_data['image_uri'], in_reply_to=msg)

@botcmd
def meme(self, msg, args):
    image1_name, image2_name = args.split('/')
    # fetch image URIs using provided image names
    image1 = download_card_image(image1_uri)
    image2 = download_card_image(image2_uri)

    meme_template = Image.open('/assets/meme-canvas.png')
    image_positions = ((490, 25), (490, 435))
    meme_template.paste(image1, box=image_positions[0])
    meme_template.paste(image2, box=image_positions[1])
    meme_bytes = BytesIO()
    meme_template.save(meme_bytes, format='PNG')
    meme_bytes.seek(0)

    name = 'meme-{}.png'.format(datetime.now().strftime('%Y%m%d-%H%M'))
    self.send_stream_request(msg.frm, meme_bytes, name=name)
torgeirl commented 1 year ago

Update: not sure why and when (starting last few perhaps?), but send_card have switched from not replying in-thread to reply-in-thread all its responses. So when invoked from a Slack thread it will reply in it (:heavy_check_mark:), but all invocations are now answered as «Reply in thread» (:x:).

nzlosh commented 1 year ago

This sounds specific to the slack backend, which was patched to reply to threads here https://github.com/errbotio/err-backend-slackv3/pull/76

Do you mind opening an issue under the slackv3 repository please?

torgeirl commented 1 year ago

Do you mind opening an issue under the slackv3 repository please?

Done! I'll keep this one open for now, as this issue with send_stream_request remains unchanged.

torgeirl commented 8 months ago

After updating to Errbot 6.2.0, the provided Slackv3 has the following behavior:

I have updated err-backend-slackv3#93, and will continue this there.