A library that allows communication via the Signal IM service using the signald daemon.
Project description
pysignald
pysignald is a Python client for the excellent signald project, which in turn is a command-line client for the Signal messaging service.
pysignald allows you to programmatically send and receive messages to Signal.
Installation
You can install pysignald with pip:
$ pip install pysignald
Running
Just make sure you have signald installed. Here's an example of how to use pysignald:
from signald import Signal
s = Signal("+1234567890")
# If you haven't registered/verified signald, do that first:
s.register(voice=False)
s.verify("sms code")
s.send_message("+1098765432", "Hello there!")
for message in s.receive_messages():
print(message)
You can also use the chat decorator interface:
from signald import Signal
s = Signal("+1234567890")
@s.chat_handler("hello there", order=10) # This is case-insensitive.
def hello_there(message, match):
# Returning `False` as the first argument will cause matching to continue
# after this handler runs.
stop = False
reply = "Hello there!"
return stop, reply
# Matching is case-insensitive. The `order` argument signifies when
# the handler will try to match (default is 100), and functions get sorted
# by order of declaration secondly.
@s.chat_handler("hello", order=10)
def hello(message, match):
# This will match on "hello there" as well because of the "stop" return code in
# the function above. Both replies will be sent.
return "Hello!"
@s.chat_handler(re.compile("my name is (.*)")) # This is case-sensitive.
def name(message, match):
return "Hello %s." % match.group(1)
@s.chat_handler("")
def catch_all(message, match):
# This will only be sent if nothing else matches, because matching
# stops by default on the first function that matches.
return "I don't know what you said."
s.run_chat()
Various
pysignald also supports different socket paths:
s = Signal("+1234567890", socket_path="/var/some/other/socket.sock")
It supports TCP sockets too, if you run a proxy. For example, you can proxy signald's UNIX socket over TCP with socat:
$ socat -d -d TCP4-LISTEN:15432,fork UNIX-CONNECT:/var/run/signald/signald.sock
Then in pysignald:
s = Signal("+1234567890", socket_path=("your.serveri.ip", 15432))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pysignald-0.0.6.tar.gz
.
File metadata
- Download URL: pysignald-0.0.6.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.11 CPython/3.6.3 Linux/4.15.0-46-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4069d1001674d5a82042c092b796509c60e881b3a7ebae9190e35a10ca09845 |
|
MD5 | caf73c36f3f7775d9c2bb38240ac8d34 |
|
BLAKE2b-256 | dfed992d1983f153efc0ec96fb1914b02dd411d54aa866419ee9bfc5655bd94d |
File details
Details for the file pysignald-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: pysignald-0.0.6-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.11 CPython/3.6.3 Linux/4.15.0-46-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd8fbe8d7ea3a9f11370eb82e488fd43ea3622517a11d421b52ede70077ab911 |
|
MD5 | 81111e161b458b04f5fc503025e79e4f |
|
BLAKE2b-256 | c683be2458b6a91f0ad41c0738b21c7de132eb2f80a0d707a291c67d0419312e |