From b3ff3b0e69571d8ce88817ba87e82a99df63c5d6 Mon Sep 17 00:00:00 2001 From: Sune Date: Thu, 7 Sep 2023 10:53:40 +0200 Subject: [PATCH] adding python example --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 76fdadf..b29a473 100644 --- a/README.md +++ b/README.md @@ -83,3 +83,24 @@ Send a message: ```sh $ signal-cli --dbus-system send -m "hey test" ``` +## 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()