Updated Development_Contribution (markdown)

master
Chris Caron 2024-05-13 21:24:26 -04:00
parent e54ffe4171
commit dd8f12ea43
1 changed files with 5 additions and 7 deletions

@ -35,9 +35,7 @@ Note: `bin/checkdone.sh` does a full scan of the product where `test.sh` is a qu
It basically boils down to this: It basically boils down to this:
```python ```python
# Whatever your class is called that inherits NotifyBase, make sure # plugins/foorbar.py might look like:
# to also make that the filename as well. Below is an example of what
# plugins/NotifyFooBar.py might look like:
from .NotifyBase import NotifyBase from .NotifyBase import NotifyBase
from ..AppriseLocale import gettext_lazy as _ from ..AppriseLocale import gettext_lazy as _
@ -105,14 +103,14 @@ class NotifyFooBar(NotifyBase):
``` ```
With respect to the above example: With respect to the above example:
- You just need to create a single notification python file as `/plugins/NotifyServiceName.py` - You just need to create a single notification python file as `/plugins/service_name.py`
- Make sure you call the class inside `NotifyServiceName` and inherit from `NotifyBase` - Make sure you call the class inside `NotifyServiceName` and inherit from `NotifyBase`
- Make sure your class object name is the same as the filename you create. This is very important! - Make sure your class object name is the same as the filename you create. This is very important!
- From there you just need to at a bare minimum define: - From there you just need to at a bare minimum define:
- **the class objects**: - **the class objects**:
- `service_name`: A string that acts as a default descriptive name associated with the Notification - `service_name`: A string that acts as a default descriptive name associated with the Notification
- `service_url`: A string that identifies the platform/services URL. This is used purely as meta data for those who seek it. But this field is required. - `service_url`: A string that identifies the platform/services URL. This is used purely as meta data for those who seek it. But this field is required.
- `protocol` and/or `secure_protocol`: A string (or can be a list of strings) identifying the scheme:// keyword that apprise uses to map to the Plugin Class it's associated with. For example, `slack` is mapped to the `NotifySlack` class found in the [`/plugins/NotifySlack.py` file](https://github.com/caronc/apprise/blob/master/apprise/plugins/NotifySlack.py). This must be defined so that people can leverage your plugin. You must choose a protocol name that isn't already taken. - `protocol` and/or `secure_protocol`: A string (or can be a list of strings) identifying the scheme:// keyword that apprise uses to map to the Plugin Class it's associated with. For example, `slack` is mapped to the `NotifySlack` class found in the [`/plugins/slack.py` file](https://github.com/caronc/apprise/blob/master/apprise/plugins/slack.py). This must be defined so that people can leverage your plugin. You must choose a protocol name that isn't already taken.
- `setup_url`: A string that identifies the URL a user can use to get information on how to use this Apprise Notification. At this time I'm just creating URLs that point back to my GitHub Wiki page. - `setup_url`: A string that identifies the URL a user can use to get information on how to use this Apprise Notification. At this time I'm just creating URLs that point back to my GitHub Wiki page.
- **the functions**: - **the functions**:
@ -200,8 +198,8 @@ With respect to the above example:
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. 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.
- Don't be afraid to just copy and paste another already created service and update it for your own usage. - Don't be afraid to just copy and paste another already created service and update it for your own usage.
- [plugins/NotifyJSON.py](https://github.com/caronc/apprise/blob/master/apprise/plugins/NotifyJSON.py) is a bit advanced; but shows the general idea of the structure. - [plugins/custom_json.py](https://github.com/caronc/apprise/blob/master/apprise/plugins/custom_json.py) is a bit advanced; but shows the general idea of the structure.
- [plugin/NotifyFCM](https://github.com/caronc/apprise/tree/master/apprise/plugins/NotifyFCM) is a much more complex design but illustrates how you can build your notification into smaller components. - [plugin/fcm](https://github.com/caronc/apprise/tree/master/apprise/plugins/fcm) is a much more complex design but illustrates how you can build your notification into smaller components.
- All in all.... just have a look at the [plugins directory](https://github.com/caronc/apprise/tree/master/apprise/plugins) and feel free to use this as a reference to help structure and solve your own notification service you might be building - All in all.... just have a look at the [plugins directory](https://github.com/caronc/apprise/tree/master/apprise/plugins) and feel free to use this as a reference to help structure and solve your own notification service you might be building
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.