Skip to content

Send multiline messages to slack #1

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

Merged
merged 3 commits into from
Apr 7, 2024

Conversation

chrisBrookes93
Copy link

@chrisBrookes93 chrisBrookes93 commented Apr 6, 2024

Update pmxbot webhook endpoint to join newlines and send message to slack once, to allow posting multi-line strings to slack and reduce chances of API throttling (which we're seeing quite a lot these days). The previous code had a comment that said "We must send line-by-line, so split multiline messages" which has been there since the beginning (I checked the git history). However according to the slack docs (https://api.slack.com/reference/surfaces/formatting#line-breaks), newline characters in messages are supported. I'm thinking this was an edge case/limitation of the slack API years ago. If there was specific reasoning why we are splitting lines then please share :)

I've tested this and verified it as working...

Before:
image

After:
image

Test script used:

import requests
message = "My Shopping List:\n- Cheese\n- Butter\n- Milk"
url = "http://localhost:8080/chris.brookes"
resp = requests.post(url, data=message)

Please inform me if there are other edge cases in the API that I haven't considered!

Chris Brookes added 2 commits April 6, 2024 20:10
…low multi-line strings and reduce chances of throttling
@chrisBrookes93
Copy link
Author

Hey @jaraco, please take a look at this when you have capacity. Thanks!

@jaraco
Copy link
Owner

jaraco commented Apr 7, 2024

I'm on mobile now. I'll add a news entry and merge+release later (likely today).

@jaraco
Copy link
Owner

jaraco commented Apr 7, 2024

It's quite possible (likely) this limitation has existed since before Slack, when IRC was the main server, or when pmxbot relied on Slack's IRC gateway for communication. It's possible that adding this change will now break on IRC servers, but I think that's okay. If it does in fact break, and there's an IRC user out there who cares, they'll report it and we'll fix the issue in pmxbot (by adding multiline handling in the pmxbot.irc implementation).

@jaraco jaraco merged commit b1db383 into jaraco:main Apr 7, 2024
10 of 12 checks passed
@adriandiazgar
Copy link

Thanks @jaraco

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

Successfully merging this pull request may close these issues.

3 participants