Closed torgeirl closed 8 months ago
Would you be able to provide a small plugin sample code on how you are using these?
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)
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:).
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?
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.
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) :heavy_check_mark: send_card()
always reply in-thread :x: send_stream_request()
always reply in-channel :x: I have updated err-backend-slackv3#93, and will continue this there.
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
andsend_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
andsend_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.