matrix-python 1.0.0b0__tar.gz → 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- matrix_python-1.0.1/.github/ISSUE_TEMPLATE/bug_report.md +28 -0
- matrix_python-1.0.1/.github/ISSUE_TEMPLATE/feature--good-first.md +29 -0
- matrix_python-1.0.1/.github/ISSUE_TEMPLATE/feature_request.md +21 -0
- matrix_python-1.0.1/.github/dependabot.yml +6 -0
- matrix_python-1.0.1/.github/pull_request_template.md +14 -0
- matrix_python-1.0.1/.github/workflows/CODEOWNERS +1 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/.github/workflows/codeql.yml +1 -1
- matrix_python-1.0.1/.github/workflows/docs.yml +38 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/.github/workflows/publish.yml +2 -2
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/.github/workflows/scorecard.yml +1 -1
- matrix_python-1.0.1/.github/workflows/tests.yml +44 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/.gitignore +2 -1
- matrix_python-1.0.1/.pre-commit-config.yaml +44 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/CONTRIBUTING.md +24 -6
- matrix_python-1.0.1/LICENSE +21 -0
- matrix_python-1.0.1/PKG-INFO +153 -0
- matrix_python-1.0.1/README.md +100 -0
- matrix_python-1.0.1/docs/docs/examples/checks.md +15 -0
- matrix_python-1.0.1/docs/docs/examples/cooldown.md +14 -0
- matrix_python-1.0.1/docs/docs/examples/error-handling.md +17 -0
- matrix_python-1.0.1/docs/docs/examples/extension.md +26 -0
- matrix_python-1.0.1/docs/docs/examples/index.md +20 -0
- matrix_python-1.0.1/docs/docs/examples/ping.md +9 -0
- matrix_python-1.0.1/docs/docs/examples/reaction.md +14 -0
- matrix_python-1.0.1/docs/docs/examples/scheduler.md +19 -0
- matrix_python-1.0.1/docs/docs/guides/bigger-bot.md +95 -0
- matrix_python-1.0.1/docs/docs/guides/checks.md +114 -0
- matrix_python-1.0.1/docs/docs/guides/commands.md +158 -0
- matrix_python-1.0.1/docs/docs/guides/component.md +141 -0
- matrix_python-1.0.1/docs/docs/guides/configuration.md +86 -0
- matrix_python-1.0.1/docs/docs/guides/error-handling.md +97 -0
- matrix_python-1.0.1/docs/docs/guides/events.md +115 -0
- matrix_python-1.0.1/docs/docs/guides/groups.md +111 -0
- matrix_python-1.0.1/docs/docs/guides/index.md +87 -0
- matrix_python-1.0.1/docs/docs/guides/introduction.md +126 -0
- matrix_python-1.0.1/docs/docs/img/favicon.svg +68 -0
- matrix_python-1.0.1/docs/docs/img/matrixpy-black.svg +72 -0
- matrix_python-1.0.1/docs/docs/img/matrixpy-white.svg +89 -0
- matrix_python-1.0.1/docs/docs/index.md +175 -0
- matrix_python-1.0.1/docs/docs/reference/bot.md +20 -0
- matrix_python-1.0.1/docs/docs/reference/checks.md +17 -0
- matrix_python-1.0.1/docs/docs/reference/command.md +15 -0
- matrix_python-1.0.1/docs/docs/reference/component.md +27 -0
- matrix_python-1.0.1/docs/docs/reference/config.md +19 -0
- matrix_python-1.0.1/docs/docs/reference/content.md +34 -0
- matrix_python-1.0.1/docs/docs/reference/context.md +15 -0
- matrix_python-1.0.1/docs/docs/reference/errors.md +18 -0
- matrix_python-1.0.1/docs/docs/reference/extension.md +30 -0
- matrix_python-1.0.1/docs/docs/reference/group.md +19 -0
- matrix_python-1.0.1/docs/docs/reference/message.md +15 -0
- matrix_python-1.0.1/docs/docs/reference/protocols.md +5 -0
- matrix_python-1.0.1/docs/docs/reference/registry.md +7 -0
- matrix_python-1.0.1/docs/docs/reference/room.md +15 -0
- matrix_python-1.0.1/docs/docs/reference/scheduler.md +16 -0
- matrix_python-1.0.1/docs/docs/reference/space.md +15 -0
- matrix_python-1.0.1/docs/docs/reference/types.md +26 -0
- matrix_python-1.0.1/docs/docs/stylesheets/extra.css +3 -0
- matrix_python-1.0.1/docs/mkdocs.yml +125 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/examples/checks.py +2 -2
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/examples/config.yaml +1 -1
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/examples/cooldown.py +2 -2
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/examples/error_handling.py +2 -2
- matrix_python-1.0.1/examples/extension.py +47 -0
- matrix_python-1.0.1/examples/member.py +33 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/examples/ping.py +2 -2
- matrix_python-1.0.1/examples/reaction.py +39 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/examples/scheduler.py +5 -5
- matrix_python-1.0.1/examples/table.py +20 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/matrix/__init__.py +13 -2
- matrix_python-1.0.1/matrix/_error_handler.py +14 -0
- matrix_python-1.0.1/matrix/_version.py +24 -0
- matrix_python-1.0.1/matrix/api.py +111 -0
- matrix_python-1.0.1/matrix/bot.py +430 -0
- matrix_python-1.0.1/matrix/checks.py +122 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/matrix/command.py +50 -51
- matrix_python-1.0.1/matrix/component.py +109 -0
- matrix_python-1.0.1/matrix/config.py +125 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/matrix/content.py +15 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/matrix/context.py +6 -5
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/matrix/errors.py +23 -6
- matrix_python-1.0.1/matrix/extension.py +90 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/matrix/group.py +61 -7
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/matrix/help/help_command.py +62 -72
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/matrix/help/pagination.py +4 -22
- matrix_python-1.0.1/matrix/member.py +217 -0
- matrix_python-1.0.1/matrix/message.py +295 -0
- matrix_python-1.0.1/matrix/protocols.py +13 -0
- matrix_python-1.0.1/matrix/py.typed +0 -0
- matrix_python-1.0.1/matrix/registry.py +460 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/matrix/room.py +175 -48
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/matrix/scheduler.py +13 -10
- matrix_python-1.0.1/matrix/space.py +45 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/matrix/types.py +15 -0
- matrix_python-1.0.1/matrix_python.egg-info/PKG-INFO +153 -0
- matrix_python-1.0.1/matrix_python.egg-info/SOURCES.txt +122 -0
- matrix_python-1.0.1/matrix_python.egg-info/requires.txt +21 -0
- matrix_python-1.0.1/matrix_python.egg-info/scm_file_list.json +118 -0
- matrix_python-1.0.1/matrix_python.egg-info/scm_version.json +8 -0
- matrix_python-1.0.1/pyproject.toml +64 -0
- matrix_python-1.0.1/tests/test_api.py +220 -0
- matrix_python-1.0.1/tests/test_bot.py +1102 -0
- matrix_python-1.0.1/tests/test_checks.py +258 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/tests/test_command.py +89 -27
- matrix_python-1.0.1/tests/test_component.py +102 -0
- matrix_python-1.0.1/tests/test_config.py +139 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/tests/test_context.py +0 -1
- matrix_python-1.0.1/tests/test_error_handler.py +70 -0
- matrix_python-1.0.1/tests/test_extension.py +252 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/tests/test_group.py +34 -2
- matrix_python-1.0.1/tests/test_member.py +392 -0
- matrix_python-1.0.1/tests/test_message.py +465 -0
- matrix_python-1.0.1/tests/test_registry.py +416 -0
- matrix_python-1.0.1/tests/test_room.py +570 -0
- matrix_python-1.0.1/tests/test_space.py +151 -0
- matrix_python-1.0.0b0/.github/workflows/tests.yml +0 -35
- matrix_python-1.0.0b0/LICENSE +0 -674
- matrix_python-1.0.0b0/PKG-INFO +0 -773
- matrix_python-1.0.0b0/README.md +0 -74
- matrix_python-1.0.0b0/examples/reaction.py +0 -43
- matrix_python-1.0.0b0/matrix/_version.py +0 -34
- matrix_python-1.0.0b0/matrix/bot.py +0 -495
- matrix_python-1.0.0b0/matrix/checks.py +0 -21
- matrix_python-1.0.0b0/matrix/config.py +0 -61
- matrix_python-1.0.0b0/matrix/message.py +0 -131
- matrix_python-1.0.0b0/matrix_python.egg-info/PKG-INFO +0 -773
- matrix_python-1.0.0b0/matrix_python.egg-info/SOURCES.txt +0 -53
- matrix_python-1.0.0b0/matrix_python.egg-info/requires.txt +0 -13
- matrix_python-1.0.0b0/pyproject.toml +0 -47
- matrix_python-1.0.0b0/tests/config_fixture.yaml +0 -4
- matrix_python-1.0.0b0/tests/config_fixture_token.yaml +0 -1
- matrix_python-1.0.0b0/tests/test_bot.py +0 -414
- matrix_python-1.0.0b0/tests/test_config.py +0 -81
- matrix_python-1.0.0b0/tests/test_message.py +0 -139
- matrix_python-1.0.0b0/tests/test_room.py +0 -356
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/CODE_OF_CONDUCT.md +0 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/examples/README.md +0 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/matrix/help/__init__.py +0 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/matrix_python.egg-info/dependency_links.txt +0 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/matrix_python.egg-info/top_level.txt +0 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/mypy.ini +0 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/setup.cfg +0 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/tests/help/test_default_help_command.py +0 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/tests/help/test_help_command.py +0 -0
- {matrix_python-1.0.0b0 → matrix_python-1.0.1}/tests/help/test_pagination.py +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: PenguinBoi12
|
|
7
|
+
type: Bug
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
**Describe the bug**
|
|
12
|
+
A clear and concise description of what the bug is.
|
|
13
|
+
|
|
14
|
+
**To Reproduce**
|
|
15
|
+
Steps to reproduce the behavior:
|
|
16
|
+
1. Go to '...'
|
|
17
|
+
2. Click on '....'
|
|
18
|
+
3. Scroll down to '....'
|
|
19
|
+
4. See error
|
|
20
|
+
|
|
21
|
+
**Expected behavior**
|
|
22
|
+
A clear and concise description of what you expected to happen.
|
|
23
|
+
|
|
24
|
+
**Screenshots**
|
|
25
|
+
If applicable, add screenshots to help explain your problem.
|
|
26
|
+
|
|
27
|
+
**Additional context**
|
|
28
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 'Feature: Good First'
|
|
3
|
+
about: 'This template is for good first issues '
|
|
4
|
+
title: ''
|
|
5
|
+
labels: good first issue
|
|
6
|
+
assignees: ''
|
|
7
|
+
type: Feature
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
Explain clearly what we want to add and why it's useful to add it. Give context when necessary.
|
|
12
|
+
|
|
13
|
+
### Proposed API
|
|
14
|
+
This is a proposed API. It does not necessarily mean it's the final API but it's a good place to start.
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
Some code here
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Example**
|
|
21
|
+
```python
|
|
22
|
+
An example of usage of the feature
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Before opening a PR
|
|
26
|
+
- Write unit tests
|
|
27
|
+
- Run `mypy matrix/`
|
|
28
|
+
- Run `pytest tests/`
|
|
29
|
+
- Run `black .`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
type: Feature
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
**Is your feature request related to a problem? Please describe.**
|
|
12
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
13
|
+
|
|
14
|
+
**Describe the solution you'd like**
|
|
15
|
+
A clear and concise description of what you want to happen.
|
|
16
|
+
|
|
17
|
+
**Describe alternatives you've considered**
|
|
18
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
|
19
|
+
|
|
20
|
+
**Additional context**
|
|
21
|
+
Add any other context or screenshots about the feature request here.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
## Description
|
|
2
|
+
Brief description of what this PR does and why.
|
|
3
|
+
|
|
4
|
+
### Type of Change
|
|
5
|
+
- [ ] Feature
|
|
6
|
+
- [ ] Refactor
|
|
7
|
+
- [ ] Bug fix
|
|
8
|
+
- [ ] Documentation
|
|
9
|
+
- [ ] Other: ___
|
|
10
|
+
|
|
11
|
+
### Pre-merge Checklist
|
|
12
|
+
- [ ] Run tests: `pytest`
|
|
13
|
+
- [ ] Run type check: `mypy`
|
|
14
|
+
- [ ] Run formatting: `black .
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* @PenguinBoi12
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: Deploy Docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [ published ]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
pages: write
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
deploy:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
environment:
|
|
16
|
+
name: github-pages
|
|
17
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.10"
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: pip install .[doc]
|
|
28
|
+
|
|
29
|
+
- name: Build docs
|
|
30
|
+
run: cd docs && mkdocs build
|
|
31
|
+
|
|
32
|
+
- uses: actions/upload-pages-artifact@v3
|
|
33
|
+
with:
|
|
34
|
+
path: docs/site
|
|
35
|
+
|
|
36
|
+
- name: Deploy to GitHub Pages
|
|
37
|
+
id: deployment
|
|
38
|
+
uses: actions/deploy-pages@v4
|
|
@@ -43,7 +43,7 @@ jobs:
|
|
|
43
43
|
environment:
|
|
44
44
|
name: release
|
|
45
45
|
url: https://pypi.org/project/matrix-python/${{ github.event.release.tag_name }}
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
steps:
|
|
48
48
|
- name: Retrieve release distributions
|
|
49
49
|
uses: actions/download-artifact@v4
|
|
@@ -52,4 +52,4 @@ jobs:
|
|
|
52
52
|
path: dist/
|
|
53
53
|
|
|
54
54
|
- name: Publish release distributions to PyPI
|
|
55
|
-
uses: pypa/gh-action-pypi-publish@release/v1
|
|
55
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "main" ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ "main" ]
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- name: Set up Python 3.12
|
|
20
|
+
uses: actions/setup-python@v3
|
|
21
|
+
with:
|
|
22
|
+
python-version: "3.12"
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: |
|
|
25
|
+
python -m pip install --upgrade pip
|
|
26
|
+
pip install -e .[dev]
|
|
27
|
+
- name: Lint with Black
|
|
28
|
+
id: black
|
|
29
|
+
continue-on-error: true
|
|
30
|
+
run: |
|
|
31
|
+
black --check matrix/ tests/ examples/
|
|
32
|
+
- name: Check typing with mypy
|
|
33
|
+
id: mypy
|
|
34
|
+
continue-on-error: true
|
|
35
|
+
run: |
|
|
36
|
+
mypy matrix
|
|
37
|
+
- name: Test with pytest
|
|
38
|
+
id: pytest
|
|
39
|
+
continue-on-error: true
|
|
40
|
+
run: |
|
|
41
|
+
pytest -v --cov=matrix --cov-report=term-missing --cov-fail-under=90
|
|
42
|
+
- name: All checks succeeded
|
|
43
|
+
if: steps.black.outcome == 'failure' || steps.mypy.outcome == 'failure' || steps.pytest.outcome == 'failure'
|
|
44
|
+
run: exit 1
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
default_language_version:
|
|
2
|
+
python: python3
|
|
3
|
+
|
|
4
|
+
default_stages: [pre-commit]
|
|
5
|
+
|
|
6
|
+
repos:
|
|
7
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
8
|
+
rev: v6.0.0
|
|
9
|
+
hooks:
|
|
10
|
+
- id: check-added-large-files
|
|
11
|
+
stages: [pre-commit]
|
|
12
|
+
- id: check-toml
|
|
13
|
+
stages: [pre-commit]
|
|
14
|
+
- id: check-yaml
|
|
15
|
+
exclude: ^docs/mkdocs\.yml$
|
|
16
|
+
stages: [pre-commit]
|
|
17
|
+
- id: end-of-file-fixer
|
|
18
|
+
stages: [pre-commit]
|
|
19
|
+
- id: trailing-whitespace
|
|
20
|
+
stages: [pre-commit]
|
|
21
|
+
|
|
22
|
+
- repo: local
|
|
23
|
+
hooks:
|
|
24
|
+
- id: black
|
|
25
|
+
name: black
|
|
26
|
+
entry: python -m black
|
|
27
|
+
language: system
|
|
28
|
+
stages: [pre-commit]
|
|
29
|
+
types_or: [python, pyi]
|
|
30
|
+
|
|
31
|
+
- id: mypy
|
|
32
|
+
name: mypy
|
|
33
|
+
entry: python -m mypy matrix
|
|
34
|
+
language: system
|
|
35
|
+
pass_filenames: false
|
|
36
|
+
stages: [pre-commit]
|
|
37
|
+
types_or: [python, pyi]
|
|
38
|
+
|
|
39
|
+
- id: pytest
|
|
40
|
+
name: pytest
|
|
41
|
+
entry: python -m pytest
|
|
42
|
+
language: system
|
|
43
|
+
pass_filenames: false
|
|
44
|
+
stages: [pre-commit]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Thank you for your interest in contributing to the matrix.py! As an open source project, many kinds of contributions are welcome.
|
|
3
3
|
|
|
4
4
|
## How can you contribute?
|
|
5
|
-
You can contribute to this project in the
|
|
5
|
+
You can contribute to this project in the following ways
|
|
6
6
|
|
|
7
7
|
- Report Bugs
|
|
8
8
|
- Add new features
|
|
@@ -12,9 +12,27 @@ You can contribute to this project in the follwing ways
|
|
|
12
12
|
**Warning:** Non-trivial pull requests must have an [issue](https://github.com/Code-Society-Lab/matrixpy/issues) proposing the changes.
|
|
13
13
|
|
|
14
14
|
## Setup
|
|
15
|
-
1. Clone the
|
|
16
|
-
2. Create a virtual
|
|
17
|
-
3. Install the dependencies
|
|
15
|
+
1. Clone the matrix.py repository
|
|
16
|
+
2. Create and activate a virtual environment
|
|
17
|
+
3. Install the development dependencies and enable the Git hooks.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install -e ".[dev]"
|
|
21
|
+
pre-commit install
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
After installation, the Git hooks run automatically before each commit to check formatting, typing, and tests.
|
|
26
|
+
The hooks include running:
|
|
27
|
+
- black
|
|
28
|
+
- mypy
|
|
29
|
+
- pytest
|
|
30
|
+
|
|
31
|
+
Run the full hook suite manually with:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pre-commit run --all-files
|
|
35
|
+
```
|
|
18
36
|
|
|
19
37
|
## Guidelines
|
|
20
38
|
Read any issue instructions carefully. Feel free to ask for clarification if any details are missing.
|
|
@@ -22,8 +40,8 @@ Read any issue instructions carefully. Feel free to ask for clarification if any
|
|
|
22
40
|
Add docstrings to all of your code (functions, methods, classes, ...). The codebase should have enough examples for you to copy from.
|
|
23
41
|
|
|
24
42
|
Write tests for your code.
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
- If you are fixing a bug, add a regression test that references the original issue.
|
|
44
|
+
- If you are implementing a new feature, add tests covering the new functionality.
|
|
27
45
|
|
|
28
46
|
## Before opening a PR
|
|
29
47
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Code Society Lab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: matrix-python
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: An easy-to-use Matrix bot framework designed for quick development and minimal setup
|
|
5
|
+
Author: Simon Roy, Chris Dedman Rollet
|
|
6
|
+
Maintainer-email: Code Society Lab <admin@codesociety.xyz>
|
|
7
|
+
License: The MIT License (MIT)
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2025 Code Society Lab
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in
|
|
19
|
+
all copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
27
|
+
THE SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://codesociety.xyz
|
|
30
|
+
Project-URL: Source, https://github.com/Code-Society-Lab/matrixpy
|
|
31
|
+
Project-URL: Issues, https://github.com/Code-Society-Lab/matrixpy/issues
|
|
32
|
+
Requires-Python: >=3.10
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
Requires-Dist: matrix-nio==0.26.0
|
|
35
|
+
Requires-Dist: logger
|
|
36
|
+
Requires-Dist: PyYAML==6.0.3
|
|
37
|
+
Requires-Dist: markdown==3.10.2
|
|
38
|
+
Requires-Dist: APScheduler==3.11.3
|
|
39
|
+
Requires-Dist: envyaml==1.10.211231
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: pytest==9.1.1; extra == "dev"
|
|
42
|
+
Requires-Dist: pytest-cov==7.1.0; extra == "dev"
|
|
43
|
+
Requires-Dist: pytest-asyncio==1.4.0; extra == "dev"
|
|
44
|
+
Requires-Dist: black==26.5.1; extra == "dev"
|
|
45
|
+
Requires-Dist: mypy==2.1.0; extra == "dev"
|
|
46
|
+
Requires-Dist: pre-commit==4.6.1; extra == "dev"
|
|
47
|
+
Requires-Dist: types-PyYAML==6.0.12.20260724; extra == "dev"
|
|
48
|
+
Requires-Dist: types-Markdown==3.10.2.20260518; extra == "dev"
|
|
49
|
+
Provides-Extra: doc
|
|
50
|
+
Requires-Dist: mkdocs==1.6.1; extra == "doc"
|
|
51
|
+
Requires-Dist: mkdocs-material==9.7.7; extra == "doc"
|
|
52
|
+
Requires-Dist: mkdocstrings[python]==1.0.6; extra == "doc"
|
|
53
|
+
|
|
54
|
+
<div align="center">
|
|
55
|
+
<em>A simple, developer-friendly library to create powerful <a href="https://matrix.org">Matrix</a> bots.</em>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div align="center">
|
|
59
|
+
<img alt="matrix.py" src="https://github.com/user-attachments/assets/d9140a9e-27fa-44e4-a5ca-87ee7bbf868f" />
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div align="center">
|
|
63
|
+
|
|
64
|
+
[<img src="https://img.shields.io/badge/Get%20Started-black?style=for-the-badge" />](https://matrixpy.codesociety.xyz/guides/introduction/)
|
|
65
|
+
[<img src="https://img.shields.io/badge/Reference-555555?style=for-the-badge" />](https://matrixpy.codesociety.xyz/reference/bot/)
|
|
66
|
+
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<div align="center">
|
|
70
|
+
|
|
71
|
+
[](https://discord.gg/code-society-823178343943897088)
|
|
72
|
+
[](https://matrix.to/#/%23codesociety:matrix.org)
|
|
73
|
+
[](https://github.com/Code-Society-Lab/matrixpy/actions/workflows/tests.yml)
|
|
74
|
+
[](https://pypi.org/project/matrix-python/)
|
|
75
|
+
[](https://github.com/Code-Society-Lab/matrixpy/actions/workflows/codeql.yml)
|
|
76
|
+
[](https://securityscorecards.dev/viewer/?uri=github.com/Code-Society-Lab/matrixpy)
|
|
77
|
+
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
Matrix.py is a lightweight and intuitive Python library to build bots on the [Matrix protocol](https://matrix.org). It
|
|
83
|
+
provides a clean, decorator-based API similar to popular event-driven frameworks, allowing developers to focus on
|
|
84
|
+
behavior rather than boilerplate.
|
|
85
|
+
|
|
86
|
+
- **Minimal setup** — install and have a working bot running in minutes
|
|
87
|
+
- **Event-driven** — async/await API reacting to any Matrix room event
|
|
88
|
+
- **Command system** — decorator-based commands with automatic argument parsing
|
|
89
|
+
- **Extensions** — split your bot into modules as it grows
|
|
90
|
+
|
|
91
|
+
## Quickstart
|
|
92
|
+
|
|
93
|
+
**Requirements:** Python 3.10+
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pip install matrix-python
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Using a virtual environment is strongly recommended:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
python -m venv venv
|
|
103
|
+
source venv/bin/activate # Windows: venv\Scripts\activate
|
|
104
|
+
pip install matrix-python
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Create a `config.yml`:
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
USERNAME: "@yourbot:matrix.org"
|
|
111
|
+
PASSWORD: "your_password"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from matrix import Bot, Context
|
|
116
|
+
|
|
117
|
+
bot = Bot()
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
@bot.command("ping")
|
|
121
|
+
async def ping(ctx: Context):
|
|
122
|
+
await ctx.reply("Pong!")
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
bot.start(config="config.yml")
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Send `!ping` in any room the bot is in, it will reply `Pong!`.
|
|
129
|
+
|
|
130
|
+
## Where to go next
|
|
131
|
+
|
|
132
|
+
- [**Guides**](https://matrixpy.codesociety.xyz/guides/introduction/) — step-by-step tutorials covering commands,
|
|
133
|
+
events, checks, extensions, and more
|
|
134
|
+
- [**Reference**](https://matrixpy.codesociety.xyz/reference/bot/) — complete API documentation for every class and
|
|
135
|
+
function
|
|
136
|
+
- [**Examples**](https://matrixpy.codesociety.xyz/examples/) — ready-to-run example bots
|
|
137
|
+
demonstrating common patterns
|
|
138
|
+
|
|
139
|
+
## Contributing
|
|
140
|
+
|
|
141
|
+
We welcome everyone to contribute! Whether it's fixing bugs, suggesting features, or improving the docs. Every bit
|
|
142
|
+
helps.
|
|
143
|
+
|
|
144
|
+
- [Submit an issue](https://github.com/Code-Society-Lab/matrixpy/issues)
|
|
145
|
+
- [Open a pull request](https://github.com/Code-Society-Lab/matrixpy/blob/main/CONTRIBUTING.md)
|
|
146
|
+
- Hop into our [Matrix](https://matrix.to/#/%23codesociety:matrix.org)
|
|
147
|
+
or [Discord](https://discord.gg/code-society-823178343943897088) and say hi!
|
|
148
|
+
|
|
149
|
+
Please read the [CONTRIBUTING.md](./CONTRIBUTING.md) and follow the [code of conduct](./CODE_OF_CONDUCT.md).
|
|
150
|
+
|
|
151
|
+
## License
|
|
152
|
+
|
|
153
|
+
Released under the [MIT License](https://github.com/Code-Society-Lab/matrixpy/blob/main/LICENSE).
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<em>A simple, developer-friendly library to create powerful <a href="https://matrix.org">Matrix</a> bots.</em>
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
6
|
+
<img alt="matrix.py" src="https://github.com/user-attachments/assets/d9140a9e-27fa-44e4-a5ca-87ee7bbf868f" />
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<div align="center">
|
|
10
|
+
|
|
11
|
+
[<img src="https://img.shields.io/badge/Get%20Started-black?style=for-the-badge" />](https://matrixpy.codesociety.xyz/guides/introduction/)
|
|
12
|
+
[<img src="https://img.shields.io/badge/Reference-555555?style=for-the-badge" />](https://matrixpy.codesociety.xyz/reference/bot/)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
<div align="center">
|
|
17
|
+
|
|
18
|
+
[](https://discord.gg/code-society-823178343943897088)
|
|
19
|
+
[](https://matrix.to/#/%23codesociety:matrix.org)
|
|
20
|
+
[](https://github.com/Code-Society-Lab/matrixpy/actions/workflows/tests.yml)
|
|
21
|
+
[](https://pypi.org/project/matrix-python/)
|
|
22
|
+
[](https://github.com/Code-Society-Lab/matrixpy/actions/workflows/codeql.yml)
|
|
23
|
+
[](https://securityscorecards.dev/viewer/?uri=github.com/Code-Society-Lab/matrixpy)
|
|
24
|
+
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
Matrix.py is a lightweight and intuitive Python library to build bots on the [Matrix protocol](https://matrix.org). It
|
|
30
|
+
provides a clean, decorator-based API similar to popular event-driven frameworks, allowing developers to focus on
|
|
31
|
+
behavior rather than boilerplate.
|
|
32
|
+
|
|
33
|
+
- **Minimal setup** — install and have a working bot running in minutes
|
|
34
|
+
- **Event-driven** — async/await API reacting to any Matrix room event
|
|
35
|
+
- **Command system** — decorator-based commands with automatic argument parsing
|
|
36
|
+
- **Extensions** — split your bot into modules as it grows
|
|
37
|
+
|
|
38
|
+
## Quickstart
|
|
39
|
+
|
|
40
|
+
**Requirements:** Python 3.10+
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install matrix-python
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Using a virtual environment is strongly recommended:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
python -m venv venv
|
|
50
|
+
source venv/bin/activate # Windows: venv\Scripts\activate
|
|
51
|
+
pip install matrix-python
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Create a `config.yml`:
|
|
55
|
+
|
|
56
|
+
```yaml
|
|
57
|
+
USERNAME: "@yourbot:matrix.org"
|
|
58
|
+
PASSWORD: "your_password"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
from matrix import Bot, Context
|
|
63
|
+
|
|
64
|
+
bot = Bot()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@bot.command("ping")
|
|
68
|
+
async def ping(ctx: Context):
|
|
69
|
+
await ctx.reply("Pong!")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
bot.start(config="config.yml")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Send `!ping` in any room the bot is in, it will reply `Pong!`.
|
|
76
|
+
|
|
77
|
+
## Where to go next
|
|
78
|
+
|
|
79
|
+
- [**Guides**](https://matrixpy.codesociety.xyz/guides/introduction/) — step-by-step tutorials covering commands,
|
|
80
|
+
events, checks, extensions, and more
|
|
81
|
+
- [**Reference**](https://matrixpy.codesociety.xyz/reference/bot/) — complete API documentation for every class and
|
|
82
|
+
function
|
|
83
|
+
- [**Examples**](https://matrixpy.codesociety.xyz/examples/) — ready-to-run example bots
|
|
84
|
+
demonstrating common patterns
|
|
85
|
+
|
|
86
|
+
## Contributing
|
|
87
|
+
|
|
88
|
+
We welcome everyone to contribute! Whether it's fixing bugs, suggesting features, or improving the docs. Every bit
|
|
89
|
+
helps.
|
|
90
|
+
|
|
91
|
+
- [Submit an issue](https://github.com/Code-Society-Lab/matrixpy/issues)
|
|
92
|
+
- [Open a pull request](https://github.com/Code-Society-Lab/matrixpy/blob/main/CONTRIBUTING.md)
|
|
93
|
+
- Hop into our [Matrix](https://matrix.to/#/%23codesociety:matrix.org)
|
|
94
|
+
or [Discord](https://discord.gg/code-society-823178343943897088) and say hi!
|
|
95
|
+
|
|
96
|
+
Please read the [CONTRIBUTING.md](./CONTRIBUTING.md) and follow the [code of conduct](./CODE_OF_CONDUCT.md).
|
|
97
|
+
|
|
98
|
+
## License
|
|
99
|
+
|
|
100
|
+
Released under the [MIT License](https://github.com/Code-Society-Lab/matrixpy/blob/main/LICENSE).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Checks
|
|
2
|
+
|
|
3
|
+
Shows how to restrict a command to a specific set of users using a [check](../reference/checks.md). The `!secret` command is only accessible to users in the `allowed_users` set — anyone else receives an "Access denied" reply.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
--8<-- "examples/checks.py"
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Key points:
|
|
10
|
+
|
|
11
|
+
- `@secret_command.check` decorates an async function that returns `True` (allow) or `False` (deny). Returning `False` raises a [`CheckError`](../reference/errors.md).
|
|
12
|
+
- `@secret_command.error(CheckError)` handles the denial and sends a friendly reply instead of silently failing.
|
|
13
|
+
- `ctx.sender` is the full Matrix ID of the user who sent the command (e.g. `@alice:matrix.org`).
|
|
14
|
+
|
|
15
|
+
See the [Checks guide](../guides/checks.md) for built-in checks like `@is_owner` and how to compose multiple checks.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Cooldowns
|
|
2
|
+
|
|
3
|
+
Demonstrates two ways to apply a rate limit to a command, and how to handle the [`CooldownError`](../reference/errors.md) when the limit is exceeded.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
--8<-- "examples/cooldown.py"
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
There are two ways to set a cooldown:
|
|
10
|
+
|
|
11
|
+
- **`@cooldown(rate, period)` decorator** — applied before `@bot.command`. `rate=2, period=10` means 2 uses per 10 seconds per user.
|
|
12
|
+
- **`cooldown=(rate, period)` argument** — passed directly to `@bot.command` for a more compact one-liner.
|
|
13
|
+
|
|
14
|
+
Both produce a `CooldownError` when the limit is exceeded. The error object exposes `error.retry` — the number of seconds until the user can try again — which you can surface in the reply.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Error Handling
|
|
2
|
+
|
|
3
|
+
Shows both per-command error handlers and a global error handler, covering argument validation, runtime errors, and unknown commands.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
--8<-- "examples/error_handling.py"
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Three layers of error handling are demonstrated:
|
|
10
|
+
|
|
11
|
+
- **Global handler** — `@bot.error(CommandNotFoundError)` catches any command the bot doesn't recognise, across the whole bot. No `ctx` is available here since no command was matched.
|
|
12
|
+
- **Per-command handlers** — `@division.error(ZeroDivisionError)` and `@division.error(ValueError)` handle errors raised inside the `division` function itself.
|
|
13
|
+
- **Argument handler** — `@division.error(MissingArgumentError)` fires when the user doesn't supply enough arguments.
|
|
14
|
+
|
|
15
|
+
Handlers are matched by exception type. If no handler is registered for a raised exception, it propagates normally.
|
|
16
|
+
|
|
17
|
+
See the [Error Handling guide](../guides/error-handling.md) for the full picture.
|