adding python example

This commit is contained in:
Sune 2023-09-07 10:53:40 +02:00
parent fb53a11879
commit b3ff3b0e69

View file

@ -83,3 +83,24 @@ Send a message:
```sh
$ signal-cli --dbus-system send -m "hey test" <RECIPIENT>
```
## Receive messages from signal-cli daemon
The signal-cli daemon publishes new messages to dbus.
Here's an example using python:
```python
def msgRcv (timestamp, source, groupID, message, attachments):
print ("Message", message, "received in group", signal.getGroupName (groupID))
return
from pydbus import SystemBus
from gi.repository import GLib
bus = SystemBus()
loop = GLib.MainLoop()
signal = bus.get('org.asamk.Signal')
```
signal.onMessageReceived = msgRcv
loop.run()