mirror of
https://github.com/caronc/apprise.git
synced 2024-12-04 22:11:25 +01:00
Updated Development_Contribution (markdown)
parent
60e91c57dc
commit
f297f70cc9
@ -42,8 +42,11 @@ It basically boils down to this:
|
||||
|
||||
# Apprise is nothing but a manager of individual plugins
|
||||
a = Apprise()
|
||||
|
||||
# Under the table, add just calls the NotifyMyService.parse_url() and passes
|
||||
# the result set into your new services __init__() function.
|
||||
a.add('myscheme://details/?more=details&are=optional')
|
||||
|
||||
|
||||
# There would be one new service added to our manager now:
|
||||
assert(len(a), 1)
|
||||
|
||||
@ -72,9 +75,43 @@ It basically boils down to this:
|
||||
# that handle some common things, but at the end of the day, it will call your `send()` function
|
||||
# you defined.
|
||||
```
|
||||
|
||||
- **Putting it together without the overhead of the Apprise manager**:
|
||||
```python
|
||||
from Apprise.plugins import NotifyMyService
|
||||
|
||||
# You can do this manually too if you want to test around the overhead
|
||||
# of the Apprise manager itself:
|
||||
results = NotifyMyService.parse_url('myscheme://details/?more=details&are=optional')
|
||||
|
||||
# A simple dictionary of all of our arguments ready to go:
|
||||
assert isinstance(results, dict)
|
||||
|
||||
# Now instantiate your object:
|
||||
obj = NotifyMyService(**results)
|
||||
|
||||
# If you build your NotifyMyService correctly, then you should be able
|
||||
# to build a copy of the object perfectly using it's url() call
|
||||
# Now instantiate your object:
|
||||
clone_results = NotifyMyService.parse_url(obj.url())
|
||||
|
||||
# A simple dictionary of all of our arguments ready to go:
|
||||
assert isinstance(clone_results, dict)
|
||||
|
||||
# if you did this properly, you'll have a second working instance
|
||||
# you can work with (this is a great test to make sure you coded
|
||||
# your new notification service perfect)
|
||||
clone = NotifyMyService(**clone_results)
|
||||
|
||||
# The best test of all to ensure you did everything well; both the
|
||||
# clone and original object you created should produce the same
|
||||
# url()
|
||||
assert clone.url() == obj.url()
|
||||
```
|
||||
|
||||
Any other functions you want to define can be done to you hearts content (if it helps with organization, structure, etc)
|
||||
Just avoid conflicting with any function written in `NotifyBase()` and `URLBase()`
|
||||
|
||||
If your service is really complex (and requires a lot of code), maybe it's easier to split your code into multiple files. This is how i handled the [NotifyFCM plugin i wrote](https://github.com/caronc/apprise/tree/master/apprise/plugins/NotifyFCM) which was based on Google's version.
|
||||
|
||||
You can have a look at the NotifyBase object and see all of the other entries you can define that Apprise can look after for you (such as restricting the message length, title length, handling TEXT -> Markdown, etc). You can also look at how other classes were built.
|
||||
You can have a look at the NotifyBase object and see all of the other entries you can define that Apprise can look after for you (such as restricting the message length, title length, handling TEXT -> Markdown, etc). You can also look at how other classes were built.
|
||||
|
Loading…
Reference in New Issue
Block a user