Skip to content

adding matrix notifier#3529

Merged
paranoidi merged 3 commits intoFlexget:developfrom
antibios:develop
Dec 7, 2022
Merged

adding matrix notifier#3529
paranoidi merged 3 commits intoFlexget:developfrom
antibios:develop

Conversation

@antibios
Copy link
Copy Markdown
Contributor

Motivation for changes:

Matrix is a secure msging platform that allows for updates via a REST call

Detailed changes:

Addition of matrix.py to the notifiers folder.

Addressed issues:

  • Fixes # .
  • Feature request.

Implemented feature requests:

  • Matrix support

Config usage if relevant (new plugin or updated schema):

Sample config:
      entries:
        via:
          - matrix:
                  server: 'https://matrix.org'
                  token: 'SECRETKEY-dsarasfaFASZgo'
                  roomid: '!ufPOdHzBzMRGDSASgf:matrix.org'

Log and/or tests output (preferably both):

2022-08-23 14:32:49 VERBOSE  notify        sort-stuff     Successfully sent a notification to `matrix`

To Do:

  • Group multiple notifications to a single msg to reduce number of requests.

Copy link
Copy Markdown
Member

@gazpachoking gazpachoking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty simple and good. Maybe tweak the room id name in config?

All fields are required.

token: Is available in Element under Help/About.
roomId: Is available in Element under room settings.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalization is different here than in actual usage. Maybe we want to standardize it to room_id everywhere?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

config['server'],
"_matrix/client/r0/rooms",
config['roomid'],
"send/m.room.message?access_token=" + config['token'],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably should use

urllib.parse.urlencode(....)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rllib.urljoin() takes from 2 to 3 positional arguments but 4 were required.

try:
requests.post(room, json=notification)
except RequestException as e:
raise PluginWarning(e.args[0])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use exception chaining

raise PluginWarning(...) from e

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

logger = logger.bind(name=plugin_name)


def urljoin(*args):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just use standard urljoin ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

urllib.urljoin() takes from 2 to 3 positional arguments but 4 were required.

@paranoidi
Copy link
Copy Markdown
Member

Awesome, let's merge this in. Can you update the wiki too?

I created the page at

https://flexget.com/en/Plugins/Notifiers/matrix

In case I have completed it, just proof-read it :)

@paranoidi paranoidi merged commit 6c35eeb into Flexget:develop Dec 7, 2022
@antibios
Copy link
Copy Markdown
Contributor Author

antibios commented Dec 7, 2022

I've updated the wiki with instructions

@paranoidi
Copy link
Copy Markdown
Member

@antibios nice! I made some further formatting improvements to stay more consistent with other documentation

thanks for contributing

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