From 0653835b3fb0a55f41908116443d8ea144c65e7c Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Sat, 16 Nov 2019 21:44:17 -0500 Subject: [PATCH] updated README to explain attachments --- README.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/README.md b/README.md index 54714d61..0268f9f7 100644 --- a/README.md +++ b/README.md @@ -153,6 +153,23 @@ apprise -t 'my title' -b 'my notification body' \ --config=https://localhost/my/apprise/config ``` +### Attaching Files +Apprise also supports file attachments too! Specify as many attachments to a notification as you want. +```bash +# Send a funny image you found on the internet to a colleage: +apprise --title 'Agile Joke' \ + --body 'Did you see this one yet?' \ + --attach https://i.redd.it/my2t4d2fx0u31.jpg \ + 'mailto://myemail:mypass@gmail.com' + +# Easily send an update from a critical server to your dev team +apprise --title 'system crash' \ + --body 'I do not think Jim fixed the bug; see attached...' \ + --attach /var/log/myprogram.log \ + --attach /var/debug/core.2345 \ + --tag devteam +``` + ## Developers To send a notification from within your python application, just do the following: ```python @@ -228,4 +245,56 @@ apobj.notify( ) ``` +### Attaching Files +Attachments are very easy to send using the Apprise API: +```python +import apprise + +# Create an Apprise instance +apobj = apprise.Apprise() + +# Add at least one service you want to notify +apobj.add('mailto://myuser:mypass@hotmail.com') + +# Then send your attachment. +apobj.notify( + title='A great photo of our family', + body='The flash caused Jane to close her eyes! hah! :)', + attach='/local/path/to/my/DSC_003.jpg', +) + +# Send a web based attachment too! In the below example, we connect to a home +# security camera and send a live image to an email. By default remote web +# content is cached but for a security camera, we might want to call notify +# again later in our code so we want our last image retrieved to expire(in +# this case after 3 seconds). +apobj.notify( + title='Latest security image', + attach='http:/admin:password@hikvision-cam01/ISAPI/Streaming/channels/101/picture?cache=3' +) + +# To send more than one attachment, you just need another object: +from apprise import AppriseAttachment + +# Initialize our attachment object +aa = AppriseAttachment() + +# Now add all of the entries we're intrested in: +# ?name= allows us to rename the actual jpeg as found on the site +# to be another name when sent to our receipient(s) +aa.add('https://i.redd.it/my2t4d2fx0u31.jpg?name=FlyingToMars.jpg') + +# Now add another: +aa.add('/path/to/funny/joke.gif') + +# Send your multiple attachments with a single notify call: +apobj.notify( + title='Some good jokes.' + body='Hey guys, check out these!' + attach=aa, + tag=friends +) +``` + +## Want To Learn More? If you're interested in reading more about this and other methods on how to customize your own notifications, please check out the wiki at https://github.com/caronc/apprise/wiki/Development_API. You can also find more examples on how to use the command line tool at: https://github.com/caronc/apprise/wiki/CLI_Usage.