mirror of
https://github.com/caronc/apprise.git
synced 2024-12-12 18:01:08 +01:00
Updated Development_API (markdown)
parent
a2fb188e89
commit
1d71787724
@ -10,9 +10,10 @@
|
|||||||
* [`details()`](#details-dynamic-view-into-available-notification-services-apprise-offers)
|
* [`details()`](#details-dynamic-view-into-available-notification-services-apprise-offers)
|
||||||
* [`async_notify()`](#async_notify--leveraging-await-to-send-notifications)
|
* [`async_notify()`](#async_notify--leveraging-await-to-send-notifications)
|
||||||
* [The Apprise Asset Object](#the-apprise-asset-object)
|
* [The Apprise Asset Object](#the-apprise-asset-object)
|
||||||
* [Pickle Support](#pickle-support)
|
|
||||||
* **Advanced**:
|
* **Advanced**:
|
||||||
* [The Apprise Notification Object](#the-apprise-notification-object)
|
* [The Apprise Notification Object](#the-apprise-notification-object)
|
||||||
|
* **Features**:
|
||||||
|
* [Pickle Support](#pickle-serialization-support)
|
||||||
<!--te-->
|
<!--te-->
|
||||||
|
|
||||||
# Development API
|
# Development API
|
||||||
@ -331,7 +332,7 @@ The **AppriseAsset()** object also performs some dynamic _templating_ of the spe
|
|||||||
| **{TYPE}** | | | | The type of notification being preformed. For example, if the user calling the notify() function specifies a _notify_type_ of _NotifyType.WARNING_, the string _warning_ would be placed as the _{TYPE}_ |
|
| **{TYPE}** | | | | The type of notification being preformed. For example, if the user calling the notify() function specifies a _notify_type_ of _NotifyType.WARNING_, the string _warning_ would be placed as the _{TYPE}_ |
|
||||||
| **{XY}** | | | | The image size to use which is in the format of **AAxBB** (as an example 72x72). Depending on the notification service being called; this value will vary. If you plan on defining your own images, you should facilitate the sizes: **32x32**, **72x72**, **128x128**, and **256x256**|
|
| **{XY}** | | | | The image size to use which is in the format of **AAxBB** (as an example 72x72). Depending on the notification service being called; this value will vary. If you plan on defining your own images, you should facilitate the sizes: **32x32**, **72x72**, **128x128**, and **256x256**|
|
||||||
|
|
||||||
Everytime the **notify()** function is called from the Apprise object, it uses the URL and/or local path and applies all of the templated masked values so that it can figure out what image to display. Here is an example how one might over-ride apprise to suit their own custom project needs:
|
Every time the **notify()** function is called from the Apprise object, it uses the URL and/or local path and applies all of the templated masked values so that it can figure out what image to display. Here is an example how one might over-ride apprise to suit their own custom project needs:
|
||||||
```python
|
```python
|
||||||
# Import this library
|
# Import this library
|
||||||
import apprise
|
import apprise
|
||||||
@ -389,3 +390,36 @@ obj.send(
|
|||||||
title=u"a title",
|
title=u"a title",
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Pickle/Serialization Support
|
||||||
|
You can Serialize your loaded notifications so they can be restored later on:
|
||||||
|
```python
|
||||||
|
import apprise
|
||||||
|
import pickle
|
||||||
|
|
||||||
|
# Instantiate our object
|
||||||
|
apobj = apprise.Apprise()
|
||||||
|
|
||||||
|
# Add our URLs
|
||||||
|
apobj.add("json://localhost")
|
||||||
|
apobj.add("xml://localhost")
|
||||||
|
apobj.add("form://localhost")
|
||||||
|
apobj.add("mailto://user:pass@localhost")
|
||||||
|
|
||||||
|
# Now serialize our object for any purpose
|
||||||
|
serialized = pickle.dumps(apobj)
|
||||||
|
|
||||||
|
# Consider even storing it to disk if you wanted:
|
||||||
|
with open("myfile.txt", "w") as file:
|
||||||
|
file.write(serialized)
|
||||||
|
```
|
||||||
|
|
||||||
|
With respect to the above example, we could later (or in another application) reload our object back as it was without having to re-add all the URLs again:
|
||||||
|
```python
|
||||||
|
# Restore our Apprise Object
|
||||||
|
apobj = pickle.loads(serialized)
|
||||||
|
|
||||||
|
# Perhaps we previously wrote it to disk, well we can load our data this way as well:
|
||||||
|
with open("myfile.txt", "r+") as file:
|
||||||
|
apobj = pickle.loads(file.read())
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user