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

Message surface text attribute #39

Closed
kvalenti opened this issue Nov 17, 2021 · 2 comments
Closed

Message surface text attribute #39

kvalenti opened this issue Nov 17, 2021 · 2 comments
Assignees

Comments

@kvalenti
Copy link
Contributor

I just found your library and it looks like it could be very useful. Is it possible to (re)add the text attribute to the Message surface?

In my case, I'm looking to use this with slack_bolt using the following endpoint:

@app.message("hello")
def message_hello(message, say):
    # say() sends a message to the channel where the event was triggered

    message = Message(
        blocks=[
            Section(text="Hey there")
        ],
    ).build()
    say(message)

When I use this, I get a slack_bolt warning in my logs saying:

/Users/me/Library/Caches/pypoetry/virtualenvs/mack-0TpdqiFV-py3.9/lib/python3.9/site-packages/slack_sdk/web/
internal_utils.py:271: UserWarning: The `text` argument is missing in the request payload for a chat.postMessage 
call - It's a best practice to always provide a `text` argument when posting a message. The `text` argument is 
used in places where content cannot be rendered such as: system push notifications, assistive technology such as 
screen readers, etc.
  warnings.warn(message, UserWarning)

What I would like to be able to do is the following:

message = Message(
    blocks=[
        Section(text="Hey there")
    ],
    text="Hey there"
).build()

I know that I can work around it by manually adding text after creating the message, but I'd prefer to do it all in one operation.

I see that text was previously available ~2 years ago. Was there a reason that it was removed?

@imryche imryche self-assigned this Nov 24, 2021
@imryche
Copy link
Owner

imryche commented Nov 24, 2021

I decided that the text is not a part of the surface and removed it from Message, but I see how it can be beneficial. I will add it in the next release.

@imryche imryche closed this as completed Nov 24, 2021
@kvalenti
Copy link
Contributor Author

Thank you!

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

2 participants