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

WxPusher Support Added #1135

Merged
merged 6 commits into from
Aug 29, 2024
Merged

WxPusher Support Added #1135

merged 6 commits into from
Aug 29, 2024

Conversation

caronc
Copy link
Owner

@caronc caronc commented May 28, 2024

Description:

Related issue (if applicable): #1133

Added WxPusher

Account Setup

  1. Create an account with WxPusher.
  2. Acquire your App Token from your profile
    appToken
    Note: The above image was taken from WxPusher's Help Page

Targets can be either a User (UID_DATA) or a Topic (<integer>). i.e:

  • wxpusher://apptoken/123/343/UID_ABCD would notify 2 topics (123, and 343) plus one user UID_DATA)

Syntax

Valid syntax is as follows:

  • wxpusher://{app_token}@{userid}
  • wxpusher://{app_token}@{userid1}/{userid2}/{useridN}
  • wxpusher://{app_token}@{token}
  • wxpusher://{app_token}@{token1}/{token2}/{tokenN}

You can also mix/match topic's and user ids:

  • wxpusher://{app_token}@{token1}/{userid1}/...

Parameter Breakdown

Variable Required Description
app_token Yes The App Token associated with your WxPusher account. It always starts with AT_

New Service Completion Status

  • apprise/plugins/wxpusher.py
  • KEYWORDS
    • add new service into this file (alphabetically).
  • README.md
    • add entry for new service to table (as a quick reference)
  • packaging/redhat/python-apprise.spec
    • add new service into the %global common_description

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • No lint errors (use flake8)
  • 100% test coverage

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@1133-wxpusher-support

# Test out the changes with the following command:
apprise -t "Test Title" -b "Test Message" \
 "wxpusher://apptoken/targets"

Here is an example of notifying a topic:

# Assuming our {app_key} is AT_12345
# Assuming our {topic} is 987
apprise -vv -t "Test Message Title" -b "Test Message Body" -n failure  \
   wxpusher://AT_12345/987

Here is an example of notifying a user:

# Assuming our {app_key} is AT_12345
# Assuming our {user} is UID_123
apprise -vv -t "Test Message Title" -b "Test Message Body" -n failure  \
   wxpusher://AT_12345/UID_123

We can notify a variety of users/topics by just specifying htem on the path:

# Assuming our {app_key} is AT_12345
# Assuming our {user} is UID_123 and UID_456
# Assuming our {topic} is 5555 and 4444
apprise -vv -t "Test Message Title" -b "Test Message Body" -n failure  \
   wxpusher://AT_12345/UID_123/5555/4444/UID_456

@codecov-commenter
Copy link

codecov-commenter commented May 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.35%. Comparing base (3cb270c) to head (9f50309).
Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #1135    +/-   ##
========================================
  Coverage   99.35%   99.35%            
========================================
  Files         146      147     +1     
  Lines       20186    20320   +134     
  Branches     3967     3979    +12     
========================================
+ Hits        20055    20189   +134     
  Misses        121      121            
  Partials       10       10            

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@caronc
Copy link
Owner Author

caronc commented Jul 2, 2024

I made another change to completely drop https and swap it for http. I'm running out of things to test right now as i'm still 100% confident the payload is correct.

This format now matches that of what is posted in their own plugin they have on github here

edit: ping @codejiangqihan 🙂

@caronc
Copy link
Owner Author

caronc commented Jul 17, 2024

@codejiangqihan, would love your feedback on this update (only because you've been so helpful in the past)

@codejiangqihan
Copy link

@codejiangqihan, would love your feedback on this update (only because you've been so helpful in the past)

After testing it, it seems that the return result is 200, but I still haven’t received the message on WeChat. I used the following two lines of commands to test. There was no error message, but I still did not receive any information on WeChat:

apprise -t "Test Title" -b "Test Message" wxpusher://AT_11111/UID_11111
apprise -vv -t "Test Message Title" -b "Test Message Body" -n failure wxpusher://AT_11111/UID_11111

@caronc
Copy link
Owner Author

caronc commented Aug 3, 2024

So wierd, I'm at a loss as to what to try next. I can't spot anything obvious. Hopefully someone else will see what's going on and resume or comment on this PR

@caronc
Copy link
Owner Author

caronc commented Aug 27, 2024

@codejiangqihan: I made some more changes after some further investigation. I think what is happening is i was looking at the wrong return code. so while Apprise was telling you the message was successfully sent, it really wasn't (this was misleading).

This new change will likely have you get the same result (that the notification won't be sent), however now it should report the real reason why (wrong ID, wrong value, etc. But it will help us identify/pinpoint better.

@jkoor
Copy link

jkoor commented Aug 29, 2024

A small error caused the run to fail.

# wxpusher.py
class WxPusherContentType:
    """
    Defines the different supported content types
    """
    TEXT = 0
    HTML = 1
    MARKDOWN = 2

The wxpusher documentation says this:

1 means text, 2 means html, 3 means markdown.

So I tried changing the code to the following:

# wxpusher.py
class WxPusherContentType:
    """
    Defines the different supported content types
    """
    TEXT = 1
    HTML = 2
    MARKDOWN = 3

Test result:

2024-08-29 10:55:00,746 - INFO - Sent WxPusher notification to 1 targets.

It ran successfully and I got the message.

@caronc
Copy link
Owner Author

caronc commented Aug 29, 2024

This is amazing detective work on your part! ❤️🙏 Thank you so much! I'll update this and also add in the message lookups:

  • 1000: Success. The request was processed successfully.
  • 1001: Token is empty. The token provided in the request is missing.
  • 1002: Token is invalid. The token provided in the request is incorrect or expired.
  • 1003: The message content is empty. The body of the message was not provided.
  • 1004: User or topic not found. The user or topic you're trying to send the message to does not exist
  • 1005: App or topic binding failed. The app or topic binding process failed.
  • 1006: Message sending failed. There was an error in sending the message.
  • 1007: Excessive message length. The message content exceeds the allowed length.
  • 1008: Sending frequency is too high. The API call frequency is too high and the server rejected the request.
  • 1009: Sending failed due to other reasons. There might be other issues that are not explicitly covered by the above codes
  • 1010: IP address is not in the whitelist. The IP address making the request is not whitelisted.

After that I'll merge the code! 🚀

@caronc caronc merged commit e3e34c4 into master Aug 29, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants