Updated Procedures, event hooks and cronjobs as Python scripts (markdown)

Fabio Manganiello 2020-10-13 23:43:59 +02:00
parent 0789218b83
commit 1c645ec92a
1 changed files with 17 additions and 0 deletions

@ -51,4 +51,21 @@ from platypush.message.event.assistant import SpeechRecognizedEvent
@hook(SpeechRecognizedEvent)
def test_procedure(event, **content):
print('Recognized speech: {}'.format(event.args['phrase']))
```
As well as cronjobs:
```python
# ~/.config/platypush/scripts/test.py
from platypush.cron import cron
from platypush.utils import run
# Run it every minute
@cron('* * * * *')
def test_cron(event, **content):
import os
import datetime
with open(os.path.expanduser('~/test.txt'), 'a') as f:
f.write('The time is: {}\n'.format(datetime.datetime.now().isoformat()))
```