caronc / apprise

Apprise - Push Notifications that work with just about every platform!
https://hub.docker.com/r/caronc/apprise
BSD 2-Clause "Simplified" License
10.94k stars 385 forks source link

Support Slack Replies by allowing use of thread_timestamp #1033

Closed AlexScotland closed 6 months ago

AlexScotland commented 6 months ago

Description:

This enhancement allows Slack notification plugin to accept timestamps of messages that it should reply too.

This allows Apprise to reply into multiple channel's messages, creating a chat thread for relevant notifications.

Syntax

Thread Timestamp (defined as {thread_ts} below can be added to defined elements using a colon : delimiter like so:

New Service Completion Status

Not Applicable

Checklist

Testing

Anyone can help test this source code as follows:

# Create a virtual environment to work in as follows:
python3 -m venv apprise

# Change into our new directory
cd apprise

# Activate our virtual environment
source bin/activate

# Install the branch
pip install git+https://github.com/caronc/apprise.git@<this.branch-name>

# Test out the changes with the following command:
apprise -t "Test Title" -b "Test Message" \
  slack://slack_bot_oauth/#channel1:timestamp1/channel2:timestamp2
AlexScotland commented 6 months ago

pushed changes for Walrus operator removal, as it was conflicting with the Docker build.

codecov-commenter commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (c47de7f) 99.27% compared to head (92bde91) 99.27%. Report is 4 commits behind head on master.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1033 +/- ## ========================================== - Coverage 99.27% 99.27% -0.01% ========================================== Files 136 135 -1 Lines 17669 17563 -106 Branches 3603 3585 -18 ========================================== - Hits 17541 17435 -106 Misses 119 119 Partials 9 9 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

caronc commented 6 months ago

That was fast! I'll review tomorrow 🚀🙂

caronc commented 6 months ago

I pushed a few changes to your code to handle some edge cases. Can you have a git pull in your branch and just double-check it's working okay for you?

Also, i'm curious if you could share/provide steps on how one can get the timestamp from Slack so that they can provide it into Apprise. Is it in the URL, or something they can copy and paste out of the message thread?

AlexScotland commented 6 months ago

I pushed a few changes to your code to handle some edge cases. Can you have a git pull in your branch and just double-check it's working okay for you?

Also, i'm curious if you could share/provide steps on how one can get the timestamp from Slack so that they can provide it into Apprise. Is it in the URL, or something they can copy and paste out of the message thread?

Just double checked, and seems the Regular expression is not matching on the CHANNEL_RE.search(channel) (line 568)

to answer your question, the slack api gives back a ts attribute on message send, which is the timestamp of the message. Some external storage tool could provide Apprise this data to send a thread.

It is also accessible on the slack frontend with some inspect element - slack uses the timestamp as the div's ID attribute

AlexScotland commented 6 months ago

Pushed a change to the regex that suits the naming schema a bit better - please verify if any adjustments are needed :)

caronc commented 6 months ago

Looks good! Great work! :rocket: