Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 of 5 tasks
torgeirl opened this issue Jan 4, 2022 · 6 comments
Closed
1 of 5 tasks

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

torgeirl opened this issue Jan 4, 2022 · 6 comments

Comments

@torgeirl
Copy link
Contributor

torgeirl commented Jan 4, 2022

I am...

  • Reporting a bug
  • Suggesting a new feature
  • Requesting help with running my bot
  • Requesting help writing plugins
  • Here about something else

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
Copy link
Contributor

sijis commented Jan 6, 2022

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

@torgeirl
Copy link
Contributor Author

torgeirl commented Jan 6, 2022

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
Copy link
Contributor Author

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
Copy link
Contributor

nzlosh commented Nov 16, 2022

This sounds specific to the slack backend, which was patched to reply to threads here errbotio/err-backend-slackv3#76

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

@torgeirl
Copy link
Contributor Author

torgeirl commented Nov 16, 2022

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
Copy link
Contributor Author

torgeirl commented Jan 4, 2024

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

  • send_message() replies either in-channel or in-thread (where prompted) ✔️
  • send_card() always reply in-thread ❌
  • send_stream_request() always reply in-channel ❌

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

@torgeirl torgeirl closed this as completed Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants