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 is only in-thread while send_stream_request is only in-channel #93

Open
torgeirl opened this issue Nov 16, 2022 · 1 comment

Comments

@torgeirl
Copy link

send_card (and send_stream_request) used to not reply in-thread (Errbot #1549), but within the last few months send_card is suddenly only reply in-thread when invoked.

As noted by @nzlosh this repo have recently made changes to its send_card implimentation:

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
Author

torgeirl commented Jan 4, 2024

Had another look at this after upgrading to Errbot 6.2.0, and when attempting to provide card.parent, as exemplified by @TheJokersThief in #76 ...

@botcmd
def hello(self, msg, args):
    """Say hello to someone"""
    return_msg = Card(
        to=msg.frm,
        title="Hello, world",
        parent=msg.parent if msg.parent else None,
    )

    self._bot.send_card(return_msg)

... I get an error stating that send_card() doesn't have a parent keyword argument:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/errbot/core.py", line 574, in _execute_and_send
    reply = method(msg, match) if match else method(msg, args)
                                             ^^^^^^^^^^^^^^^^^
  File "/app/plugins/tradingpost-errbot/tradingpost.py", line 40, in card
    self.send_card(title=card['name'],
TypeError: BotPlugin.send_card() got an unexpected keyword argument 'parent'
"
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/errbot/core.py", line 574, in _execute_and_send
    reply = method(msg, match) if match else method(msg, args)
                                             ^^^^^^^^^^^^^^^^^
  File "/app/plugins/tradingpost-errbot/tradingpost.py", line 40, in card
    self.send_card(title=card['name'],
TypeError: BotPlugin.send_card() got an unexpected keyword argument 'parent'

Trying to only use card.to (instead of card.in_reply_to as instructed in the docs) gives a similar error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/errbot/core.py", line 574, in _execute_and_send
    reply = method(msg, match) if match else method(msg, args)
                                             ^^^^^^^^^^^^^^^^^
  File "/app/plugins/tradingpost-errbot/tradingpost.py", line 38, in card
    self.send_card(title=card['name'],
  File "/usr/local/lib/python3.11/site-packages/errbot/botplugin.py", line 654, in send_card
    self._bot.send_card(
  File "/usr/local/lib/python3.11/site-packages/slackv3/slackv3.py", line 860, in send_card
    to_humanreadable, to_channel_id = self._prepare_message(card)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/slackv3/slackv3.py", line 687, in _prepare_message
    to_humanreadable = msg.to.username
                       ^^^^^^^^^^^^^^^
AttributeError: 'Message' object has no attribute 'username'

As a side note it seems strange that the default behavior of send_card() isn't similar to send_message(): only reply in-thread when prompted in a thread.

Also note that send_card() and send_stream_request() have the opposite behavior:

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

@torgeirl torgeirl changed the title send_card now only reply-in-threads send_card is only in-thread while send_stream_request is only in-channel 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

1 participant