PySynapse
Python Synapse (Matrix) server admin API module.
NOTE: This is my first time writing a Python module, its probably not perfect.
Requirements
- Python3 (written on 3.11)
- requests
- validators
Usage Examples
Create a connection from a config file
from configparser import ConfigParser
from os.path import abspath, dirname, join
try:
from pysynapse import Homeserver
except ImportError:
print("pysynapse not installed, install with:")
print("python3 -m pip install pysynapse")
exit(1)
config = ConfigParser()
config_file = join(dirname(abspath(__file__)), "config.ini")
if len(config.read(config_file)) != 1:
print("Failed to load config.ini")
exit(1)
homeserver = Homeserver(
config.get("homeserver", "access_token"),
config.get("homeserver", "host", fallback="localhost"),
config.getint("homeserver", "port", fallback=8008),
config.getboolean("homeserver", "secure", fallback=False),
config.getboolean("homeserver", "verify", fallback=None),
config.get("homeserver", "notices_user", fallback=None),
)
print(f"Connected to {homeserver.base_url} (Synapse {homeserver.server_version})")
Print summary of event reports
print(
"| ID | Reported | Claimant | Defendant | Room |"
)
print(
"|------|---------------------|--------------------------------|--------------------------------|--------------------------------|"
)
for event_report in homeserver.event_reports:
print(
"| {:4.4} | {:19.19} | {:30.30} | {:30.30} | {:30.30} |".format(
str(event_report.id),
str(event_report.received),
str(event_report.user),
str(event_report.sender),
str(event_report.room),
)
)
Purge forgotten rooms
for room in homeserver.rooms:
if room.forgotten:
print("Deleting forgotten room: {}".format(room))
room.delete(block_rejoining=False)
else:
print("Keeping room: {}".format(room))
for member in room.members:
print("- {}".format(member))
Metadata
Release files for pysynapse 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pysynapse-0.0.3.tar.gz | 54.3 kB | Without provenance | Details for pysynapse-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pysynapse-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for pysynapse-0.0.3-py3-none-any.whl |
Total release size: 97.5 kB
Release files / pysynapse-0.0.3.tar.gz
| Download URL | pysynapse-0.0.3.tar.gz |
|---|---|
| Size | 54.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9d7c7b59560812ce6d8111a73de7231ae39e873bc59348caa76f9d79165e3b38
|
|
BLAKE2b-256 checksum How to use checksums |
2defe5b486df3585f9ca74132040c99a0bb1a220c7b74b58b0ca9edd42d02e30
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / pysynapse-0.0.3-py3-none-any.whl
| Download URL | pysynapse-0.0.3-py3-none-any.whl |
|---|---|
| Size | 43.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1b201b2fac6669c5c60c8335e74bd542cd222b499265336f000b67896955e9f5
|
|
BLAKE2b-256 checksum How to use checksums |
c32876c46d87ca069a12da104c7203d11c1cb8b242357a584f11e4b3799d1d12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Security for pysynapse 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.