Compare commits
32 Commits
slix-1.8.6
...
master
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a30f76892b | ||
![]() |
3de8ee97b5 | ||
![]() |
0de9df92c4 | ||
![]() |
04d5c43853 | ||
![]() |
0707786057 | ||
![]() |
1c762c6b25 | ||
![]() |
f94a4f2dbd | ||
![]() |
75ea0bf039 | ||
![]() |
4cf1286332 | ||
![]() |
8a127f61d0 | ||
![]() |
1f14fb54c2 | ||
![]() |
651e0ea593 | ||
![]() |
4ac41a5250 | ||
![]() |
e03b7661c1 | ||
![]() |
e955cd308a | ||
![]() |
2db5e0199c | ||
![]() |
bf2e006f88 | ||
![]() |
8c8bb5da8b | ||
![]() |
bd638f1b39 | ||
![]() |
0ff9e3661d | ||
![]() |
5ec378cccd | ||
![]() |
a9fc955eda | ||
![]() |
05860f71ac | ||
![]() |
1482bcc395 | ||
![]() |
2e736bc715 | ||
![]() |
8d984cd8a1 | ||
![]() |
100014651c | ||
![]() |
f9a9a0dcb7 | ||
![]() |
c585ec5983 | ||
![]() |
27bbb1ef95 | ||
![]() |
5dfc622539 | ||
![]() |
2ab9b5a05c |
@ -1,81 +0,0 @@
|
|||||||
stages:
|
|
||||||
- lint
|
|
||||||
- test
|
|
||||||
- trigger
|
|
||||||
|
|
||||||
mypy:
|
|
||||||
stage: lint
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
image: python:3
|
|
||||||
script:
|
|
||||||
- pip3 install mypy
|
|
||||||
- mypy slixmpp
|
|
||||||
|
|
||||||
test-3.7:
|
|
||||||
stage: test
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
image: python:3.7
|
|
||||||
script:
|
|
||||||
- apt-get update
|
|
||||||
- apt-get install -y python3 python3-pip cython3 gpg
|
|
||||||
- pip3 install emoji aiohttp cryptography
|
|
||||||
- ./run_tests.py
|
|
||||||
|
|
||||||
test-3.10:
|
|
||||||
stage: test
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
image: python:3.10
|
|
||||||
script:
|
|
||||||
- apt update
|
|
||||||
- apt-get install -y python3 python3-pip cython3 gpg
|
|
||||||
- pip3 install emoji aiohttp cryptography
|
|
||||||
- ./run_tests.py
|
|
||||||
|
|
||||||
test-3.11:
|
|
||||||
stage: test
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
image: python:3.11
|
|
||||||
script:
|
|
||||||
- apt-get update
|
|
||||||
- apt-get install -y python3 python3-pip cython3 gpg
|
|
||||||
- pip3 install emoji aiohttp cryptography
|
|
||||||
- ./run_tests.py
|
|
||||||
|
|
||||||
test-3.12:
|
|
||||||
stage: test
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
image: python:3.12-rc
|
|
||||||
allow_failure: true
|
|
||||||
script:
|
|
||||||
- apt-get update
|
|
||||||
- apt-get install -y python3 python3-pip cython3 gpg
|
|
||||||
- pip3 install emoji aiohttp cryptography
|
|
||||||
- ./run_tests.py
|
|
||||||
|
|
||||||
test_integration:
|
|
||||||
stage: test
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
image: python:3
|
|
||||||
only:
|
|
||||||
variables:
|
|
||||||
- $CI_ACCOUNT1
|
|
||||||
- $CI_ACCOUNT2
|
|
||||||
script:
|
|
||||||
- apt-get update
|
|
||||||
- apt-get install -y python3 python3-pip cython3 gpg
|
|
||||||
- pip3 install emoji aiohttp aiodns
|
|
||||||
- ./run_integration_tests.py
|
|
||||||
|
|
||||||
trigger_poezio:
|
|
||||||
stage: trigger
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
image: curlimages/curl:7.79.1
|
|
||||||
script:
|
|
||||||
- curl --request POST -F token="$SLIXMPP_TRIGGER_TOKEN" -F ref=master https://lab.louiz.org/api/v4/projects/18/trigger/pipeline
|
|
@ -1,7 +0,0 @@
|
|||||||
language: python
|
|
||||||
python:
|
|
||||||
- "3.7"
|
|
||||||
- "3.8-dev"
|
|
||||||
install:
|
|
||||||
- "pip install ."
|
|
||||||
script: testall.py
|
|
@ -1,3 +1,6 @@
|
|||||||
|
when:
|
||||||
|
event: [ push, pull_request ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
mypy:
|
mypy:
|
||||||
image: python:3
|
image: python:3
|
||||||
|
@ -1,7 +1,20 @@
|
|||||||
|
when:
|
||||||
|
event: [ push, pull_request ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
test_integration:
|
test_integration:
|
||||||
image: "python:3.11"
|
image: "python:3.11"
|
||||||
secrets: [ci_account1, ci_account1_password, ci_account2, ci_account2_password, ci_muc_server]
|
environment:
|
||||||
|
CI_ACCOUNT1:
|
||||||
|
from_secret: ci_account1
|
||||||
|
CI_ACCOUNT1_PASSWORD:
|
||||||
|
from_secret: ci_account1_password
|
||||||
|
CI_ACCOUNT2:
|
||||||
|
from_secret: ci_account2
|
||||||
|
CI_ACCOUNT2_PASSWORD:
|
||||||
|
from_secret: ci_account2_password
|
||||||
|
CI_MUC_SERVER:
|
||||||
|
from_secret: ci_muc_server
|
||||||
commands:
|
commands:
|
||||||
- apt-get update
|
- apt-get update
|
||||||
- apt-get install -y python3-pip cython3 gpg idn libidn-dev
|
- apt-get install -y python3-pip cython3 gpg idn libidn-dev
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
|
when:
|
||||||
|
event: [ push, pull_request ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
unit_tests:
|
unit_tests:
|
||||||
image: "python:${TAG}"
|
image: "python:${TAG}"
|
||||||
commands:
|
commands:
|
||||||
- apt-get update
|
- apt-get update
|
||||||
- apt-get install -y python3 python3-pip cython3 gpg
|
- apt-get install -y python3 python3-pip cython3 gpg
|
||||||
- pip3 install emoji aiohttp cryptography
|
- pip3 install emoji aiohttp cryptography setuptools
|
||||||
- ./run_tests.py
|
- ./run_tests.py
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
TAG:
|
TAG:
|
||||||
- "3.7"
|
|
||||||
- "3.9"
|
- "3.9"
|
||||||
- "3.8"
|
|
||||||
- "3.10"
|
- "3.10"
|
||||||
- "3.11"
|
- "3.11"
|
||||||
- "3.12"
|
- "3.12"
|
||||||
|
- "3.13"
|
||||||
|
50
doap.xml
50
doap.xml
@ -616,6 +616,14 @@
|
|||||||
<xmpp:since>1.0</xmpp:since>
|
<xmpp:since>1.0</xmpp:since>
|
||||||
</xmpp:SupportedXep>
|
</xmpp:SupportedXep>
|
||||||
</implements>
|
</implements>
|
||||||
|
<implements>
|
||||||
|
<xmpp:SupportedXep>
|
||||||
|
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0264.html"/>
|
||||||
|
<xmpp:status>complete</xmpp:status>
|
||||||
|
<xmpp:version>0.4.2</xmpp:version>
|
||||||
|
<xmpp:since>1.8.6</xmpp:since>
|
||||||
|
</xmpp:SupportedXep>
|
||||||
|
</implements>
|
||||||
<implements>
|
<implements>
|
||||||
<xmpp:SupportedXep>
|
<xmpp:SupportedXep>
|
||||||
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0270.html"/>
|
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0270.html"/>
|
||||||
@ -682,6 +690,14 @@
|
|||||||
<xmpp:since>1.0</xmpp:since>
|
<xmpp:since>1.0</xmpp:since>
|
||||||
</xmpp:SupportedXep>
|
</xmpp:SupportedXep>
|
||||||
</implements>
|
</implements>
|
||||||
|
<implements>
|
||||||
|
<xmpp:SupportedXep>
|
||||||
|
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0317.html"/>
|
||||||
|
<xmpp:status>complete</xmpp:status>
|
||||||
|
<xmpp:version>1.8.6</xmpp:version>
|
||||||
|
<xmpp:since>0.2</xmpp:since>
|
||||||
|
</xmpp:SupportedXep>
|
||||||
|
</implements>
|
||||||
<implements>
|
<implements>
|
||||||
<xmpp:SupportedXep>
|
<xmpp:SupportedXep>
|
||||||
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0319.html"/>
|
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0319.html"/>
|
||||||
@ -900,13 +916,37 @@
|
|||||||
<xmpp:since>1.6.0</xmpp:since>
|
<xmpp:since>1.6.0</xmpp:since>
|
||||||
</xmpp:SupportedXep>
|
</xmpp:SupportedXep>
|
||||||
</implements>
|
</implements>
|
||||||
|
<implements>
|
||||||
|
<xmpp:SupportedXep>
|
||||||
|
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0446.html"/>
|
||||||
|
<xmpp:status>complete</xmpp:status>
|
||||||
|
<xmpp:version>0.2.0</xmpp:version>
|
||||||
|
<xmpp:since>1.8.7</xmpp:since>
|
||||||
|
</xmpp:SupportedXep>
|
||||||
|
</implements>
|
||||||
<implements>
|
<implements>
|
||||||
<xmpp:SupportedXep>
|
<xmpp:SupportedXep>
|
||||||
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0454.html"/>
|
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0454.html"/>
|
||||||
<xmpp:status>partial</xmpp:status>
|
<xmpp:status>partial</xmpp:status>
|
||||||
<xmpp:version>0.1.0</xmpp:version>
|
<xmpp:version>0.1.0</xmpp:version>
|
||||||
<xmpp:since>1.8.1</xmpp:since>
|
<xmpp:since>1.8.1</xmpp:since>
|
||||||
<xmpp:note>no thumbnail support</xmpp:note>
|
<xmpp:note>no thumbnail support</xmpp:note>
|
||||||
|
</xmpp:SupportedXep>
|
||||||
|
</implements>
|
||||||
|
<implements>
|
||||||
|
<xmpp:SupportedXep>
|
||||||
|
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0469.html"/>
|
||||||
|
<xmpp:status>partial</xmpp:status>
|
||||||
|
<xmpp:version>0.1.0</xmpp:version>
|
||||||
|
<xmpp:since>1.8.6</xmpp:since>
|
||||||
|
</xmpp:SupportedXep>
|
||||||
|
</implements>
|
||||||
|
<implements>
|
||||||
|
<xmpp:SupportedXep>
|
||||||
|
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0482.html"/>
|
||||||
|
<xmpp:status>complete</xmpp:status>
|
||||||
|
<xmpp:version>0.1.0</xmpp:version>
|
||||||
|
<xmpp:since>1.8.7</xmpp:since>
|
||||||
</xmpp:SupportedXep>
|
</xmpp:SupportedXep>
|
||||||
</implements>
|
</implements>
|
||||||
<implements>
|
<implements>
|
||||||
@ -917,6 +957,14 @@
|
|||||||
<xmpp:since>1.8.6</xmpp:since>
|
<xmpp:since>1.8.6</xmpp:since>
|
||||||
</xmpp:SupportedXep>
|
</xmpp:SupportedXep>
|
||||||
</implements>
|
</implements>
|
||||||
|
<implements>
|
||||||
|
<xmpp:SupportedXep>
|
||||||
|
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0492.html"/>
|
||||||
|
<xmpp:status>complete</xmpp:status>
|
||||||
|
<xmpp:version>0.1.0</xmpp:version>
|
||||||
|
<xmpp:since>1.8.7</xmpp:since>
|
||||||
|
</xmpp:SupportedXep>
|
||||||
|
</implements>
|
||||||
|
|
||||||
<release>
|
<release>
|
||||||
<Version>
|
<Version>
|
||||||
|
@ -17,6 +17,7 @@ Plugin index
|
|||||||
xep_0049
|
xep_0049
|
||||||
xep_0050
|
xep_0050
|
||||||
xep_0054
|
xep_0054
|
||||||
|
xep_0055
|
||||||
xep_0059
|
xep_0059
|
||||||
xep_0060
|
xep_0060
|
||||||
xep_0065
|
xep_0065
|
||||||
@ -31,6 +32,7 @@ Plugin index
|
|||||||
xep_0085
|
xep_0085
|
||||||
xep_0086
|
xep_0086
|
||||||
xep_0092
|
xep_0092
|
||||||
|
xep_0100
|
||||||
xep_0106
|
xep_0106
|
||||||
xep_0107
|
xep_0107
|
||||||
xep_0108
|
xep_0108
|
||||||
@ -62,12 +64,15 @@ Plugin index
|
|||||||
xep_0256
|
xep_0256
|
||||||
xep_0257
|
xep_0257
|
||||||
xep_0258
|
xep_0258
|
||||||
|
xep_0264
|
||||||
xep_0279
|
xep_0279
|
||||||
xep_0280
|
xep_0280
|
||||||
|
xep_0292
|
||||||
xep_0297
|
xep_0297
|
||||||
xep_0300
|
xep_0300
|
||||||
xep_0308
|
xep_0308
|
||||||
xep_0313
|
xep_0313
|
||||||
|
xep_0317
|
||||||
xep_0319
|
xep_0319
|
||||||
xep_0332
|
xep_0332
|
||||||
xep_0333
|
xep_0333
|
||||||
@ -79,9 +84,13 @@ Plugin index
|
|||||||
xep_0359
|
xep_0359
|
||||||
xep_0363
|
xep_0363
|
||||||
xep_0369
|
xep_0369
|
||||||
|
xep_0372
|
||||||
xep_0377
|
xep_0377
|
||||||
xep_0380
|
xep_0380
|
||||||
|
xep_0382
|
||||||
|
xep_0385
|
||||||
xep_0394
|
xep_0394
|
||||||
|
xep_0402
|
||||||
xep_0403
|
xep_0403
|
||||||
xep_0404
|
xep_0404
|
||||||
xep_0405
|
xep_0405
|
||||||
@ -94,3 +103,9 @@ Plugin index
|
|||||||
xep_0439
|
xep_0439
|
||||||
xep_0441
|
xep_0441
|
||||||
xep_0444
|
xep_0444
|
||||||
|
xep_0446
|
||||||
|
xep_0447
|
||||||
|
xep_0461
|
||||||
|
xep_0469
|
||||||
|
xep_0490
|
||||||
|
xep_0492
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
XEP-0106: Gateway interaction
|
XEP-0100: Gateway interaction
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
.. module:: slixmpp.plugins.xep_0100
|
.. module:: slixmpp.plugins.xep_0100
|
||||||
|
18
docs/api/plugins/xep_0264.rst
Normal file
18
docs/api/plugins/xep_0264.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
XEP-0264: Jingle Content Thumbnails
|
||||||
|
===================================
|
||||||
|
|
||||||
|
.. module:: slixmpp.plugins.xep_0264
|
||||||
|
|
||||||
|
.. autoclass:: XEP_0264
|
||||||
|
:members:
|
||||||
|
:exclude-members: session_bind, plugin_init, plugin_end
|
||||||
|
|
||||||
|
|
||||||
|
Stanza elements
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. automodule:: slixmpp.plugins.xep_0264.stanza
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
|
18
docs/api/plugins/xep_0317.rst
Normal file
18
docs/api/plugins/xep_0317.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
XEP-0317: Hats
|
||||||
|
==============
|
||||||
|
|
||||||
|
.. module:: slixmpp.plugins.xep_0317
|
||||||
|
|
||||||
|
.. autoclass:: XEP_0317
|
||||||
|
:members:
|
||||||
|
:exclude-members: session_bind, plugin_init, plugin_end
|
||||||
|
|
||||||
|
|
||||||
|
Stanza elements
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. automodule:: slixmpp.plugins.xep_0317.stanza
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
|
18
docs/api/plugins/xep_0372.rst
Normal file
18
docs/api/plugins/xep_0372.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
XEP-0372: References
|
||||||
|
====================
|
||||||
|
|
||||||
|
.. module:: slixmpp.plugins.xep_0372
|
||||||
|
|
||||||
|
.. autoclass:: XEP_0372
|
||||||
|
:members:
|
||||||
|
:exclude-members: session_bind, plugin_init, plugin_end
|
||||||
|
|
||||||
|
|
||||||
|
Stanza elements
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. automodule:: slixmpp.plugins.xep_0372.stanza
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
|
18
docs/api/plugins/xep_0382.rst
Normal file
18
docs/api/plugins/xep_0382.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
XEP-0382: Spoiler Messages
|
||||||
|
==========================
|
||||||
|
|
||||||
|
.. module:: slixmpp.plugins.xep_0382
|
||||||
|
|
||||||
|
.. autoclass:: XEP_0382
|
||||||
|
:members:
|
||||||
|
:exclude-members: session_bind, plugin_init, plugin_end
|
||||||
|
|
||||||
|
|
||||||
|
Stanza elements
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. automodule:: slixmpp.plugins.xep_0382.stanza
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
|
18
docs/api/plugins/xep_0385.rst
Normal file
18
docs/api/plugins/xep_0385.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
XEP-0385: Stateless Inline Media Sharing (SIMS)
|
||||||
|
===============================================
|
||||||
|
|
||||||
|
.. module:: slixmpp.plugins.xep_0385
|
||||||
|
|
||||||
|
.. autoclass:: XEP_0385
|
||||||
|
:members:
|
||||||
|
:exclude-members: session_bind, plugin_init, plugin_end
|
||||||
|
|
||||||
|
|
||||||
|
Stanza elements
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. automodule:: slixmpp.plugins.xep_0385.stanza
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
|
18
docs/api/plugins/xep_0402.rst
Normal file
18
docs/api/plugins/xep_0402.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
XEP-0402: PEP Native Bookmarks
|
||||||
|
==============================
|
||||||
|
|
||||||
|
.. module:: slixmpp.plugins.xep_0402
|
||||||
|
|
||||||
|
.. autoclass:: XEP_0402
|
||||||
|
:members:
|
||||||
|
:exclude-members: session_bind, plugin_init, plugin_end
|
||||||
|
|
||||||
|
|
||||||
|
Stanza elements
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. automodule:: slixmpp.plugins.xep_0402.stanza
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
|
18
docs/api/plugins/xep_0446.rst
Normal file
18
docs/api/plugins/xep_0446.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
XEP-0446: File metadata element
|
||||||
|
===============================
|
||||||
|
|
||||||
|
.. module:: slixmpp.plugins.xep_0446
|
||||||
|
|
||||||
|
.. autoclass:: XEP_0446
|
||||||
|
:members:
|
||||||
|
:exclude-members: session_bind, plugin_init, plugin_end
|
||||||
|
|
||||||
|
|
||||||
|
Stanza elements
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. automodule:: slixmpp.plugins.xep_0446.stanza
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
|
18
docs/api/plugins/xep_0447.rst
Normal file
18
docs/api/plugins/xep_0447.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
XEP-0447: Stateless File Sharing
|
||||||
|
================================
|
||||||
|
|
||||||
|
.. module:: slixmpp.plugins.xep_0447
|
||||||
|
|
||||||
|
.. autoclass:: XEP_0447
|
||||||
|
:members:
|
||||||
|
:exclude-members: session_bind, plugin_init, plugin_end
|
||||||
|
|
||||||
|
|
||||||
|
Stanza elements
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. automodule:: slixmpp.plugins.xep_0447.stanza
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
|
18
docs/api/plugins/xep_0461.rst
Normal file
18
docs/api/plugins/xep_0461.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
XEP-0461: Message Replies
|
||||||
|
=========================
|
||||||
|
|
||||||
|
.. module:: slixmpp.plugins.xep_0461
|
||||||
|
|
||||||
|
.. autoclass:: XEP_0461
|
||||||
|
:members:
|
||||||
|
:exclude-members: session_bind, plugin_init, plugin_end
|
||||||
|
|
||||||
|
|
||||||
|
Stanza elements
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. automodule:: slixmpp.plugins.xep_0461.stanza
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
|
17
docs/api/plugins/xep_0469.rst
Normal file
17
docs/api/plugins/xep_0469.rst
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
XEP-0469: Bookmark Pinning
|
||||||
|
==========================
|
||||||
|
|
||||||
|
.. module:: slixmpp.plugins.xep_0469
|
||||||
|
|
||||||
|
.. autoclass:: XEP_0469
|
||||||
|
:members:
|
||||||
|
:exclude-members: session_bind, plugin_init, plugin_end
|
||||||
|
|
||||||
|
|
||||||
|
Stanza elements
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. automodule:: slixmpp.plugins.xep_0469.stanza
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
|
18
docs/api/plugins/xep_0490.rst
Normal file
18
docs/api/plugins/xep_0490.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
XEP-0490: Message Displayed Synchronization
|
||||||
|
===========================================
|
||||||
|
|
||||||
|
.. module:: slixmpp.plugins.xep_0490
|
||||||
|
|
||||||
|
.. autoclass:: XEP_0490
|
||||||
|
:members:
|
||||||
|
:exclude-members: session_bind, plugin_init, plugin_end
|
||||||
|
|
||||||
|
|
||||||
|
Stanza elements
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. automodule:: slixmpp.plugins.xep_0490.stanza
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
|
18
docs/api/plugins/xep_0492.rst
Normal file
18
docs/api/plugins/xep_0492.rst
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
XEP-0492: Chat Notification Settings
|
||||||
|
====================================
|
||||||
|
|
||||||
|
.. module:: slixmpp.plugins.xep_0492
|
||||||
|
|
||||||
|
.. autoclass:: XEP_0492
|
||||||
|
:members:
|
||||||
|
:exclude-members: session_bind, plugin_init, plugin_end
|
||||||
|
|
||||||
|
|
||||||
|
Stanza elements
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. automodule:: slixmpp.plugins.xep_0492.stanza
|
||||||
|
:members:
|
||||||
|
:undoc-members:
|
||||||
|
|
@ -10,8 +10,8 @@ sendxmpp-py
|
|||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
sendxmpp is a command line program and is the XMPP equivalent of sendmail. It is a Python version of the original sendxmpp which is written in Perl.
|
sendxmpp is a command line program and is the XMPP equivalent of sendmail. It is a Python version of the original sendxmpp which is written in Perl.
|
||||||
|
|
||||||
- `Source <https://code.moparisthebest.com/moparisthebest/sendxmpp-py>`_
|
- `Source <https://code.moparisthebest.com/moparisthebest/sendxmpp-py>`__
|
||||||
- `Groupchat <xmpp:xmpp-ircd@chatrooms.hackerposse.com?join>`_
|
- `Groupchat <xmpp:xmpp-ircd@chatrooms.hackerposse.com?join>`__
|
||||||
|
|
||||||
Bots
|
Bots
|
||||||
----
|
----
|
||||||
@ -20,69 +20,65 @@ BotLogMauve
|
|||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
XMPP bot which logs groupchat messages. Logs are in text format, with one file per day and per groupchat.
|
XMPP bot which logs groupchat messages. Logs are in text format, with one file per day and per groupchat.
|
||||||
|
|
||||||
- `Source <https://git.khaganat.net/khaganat/BotLogMauve>`_
|
- `Source <https://git.khaganat.net/khaganat/BotLogMauve>`__
|
||||||
|
|
||||||
BukuBot
|
BukuBot
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
BukuBot makes it possible to manage and search your bookmarks from your chat.
|
BukuBot makes it possible to manage and search your bookmarks from your chat.
|
||||||
|
|
||||||
- `Source <https://codeberg.org/sch/BukuBot>`_
|
- `Source <https://codeberg.org/sch/BukuBot>`__
|
||||||
|
|
||||||
LinkBot
|
LinkBot
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
This bot reveals the title of any shared link in a groupchat for quick content insight.
|
This bot reveals the title of any shared link in a groupchat for quick content insight.
|
||||||
|
|
||||||
- `Source <https://git.xmpp-it.net/mario/XMPPBot>`_
|
- `Source <https://git.xmpp-it.net/mario/XMPPBot>`__
|
||||||
|
|
||||||
llama-bot
|
llama-bot
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
Llama-bot enables engaging communication with the LLM (large language model) of llama.cpp, providing seamless and dynamic conversation with it.
|
Llama-bot enables engaging communication with the LLM (large language model) of llama.cpp, providing seamless and dynamic conversation with it.
|
||||||
|
|
||||||
- `Groupchat <xmpp:slixmpp@muc.poez.io?join>`_
|
- `Source <https://github.com/decent-im/llama-bot>`__
|
||||||
- `Source <https://github.com/decent-im/llama-bot>`_
|
- `Demo <xmpp:llama@decent.im?message>`__
|
||||||
- `Demo <xmpp:llama@decent.im?message>`_
|
|
||||||
|
|
||||||
Morbot
|
Morbot
|
||||||
~~~~~~
|
~~~~~~
|
||||||
Morbot is a simple Slixmpp bot that will take new articles from listed RSS feeds and send them to assigned XMPP MUCs.
|
Morbot is a simple Slixmpp bot that will take new articles from listed RSS feeds and send them to assigned XMPP MUCs.
|
||||||
|
|
||||||
- `Groupchat <xmpp:slixmpp@muc.poez.io?join>`_
|
- `Source <https://codeberg.org/TheCoffeMaker/Morbot>`__
|
||||||
- `Source <https://codeberg.org/TheCoffeMaker/Morbot>`_
|
|
||||||
|
|
||||||
Slixfeed
|
Slixfeed
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
Slixfeed aims to be an easy to use and fully-featured news aggregator bot for XMPP. It provides a convenient access to Blogs, Fediverse and News websites along with filtering functionality.
|
Slixfeed aims to be an easy to use and fully-featured news aggregator bot for XMPP. It provides a convenient access to Blogs, Fediverse and News websites along with filtering functionality.
|
||||||
|
|
||||||
- `Groupchat <xmpp:slixfeed@chat.woodpeckersnest.space?join>`_
|
- `Groupchat <xmpp:slixfeed@chat.woodpeckersnest.space?join>`__
|
||||||
- `Source <https://gitgud.io/sjehuda/slixfeed>`_
|
- `Source <https://gitgud.io/sjehuda/slixfeed>`__
|
||||||
|
|
||||||
sms4you
|
sms4you
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
sms4you forwards messages from and to SMS and connects either with sms4you-xmpp or sms4you-email to choose the other mean of communication. Nice for receiving or sending SMS, independently from carrying a SIM card.
|
sms4you forwards messages from and to SMS and connects either with sms4you-xmpp or sms4you-email to choose the other mean of communication. Nice for receiving or sending SMS, independently from carrying a SIM card.
|
||||||
|
|
||||||
- `Groupchat <xmpp:slixmpp@muc.poez.io?join>`_
|
- `Homepage <https://sms4you-team.pages.debian.net/sms4you/>`__
|
||||||
- `Homepage <https://sms4you-team.pages.debian.net/sms4you/>`_
|
- `Source <https://salsa.debian.org/sms4you-team/sms4you>`__
|
||||||
- `Source <https://salsa.debian.org/sms4you-team/sms4you>`_
|
|
||||||
|
|
||||||
Stable Diffusion
|
Stable Diffusion
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
XMPP bot that generates digital images from textual descriptions.
|
XMPP bot that generates digital images from textual descriptions.
|
||||||
|
|
||||||
- `Groupchat <xmpp:slidge@conference.nicoco.fr?join>`_
|
- `Groupchat <xmpp:slidge@conference.nicoco.fr?join>`__
|
||||||
- `Source <https://www.nicoco.fr/blog/2022/08/31/xmpp-bot-stable-diffusion/>`_
|
- `Source <https://www.nicoco.fr/blog/2022/08/31/xmpp-bot-stable-diffusion/>`__
|
||||||
|
|
||||||
WhisperBot
|
WhisperBot
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
XMPP bot that transliterates audio messages using OpenAI's Whisper libraries.
|
XMPP bot that transliterates audio messages using OpenAI's Whisper libraries.
|
||||||
|
|
||||||
- `Groupchat <xmpp:slixmpp@muc.poez.io?join>`_
|
- `Source <https://codeberg.org/TheCoffeMaker/WhisperBot>`__
|
||||||
- `Source <https://codeberg.org/TheCoffeMaker/WhisperBot>`_
|
|
||||||
|
|
||||||
XMPP MUC Message Gateway
|
XMPP MUC Message Gateway
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
A multipurpose JSON forwarder microservice from HTTP POST to XMPP MUC room over TLSv1.2 with SliXMPP.
|
A multipurpose JSON forwarder microservice from HTTP POST to XMPP MUC room over TLSv1.2 with SliXMPP.
|
||||||
|
|
||||||
- `Source <https://github.com/immanuelfodor/xmpp-muc-message-gateway>`_
|
- `Source <https://github.com/immanuelfodor/xmpp-muc-message-gateway>`__
|
||||||
|
|
||||||
Services
|
Services
|
||||||
--------
|
--------
|
||||||
@ -91,14 +87,14 @@ AtomToPubsub
|
|||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
AtomToPubsub is a simple Python script that parses Atom + RSS feeds and pushes the entries to a designated XMPP Pubsub Node.
|
AtomToPubsub is a simple Python script that parses Atom + RSS feeds and pushes the entries to a designated XMPP Pubsub Node.
|
||||||
|
|
||||||
- `Groupchat <xmpp:movim@conference.movim.eu?join>`_
|
- `Groupchat <xmpp:movim@conference.movim.eu?join>`__
|
||||||
- `Source <https://github.com/imattau/atomtopubsub>`_
|
- `Source <https://github.com/imattau/atomtopubsub>`__
|
||||||
|
|
||||||
Slidge
|
Slidge
|
||||||
~~~~~~
|
~~~~~~
|
||||||
|
|
||||||
Slidge is a general purpose XMPP gateway framework in Python.
|
Slidge is a general purpose XMPP gateway framework in Python.
|
||||||
|
|
||||||
- `Groupchat <xmpp:slidge@conference.nicoco.fr?join>`_
|
- `Groupchat <xmpp:slidge@conference.nicoco.fr?join>`__
|
||||||
- `Homepage <https://slidge.im/core/>`_
|
- `Homepage <https://slidge.im/core/>`__
|
||||||
- `Source <https://sr.ht/~nicoco/slidge>`_
|
- `Source <https://sr.ht/~nicoco/slidge>`__
|
||||||
|
@ -50,10 +50,39 @@ Running the event loop
|
|||||||
only run for this amount of time, and if ``forever`` is False it will
|
only run for this amount of time, and if ``forever`` is False it will
|
||||||
run until disconnection).
|
run until disconnection).
|
||||||
|
|
||||||
|
This wrapper should be removed in slixmpp 1.9.0.
|
||||||
|
|
||||||
Therefore you can handle the event loop in any way you like
|
Therefore you can handle the event loop in any way you like
|
||||||
instead of using ``process()``.
|
instead of using ``process()``.
|
||||||
|
|
||||||
|
|
||||||
|
Using connect()
|
||||||
|
~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
:meth:`.XMLStream.connect` schedules a lot of things in the background, but that
|
||||||
|
only holds true if the event loop is running!
|
||||||
|
|
||||||
|
That is why in all examples we usually call connect() right before calling
|
||||||
|
a `loop.run_…` function, or the deprecated `process()` function.
|
||||||
|
|
||||||
|
Using a different event loop
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
Immediately upon XMPP object creation (`ClientXMPP` / `ComponentXMPP`) you
|
||||||
|
should sets its `loop` attribute to whatever you want, and ideally this
|
||||||
|
should work. This path is less tested, so it may break, if that is the case
|
||||||
|
please report a bug.
|
||||||
|
|
||||||
|
Any access to the `loop` attribute if not user-initialized will set it
|
||||||
|
to the default asyncio event loop by default.
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
|
||||||
|
If the loop attribute is modified at runtime, the application will probably
|
||||||
|
end up in an hybrid state and asyncio may complain loudly that things bound
|
||||||
|
to an event loop are being ran in another. Try to avoid that situation.
|
||||||
|
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
|
|
||||||
@ -73,10 +102,11 @@ callbacks while everything is not ready.
|
|||||||
callback = lambda _: client.connected_event.set()
|
callback = lambda _: client.connected_event.set()
|
||||||
client.add_event_handler('session_start', callback)
|
client.add_event_handler('session_start', callback)
|
||||||
client.connect()
|
client.connect()
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
loop.run_until_complete(event.wait())
|
loop.run_until_complete(event.wait())
|
||||||
# do some other stuff before running the event loop, e.g.
|
# do some other stuff before running the event loop, e.g.
|
||||||
# loop.run_until_complete(httpserver.init())
|
# loop.run_until_complete(httpserver.init())
|
||||||
client.process()
|
loop.run_forever()
|
||||||
|
|
||||||
|
|
||||||
Use with other asyncio-based libraries
|
Use with other asyncio-based libraries
|
||||||
@ -106,7 +136,7 @@ a simple <message>.
|
|||||||
client.add_event_handler('session_start', get_pythonorg)
|
client.add_event_handler('session_start', get_pythonorg)
|
||||||
client.add_event_handler('session_start', get_asyncioorg)
|
client.add_event_handler('session_start', get_asyncioorg)
|
||||||
client.connect()
|
client.connect()
|
||||||
client.process()
|
client.loop.run_until_complete(client.disconnected)
|
||||||
|
|
||||||
|
|
||||||
Blocking Iq
|
Blocking Iq
|
||||||
@ -136,6 +166,6 @@ JID indicating its findings.
|
|||||||
|
|
||||||
client = ExampleClient('jid@example', 'password')
|
client = ExampleClient('jid@example', 'password')
|
||||||
client.connect()
|
client.connect()
|
||||||
client.process()
|
client.loop.run_until_complete(client.disconnected)
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ class TestRetract(SlixIntegration):
|
|||||||
fallback_text='Twas a mistake',
|
fallback_text='Twas a mistake',
|
||||||
)
|
)
|
||||||
msg = await self.clients[1].wait_until('message_retract')
|
msg = await self.clients[1].wait_until('message_retract')
|
||||||
self.assertEqual(msg['apply_to']['id'], 'toto')
|
self.assertEqual(msg['retract']['id'], 'toto')
|
||||||
self.assertTrue(msg['apply_to']['retract'])
|
|
||||||
|
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(TestRetract)
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestRetract)
|
||||||
|
@ -315,13 +315,12 @@ class BaseXMPP(XMLStream):
|
|||||||
pres['lang'] = self.default_lang
|
pres['lang'] = self.default_lang
|
||||||
return pres
|
return pres
|
||||||
|
|
||||||
def make_iq(self, id: str = "0", ifrom: OptJidStr = None,
|
def make_iq(self, id: Optional[str] = None, ifrom: OptJidStr = None,
|
||||||
ito: OptJidStr = None, itype: Optional[IqTypes] = None,
|
ito: OptJidStr = None, itype: Optional[IqTypes] = None,
|
||||||
iquery: Optional[str] = None) -> stanza.Iq:
|
iquery: Optional[str] = None) -> stanza.Iq:
|
||||||
"""Create a new :class:`~.Iq` stanza with a given Id and from JID.
|
"""Create a new :class:`~.Iq` stanza with a given Id and from JID.
|
||||||
|
|
||||||
:param id: An ideally unique ID value for this stanza thread.
|
:param id: An ideally unique ID value for this stanza thread.
|
||||||
Defaults to 0.
|
|
||||||
:param ifrom: The from :class:`~.JID`
|
:param ifrom: The from :class:`~.JID`
|
||||||
to use for this stanza.
|
to use for this stanza.
|
||||||
:param ito: The destination :class:`~.JID`
|
:param ito: The destination :class:`~.JID`
|
||||||
@ -332,7 +331,8 @@ class BaseXMPP(XMLStream):
|
|||||||
:param iquery: Optional namespace for adding a query element.
|
:param iquery: Optional namespace for adding a query element.
|
||||||
"""
|
"""
|
||||||
iq = self.Iq()
|
iq = self.Iq()
|
||||||
iq['id'] = str(id)
|
if id is not None:
|
||||||
|
iq['id'] = str(id)
|
||||||
iq['to'] = ito
|
iq['to'] = ito
|
||||||
iq['from'] = ifrom
|
iq['from'] = ifrom
|
||||||
iq['type'] = itype
|
iq['type'] = itype
|
||||||
|
@ -139,7 +139,7 @@ class ClientXMPP(BaseXMPP):
|
|||||||
|
|
||||||
def connect(self, address: Optional[Tuple[str, int]] = None, # type: ignore
|
def connect(self, address: Optional[Tuple[str, int]] = None, # type: ignore
|
||||||
use_ssl: Optional[bool] = None, force_starttls: Optional[bool] = None,
|
use_ssl: Optional[bool] = None, force_starttls: Optional[bool] = None,
|
||||||
disable_starttls: Optional[bool] = None) -> None:
|
disable_starttls: Optional[bool] = None) -> asyncio.Future:
|
||||||
"""Connect to the XMPP server.
|
"""Connect to the XMPP server.
|
||||||
|
|
||||||
When no address is given, a SRV lookup for the server will
|
When no address is given, a SRV lookup for the server will
|
||||||
@ -166,8 +166,9 @@ class ClientXMPP(BaseXMPP):
|
|||||||
host, port = (self.boundjid.host, 5222)
|
host, port = (self.boundjid.host, 5222)
|
||||||
self.dns_service = 'xmpp-client'
|
self.dns_service = 'xmpp-client'
|
||||||
|
|
||||||
XMLStream.connect(self, host, port, use_ssl=use_ssl,
|
return XMLStream.connect(self, host, port, use_ssl=use_ssl,
|
||||||
force_starttls=force_starttls, disable_starttls=disable_starttls)
|
force_starttls=force_starttls,
|
||||||
|
disable_starttls=disable_starttls)
|
||||||
|
|
||||||
def register_feature(self, name: str, handler: Callable, restart: bool = False, order: int = 5000) -> None:
|
def register_feature(self, name: str, handler: Callable, restart: bool = False, order: int = 5000) -> None:
|
||||||
"""Register a stream feature handler.
|
"""Register a stream feature handler.
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
|
from asyncio import Future
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from slixmpp import Message, Iq, Presence
|
from slixmpp import Message, Iq, Presence
|
||||||
@ -97,7 +98,7 @@ class ComponentXMPP(BaseXMPP):
|
|||||||
|
|
||||||
def connect(self, host: Optional[str] = None, port: int = 0, use_ssl: Optional[bool] = None,
|
def connect(self, host: Optional[str] = None, port: int = 0, use_ssl: Optional[bool] = None,
|
||||||
force_starttls: Optional[bool] = None,
|
force_starttls: Optional[bool] = None,
|
||||||
disable_starttls: Optional[bool] = None) -> None:
|
disable_starttls: Optional[bool] = None) -> Future:
|
||||||
"""Connect to the server.
|
"""Connect to the server.
|
||||||
|
|
||||||
|
|
||||||
@ -118,7 +119,7 @@ class ComponentXMPP(BaseXMPP):
|
|||||||
self.server_name = self.boundjid.host
|
self.server_name = self.boundjid.host
|
||||||
|
|
||||||
log.debug("Connecting to %s:%s", host, port)
|
log.debug("Connecting to %s:%s", host, port)
|
||||||
XMLStream.connect(self, host=self.server_host, port=self.server_port, use_ssl=use_ssl)
|
return XMLStream.connect(self, host=self.server_host, port=self.server_port, use_ssl=use_ssl)
|
||||||
|
|
||||||
def incoming_filter(self, xml):
|
def incoming_filter(self, xml):
|
||||||
"""
|
"""
|
||||||
|
@ -135,6 +135,7 @@ _DEFAULT_ERROR_TYPES: Dict[ErrorConditions, ErrorTypes] = {
|
|||||||
"not-allowed": "cancel",
|
"not-allowed": "cancel",
|
||||||
"not-authorized": "auth",
|
"not-authorized": "auth",
|
||||||
"payment-required": "auth",
|
"payment-required": "auth",
|
||||||
|
"policy-violation": "modify",
|
||||||
"recipient-unavailable": "wait",
|
"recipient-unavailable": "wait",
|
||||||
"redirect": "modify",
|
"redirect": "modify",
|
||||||
"registration-required": "auth",
|
"registration-required": "auth",
|
||||||
|
@ -118,10 +118,13 @@ PLUGINS = [
|
|||||||
'xep_0439', # Quick Response
|
'xep_0439', # Quick Response
|
||||||
'xep_0441', # Message Archive Management Preferences
|
'xep_0441', # Message Archive Management Preferences
|
||||||
'xep_0444', # Message Reactions
|
'xep_0444', # Message Reactions
|
||||||
|
'xep_0446', # File metadata element
|
||||||
'xep_0447', # Stateless file sharing
|
'xep_0447', # Stateless file sharing
|
||||||
'xep_0461', # Message Replies
|
'xep_0461', # Message Replies
|
||||||
'xep_0469', # Bookmarks Pinning
|
'xep_0469', # Bookmarks Pinning
|
||||||
|
'xep_0482', # Call Invites
|
||||||
'xep_0490', # Message Displayed Synchronization
|
'xep_0490', # Message Displayed Synchronization
|
||||||
|
'xep_0492', # Chat Notification Settings
|
||||||
# Meant to be imported by plugins
|
# Meant to be imported by plugins
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
|
||||||
# Slixmpp: The Slick XMPP Library
|
# Slixmpp: The Slick XMPP Library
|
||||||
# Copyright (C) 2011 Nathanael C. Fritz, Lance J.T. Stout
|
# Copyright (C) 2011 Nathanael C. Fritz, Lance J.T. Stout
|
||||||
# This file is part of Slixmpp.
|
# This file is part of Slixmpp.
|
||||||
# See the file LICENSE for copying permission.
|
# See the file LICENSE for copying permission.
|
||||||
|
import logging
|
||||||
|
|
||||||
from slixmpp.xmlstream import ElementBase, ET
|
from slixmpp.xmlstream import ElementBase, ET
|
||||||
|
|
||||||
|
|
||||||
@ -78,7 +79,14 @@ class FormField(ElementBase):
|
|||||||
reqXML = self.xml.find('{%s}required' % self.namespace)
|
reqXML = self.xml.find('{%s}required' % self.namespace)
|
||||||
return reqXML is not None
|
return reqXML is not None
|
||||||
|
|
||||||
def get_value(self, convert=True):
|
def get_value(self, convert=True, convert_list=False):
|
||||||
|
"""
|
||||||
|
Gets the value for this field
|
||||||
|
|
||||||
|
:param convert: Convert truthy values to boolean
|
||||||
|
:param convert_list: Convert text-multi fields to a string with
|
||||||
|
\n as separator for values
|
||||||
|
"""
|
||||||
valsXML = self.xml.findall('{%s}value' % self.namespace)
|
valsXML = self.xml.findall('{%s}value' % self.namespace)
|
||||||
if len(valsXML) == 0:
|
if len(valsXML) == 0:
|
||||||
return None
|
return None
|
||||||
@ -92,7 +100,7 @@ class FormField(ElementBase):
|
|||||||
if valXML.text is None:
|
if valXML.text is None:
|
||||||
valXML.text = ''
|
valXML.text = ''
|
||||||
values.append(valXML.text)
|
values.append(valXML.text)
|
||||||
if self._type == 'text-multi' and convert:
|
if self._type == 'text-multi' and convert_list:
|
||||||
values = "\n".join(values)
|
values = "\n".join(values)
|
||||||
return values
|
return values
|
||||||
else:
|
else:
|
||||||
@ -127,6 +135,17 @@ class FormField(ElementBase):
|
|||||||
del self['value']
|
del self['value']
|
||||||
valXMLName = '{%s}value' % self.namespace
|
valXMLName = '{%s}value' % self.namespace
|
||||||
|
|
||||||
|
if not self._type:
|
||||||
|
if isinstance(value, bool):
|
||||||
|
log.debug("Passed a 'boolean' as value of an untyped field, assuming it is a 'boolean'")
|
||||||
|
self._type = "boolean"
|
||||||
|
elif isinstance(value, str):
|
||||||
|
log.debug("Passed a 'str' as value of an untyped field, assuming it is a 'text-single'")
|
||||||
|
self._type = "text-single"
|
||||||
|
elif isinstance(value, (list, tuple)):
|
||||||
|
log.debug("Passed a %s as value of an untyped field, assuming it is a 'text-multi'")
|
||||||
|
self._type = "text-multi"
|
||||||
|
|
||||||
if self._type == 'boolean':
|
if self._type == 'boolean':
|
||||||
if value in self.true_values:
|
if value in self.true_values:
|
||||||
valXML = ET.Element(valXMLName)
|
valXML = ET.Element(valXMLName)
|
||||||
@ -180,3 +199,6 @@ FormField.setOptions = FormField.set_options
|
|||||||
FormField.setRequired = FormField.set_required
|
FormField.setRequired = FormField.set_required
|
||||||
FormField.setTrue = FormField.set_true
|
FormField.setTrue = FormField.set_true
|
||||||
FormField.setValue = FormField.set_value
|
FormField.setValue = FormField.set_value
|
||||||
|
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
@ -162,7 +162,7 @@ class XEP_0009(BasePlugin):
|
|||||||
if not forwarded and self.xmpp.event_handled('jabber_rpc_method_call') > 1:
|
if not forwarded and self.xmpp.event_handled('jabber_rpc_method_call') > 1:
|
||||||
return
|
return
|
||||||
# Reply with error by default
|
# Reply with error by default
|
||||||
error = self.client.plugin['xep_0009']._item_not_found(iq)
|
error = self.xmpp.plugin['xep_0009']._item_not_found(iq)
|
||||||
error.send()
|
error.send()
|
||||||
|
|
||||||
def _on_jabber_rpc_method_response(self, iq, forwarded=False):
|
def _on_jabber_rpc_method_response(self, iq, forwarded=False):
|
||||||
@ -175,7 +175,7 @@ class XEP_0009(BasePlugin):
|
|||||||
"""
|
"""
|
||||||
if not forwarded and self.xmpp.event_handled('jabber_rpc_method_response') > 1:
|
if not forwarded and self.xmpp.event_handled('jabber_rpc_method_response') > 1:
|
||||||
return
|
return
|
||||||
error = self.client.plugin['xep_0009']._recpient_unavailable(iq)
|
error = self.xmpp.plugin['xep_0009']._recipient_unvailable(iq)
|
||||||
error.send()
|
error.send()
|
||||||
|
|
||||||
def _on_jabber_rpc_method_fault(self, iq, forwarded=False):
|
def _on_jabber_rpc_method_fault(self, iq, forwarded=False):
|
||||||
@ -188,7 +188,7 @@ class XEP_0009(BasePlugin):
|
|||||||
"""
|
"""
|
||||||
if not forwarded and self.xmpp.event_handled('jabber_rpc_method_fault') > 1:
|
if not forwarded and self.xmpp.event_handled('jabber_rpc_method_fault') > 1:
|
||||||
return
|
return
|
||||||
error = self.client.plugin['xep_0009']._recpient_unavailable(iq)
|
error = self.xmpp.plugin['xep_0009']._recipient_unvailable(iq)
|
||||||
error.send()
|
error.send()
|
||||||
|
|
||||||
def _on_jabber_rpc_error(self, iq, forwarded=False):
|
def _on_jabber_rpc_error(self, iq, forwarded=False):
|
||||||
@ -201,7 +201,7 @@ class XEP_0009(BasePlugin):
|
|||||||
"""
|
"""
|
||||||
if not forwarded and self.xmpp.event_handled('jabber_rpc_error') > 1:
|
if not forwarded and self.xmpp.event_handled('jabber_rpc_error') > 1:
|
||||||
return
|
return
|
||||||
error = self.client.plugin['xep_0009']._recpient_unavailable(iq, iq.get_payload())
|
error = self.xmpp.plugin['xep_0009']._recipient_unvailable(iq)
|
||||||
error.send()
|
error.send()
|
||||||
|
|
||||||
def _send_fault(self, iq, fault_xml): #
|
def _send_fault(self, iq, fault_xml): #
|
||||||
|
@ -57,6 +57,9 @@ class XEP_0030(BasePlugin):
|
|||||||
Given Given A single node
|
Given Given A single node
|
||||||
====== ======= ============================
|
====== ======= ============================
|
||||||
|
|
||||||
|
Adding information for a given node without specifying the JID will
|
||||||
|
use the bound JID and therefore must be done after the bind happens.
|
||||||
|
|
||||||
Stream Handlers:
|
Stream Handlers:
|
||||||
|
|
||||||
::
|
::
|
||||||
|
@ -9,6 +9,7 @@ from typing import (
|
|||||||
Set,
|
Set,
|
||||||
Tuple,
|
Tuple,
|
||||||
Union,
|
Union,
|
||||||
|
Dict,
|
||||||
)
|
)
|
||||||
from slixmpp.xmlstream import ElementBase, ET
|
from slixmpp.xmlstream import ElementBase, ET
|
||||||
|
|
||||||
@ -144,6 +145,25 @@ class DiscoInfo(ElementBase):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def dict_identities(self, lang: Optional[str] = None) -> Set[Dict[str, str]]:
|
||||||
|
"""
|
||||||
|
Return the set of all identities, each one as a dict with
|
||||||
|
category, type, xml_lang, and name keys.
|
||||||
|
|
||||||
|
:param lang: If there is a need to filter identities by lang.
|
||||||
|
"""
|
||||||
|
ids = self.get_identities(lang=lang, dedupe=True)
|
||||||
|
dict_ids = set()
|
||||||
|
for identity in ids:
|
||||||
|
dict_ids.add({
|
||||||
|
'category': identity[0],
|
||||||
|
'type': identity[1],
|
||||||
|
'xml_lang': identity[2],
|
||||||
|
'name': identity[3],
|
||||||
|
})
|
||||||
|
return dict_ids
|
||||||
|
|
||||||
|
|
||||||
def get_identities(self, lang: Optional[str] = None, dedupe: bool = True
|
def get_identities(self, lang: Optional[str] = None, dedupe: bool = True
|
||||||
) -> Iterable[IdentityType]:
|
) -> Iterable[IdentityType]:
|
||||||
"""
|
"""
|
||||||
|
@ -326,7 +326,10 @@ class XEP_0050(BasePlugin):
|
|||||||
iq['command']['actions'] = actions
|
iq['command']['actions'] = actions
|
||||||
iq['command']['status'] = 'executing'
|
iq['command']['status'] = 'executing'
|
||||||
else:
|
else:
|
||||||
iq['command']['actions'] = ['complete']
|
actions = ['complete']
|
||||||
|
if session['allow_prev']:
|
||||||
|
actions.append('prev')
|
||||||
|
iq['command']['actions'] = actions
|
||||||
iq['command']['status'] = 'executing'
|
iq['command']['status'] = 'executing'
|
||||||
|
|
||||||
iq['command']['notes'] = session['notes']
|
iq['command']['notes'] = session['notes']
|
||||||
|
@ -464,10 +464,10 @@ class XEP_0060(BasePlugin):
|
|||||||
"""
|
"""
|
||||||
Retrieve the ItemIDs hosted by a given node, using disco.
|
Retrieve the ItemIDs hosted by a given node, using disco.
|
||||||
"""
|
"""
|
||||||
self.xmpp['xep_0030'].get_items(jid, node, ifrom=ifrom,
|
return self.xmpp['xep_0030'].get_items(jid, node, ifrom=ifrom,
|
||||||
callback=callback, timeout=timeout,
|
callback=callback, timeout=timeout,
|
||||||
iterator=iterator,
|
iterator=iterator,
|
||||||
timeout_callback=timeout_callback)
|
timeout_callback=timeout_callback)
|
||||||
|
|
||||||
def modify_affiliations(self, jid, node, affiliations=None, ifrom=None,
|
def modify_affiliations(self, jid, node, affiliations=None, ifrom=None,
|
||||||
timeout_callback=None, callback=None,
|
timeout_callback=None, callback=None,
|
||||||
|
@ -48,8 +48,12 @@ class XEP_0223(BasePlugin):
|
|||||||
|
|
||||||
:param node: Node to set the configuration at.
|
:param node: Node to set the configuration at.
|
||||||
"""
|
"""
|
||||||
config = self.xmpp['xep_0004'].Form()
|
config = self.xmpp['xep_0004'].stanza.Form()
|
||||||
config['type'] = 'submit'
|
config['type'] = 'submit'
|
||||||
|
config.add_field(
|
||||||
|
var='FORM_TYPE',
|
||||||
|
ftype='hidden',
|
||||||
|
value='http://jabber.org/protocol/pubsub#node_config')
|
||||||
|
|
||||||
for field, value in self.profile.items():
|
for field, value in self.profile.items():
|
||||||
config.add_field(var=field, value=value)
|
config.add_field(var=field, value=value)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from slixmpp.plugins.base import register_plugin
|
from slixmpp.plugins.base import register_plugin
|
||||||
|
|
||||||
from . import stanza, vcard4
|
from . import stanza, vcard4
|
||||||
|
from .vcard4 import XEP_0292
|
||||||
|
|
||||||
register_plugin(vcard4.XEP_0292)
|
register_plugin(vcard4.XEP_0292)
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
|
|
||||||
# Slixmpp: The Slick XMPP Library
|
# Slixmpp: The Slick XMPP Library
|
||||||
# Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout
|
# Copyright (C) 2012 Nathanael C. Fritz, Lance J.T. Stout
|
||||||
# This file is part of Slixmpp.
|
# This file is part of Slixmpp.
|
||||||
# See the file LICENSE for copying permissio
|
# See the file LICENSE for copying permissio
|
||||||
import logging
|
import logging
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from slixmpp.stanza import Message
|
from slixmpp.stanza import Message
|
||||||
|
from slixmpp.jid import JID
|
||||||
from slixmpp.xmlstream.handler import Callback
|
from slixmpp.xmlstream.handler import Callback
|
||||||
from slixmpp.xmlstream.matcher import StanzaPath
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
from slixmpp.xmlstream import register_stanza_plugin
|
from slixmpp.xmlstream import register_stanza_plugin
|
||||||
@ -49,3 +50,54 @@ class XEP_0308(BasePlugin):
|
|||||||
|
|
||||||
def _handle_correction(self, msg: Message):
|
def _handle_correction(self, msg: Message):
|
||||||
self.xmpp.event('message_correction', msg)
|
self.xmpp.event('message_correction', msg)
|
||||||
|
|
||||||
|
def build_correction(self, id_to_replace: str, mto: JID,
|
||||||
|
mfrom: Optional[JID] = None, mtype: str = 'chat',
|
||||||
|
mbody: str = '') -> Message:
|
||||||
|
"""
|
||||||
|
Build a corrected message.
|
||||||
|
|
||||||
|
:param id_to_replace: The id of the original message.
|
||||||
|
:param mto: Recipient of the message, must be the same as the original
|
||||||
|
message.
|
||||||
|
:param mfrom: Sender of the message, must be the same as the original
|
||||||
|
message.
|
||||||
|
:param mtype: Type of the message, must be the send as the original
|
||||||
|
message.
|
||||||
|
:param mbody: The corrected message body.
|
||||||
|
"""
|
||||||
|
msg = self.xmpp.make_message(
|
||||||
|
mto=mto,
|
||||||
|
mfrom=mfrom,
|
||||||
|
mbody=mbody,
|
||||||
|
mtype=mtype
|
||||||
|
)
|
||||||
|
msg['replace']['id'] = id_to_replace
|
||||||
|
return msg
|
||||||
|
|
||||||
|
def correct_message(self, msg: Message, body: str) -> Message:
|
||||||
|
"""
|
||||||
|
Send a correction to an existing message.
|
||||||
|
|
||||||
|
:param msg: The message that must be replaced.
|
||||||
|
:param body: The body to set in the correcting message.
|
||||||
|
:returns: The message that was sent.
|
||||||
|
"""
|
||||||
|
to_replace = msg['id']
|
||||||
|
mto = msg['to']
|
||||||
|
mfrom = msg['from']
|
||||||
|
mtype = msg['type']
|
||||||
|
if not to_replace:
|
||||||
|
raise ValueError('No available ID for replacing the message')
|
||||||
|
if not mto:
|
||||||
|
raise ValueError('No available recipient JID')
|
||||||
|
|
||||||
|
new = self.build_correction(
|
||||||
|
id_to_replace=to_replace,
|
||||||
|
mto=mto,
|
||||||
|
mfrom=mfrom,
|
||||||
|
mtype=mtype,
|
||||||
|
mbody=body,
|
||||||
|
)
|
||||||
|
new.send()
|
||||||
|
return new
|
||||||
|
@ -138,10 +138,10 @@ class XEP_0356(BasePlugin):
|
|||||||
|
|
||||||
Raises ValueError if the server did not advertise the corresponding privileges
|
Raises ValueError if the server did not advertise the corresponding privileges
|
||||||
|
|
||||||
:param jid: user we want to add or modify roster items
|
Here is an example of a roster_items value:
|
||||||
:param roster_items: a dict containing the roster items' JIDs as keys and
|
|
||||||
nested dicts containing names, subscriptions and groups.
|
.. code-block:: json
|
||||||
Example:
|
|
||||||
{
|
{
|
||||||
"friend1@example.com": {
|
"friend1@example.com": {
|
||||||
"name": "Friend 1",
|
"name": "Friend 1",
|
||||||
@ -152,8 +152,13 @@ class XEP_0356(BasePlugin):
|
|||||||
"name": "Friend 2",
|
"name": "Friend 2",
|
||||||
"subscription": "from",
|
"subscription": "from",
|
||||||
"groups": ["group3"],
|
"groups": ["group3"],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:param jid: user we want to add or modify roster items
|
||||||
|
:param roster_items: a dict containing the roster items' JIDs as keys and
|
||||||
|
nested dicts containing names, subscriptions and groups.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if isinstance(jid, str):
|
if isinstance(jid, str):
|
||||||
jid = JID(jid)
|
jid = JID(jid)
|
||||||
|
@ -19,7 +19,7 @@ class Moderate(ElementBase):
|
|||||||
namespace = NS
|
namespace = NS
|
||||||
name = 'moderate'
|
name = 'moderate'
|
||||||
plugin_attrib = 'moderate'
|
plugin_attrib = 'moderate'
|
||||||
interfaces = {'reason'}
|
interfaces = {'id', 'reason'}
|
||||||
sub_interfaces = {'reason'}
|
sub_interfaces = {'reason'}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,3 +18,7 @@ class XEP_0446(BasePlugin):
|
|||||||
name = "xep_0446"
|
name = "xep_0446"
|
||||||
description = "XEP-0446: File metadata element"
|
description = "XEP-0446: File metadata element"
|
||||||
stanza = stanza
|
stanza = stanza
|
||||||
|
dependencies = {'xep_0300', 'xep_0264'}
|
||||||
|
|
||||||
|
def plugin_init(self):
|
||||||
|
stanza.register_plugins()
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
from slixmpp.plugins.xep_0082 import format_datetime, parse
|
from slixmpp.plugins.xep_0082 import format_datetime, parse
|
||||||
from slixmpp.xmlstream import ElementBase
|
from slixmpp.plugins.xep_0300 import Hash
|
||||||
|
from slixmpp.plugins.xep_0264.stanza import Thumbnail
|
||||||
|
from slixmpp.xmlstream import ElementBase, register_stanza_plugin
|
||||||
|
|
||||||
NS = "urn:xmpp:file:metadata:0"
|
NS = "urn:xmpp:file:metadata:0"
|
||||||
|
|
||||||
@ -10,15 +13,42 @@ class File(ElementBase):
|
|||||||
name = "file"
|
name = "file"
|
||||||
namespace = NS
|
namespace = NS
|
||||||
plugin_attrib = "file"
|
plugin_attrib = "file"
|
||||||
interfaces = sub_interfaces = {"media-type", "name", "date", "size", "hash", "desc"}
|
interfaces = sub_interfaces = {
|
||||||
|
"media-type",
|
||||||
|
"name",
|
||||||
|
"date",
|
||||||
|
"size",
|
||||||
|
"desc",
|
||||||
|
"width",
|
||||||
|
"height",
|
||||||
|
"length"
|
||||||
|
}
|
||||||
|
|
||||||
|
def set_width(self, width: int):
|
||||||
|
self.__set_if_positive("width", width)
|
||||||
|
|
||||||
|
def get_width(self) -> Optional[int]:
|
||||||
|
return _positive_int_or_none(self._get_sub_text("width"))
|
||||||
|
|
||||||
|
def set_height(self, height: int):
|
||||||
|
self.__set_if_positive("height", height)
|
||||||
|
|
||||||
|
def get_height(self) -> Optional[int]:
|
||||||
|
return _positive_int_or_none(self._get_sub_text("height"))
|
||||||
|
|
||||||
|
def set_length(self, length: int):
|
||||||
|
self.__set_if_positive("length", length)
|
||||||
|
|
||||||
|
def get_length(self) -> Optional[int]:
|
||||||
|
return _positive_int_or_none(self._get_sub_text("length"))
|
||||||
|
|
||||||
def set_size(self, size: int):
|
def set_size(self, size: int):
|
||||||
self._set_sub_text("size", str(size))
|
self.__set_if_positive("size", size)
|
||||||
|
|
||||||
def get_size(self):
|
def get_size(self) -> Optional[int]:
|
||||||
return _int_or_none(self._get_sub_text("size"))
|
return _positive_int_or_none(self._get_sub_text("size"))
|
||||||
|
|
||||||
def get_date(self):
|
def get_date(self) -> Optional[datetime]:
|
||||||
try:
|
try:
|
||||||
return parse(self._get_sub_text("date"))
|
return parse(self._get_sub_text("date"))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@ -30,9 +60,18 @@ class File(ElementBase):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def __set_if_positive(self, key: str, value: int):
|
||||||
|
if value <= 0:
|
||||||
|
raise ValueError(f"Invalid value for element {key}: {value}")
|
||||||
|
self._set_sub_text(key, str(value))
|
||||||
|
|
||||||
def _int_or_none(v):
|
|
||||||
|
def _positive_int_or_none(v: str) -> Optional[int]:
|
||||||
try:
|
try:
|
||||||
return int(v)
|
return int(v)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def register_plugins():
|
||||||
|
register_stanza_plugin(File, Hash)
|
||||||
|
register_stanza_plugin(File, Thumbnail)
|
||||||
|
@ -14,11 +14,12 @@ class Reply(ElementBase):
|
|||||||
interfaces = {"id", "to"}
|
interfaces = {"id", "to"}
|
||||||
|
|
||||||
def add_quoted_fallback(self, fallback: str, nickname: Optional[str] = None):
|
def add_quoted_fallback(self, fallback: str, nickname: Optional[str] = None):
|
||||||
"""
|
r"""
|
||||||
Add plain text fallback for clients not implementing XEP-0461.
|
Add plain text fallback for clients not implementing XEP-0461.
|
||||||
|
|
||||||
|
|
||||||
``msg["reply"].add_quoted_fallback("Some text", "Bob")`` will
|
``msg["reply"].add_quoted_fallback("Some text", "Bob")`` will
|
||||||
prepend "> Bob:\n> Some text\n" to the body of the message, and set the
|
prepend ``> Bob:\n> Some text\n`` to the body of the message, and set the
|
||||||
fallback_body attributes accordingly, so that clients implementing
|
fallback_body attributes accordingly, so that clients implementing
|
||||||
XEP-0461 can hide the fallback text.
|
XEP-0461 can hide the fallback text.
|
||||||
|
|
||||||
|
11
slixmpp/plugins/xep_0482/__init__.py
Normal file
11
slixmpp/plugins/xep_0482/__init__.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Slixmpp: The Slick XMPP Library
|
||||||
|
# Copyright (C) 2025 Mathieu Pasquet
|
||||||
|
# This file is part of Slixmpp.
|
||||||
|
# See the file LICENSE for copying permissio
|
||||||
|
from slixmpp.plugins.base import register_plugin
|
||||||
|
|
||||||
|
from slixmpp.plugins.xep_0482 import stanza
|
||||||
|
from slixmpp.plugins.xep_0482.call_invites import XEP_0482
|
||||||
|
|
||||||
|
|
||||||
|
register_plugin(XEP_0482)
|
55
slixmpp/plugins/xep_0482/call_invites.py
Normal file
55
slixmpp/plugins/xep_0482/call_invites.py
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
# Slixmpp: The Slick XMPP Library
|
||||||
|
# Copyright (C) 2025 Mathieu Pasquet
|
||||||
|
# This file is part of Slixmpp.
|
||||||
|
# See the file LICENSE for copying permissio
|
||||||
|
import logging
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from slixmpp.stanza import Message
|
||||||
|
from slixmpp.jid import JID
|
||||||
|
from slixmpp.xmlstream.handler import Callback
|
||||||
|
from slixmpp.xmlstream.matcher import StanzaPath
|
||||||
|
from slixmpp.xmlstream import register_stanza_plugin
|
||||||
|
from slixmpp.plugins import BasePlugin
|
||||||
|
from slixmpp.plugins.xep_0482 import stanza
|
||||||
|
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class XEP_0482(BasePlugin):
|
||||||
|
|
||||||
|
"""
|
||||||
|
XEP-0482: Call Invites
|
||||||
|
|
||||||
|
This plugin defines the stanza elements for Call Invites, as well as new
|
||||||
|
events:
|
||||||
|
|
||||||
|
- `call-invite`
|
||||||
|
- `call-reject`
|
||||||
|
- `call-retract`
|
||||||
|
- `call-leave`
|
||||||
|
- `call-left`
|
||||||
|
"""
|
||||||
|
|
||||||
|
name = 'xep_0482'
|
||||||
|
description = 'XEP-0482: Call Invites'
|
||||||
|
dependencies = set()
|
||||||
|
stanza = stanza
|
||||||
|
|
||||||
|
def plugin_init(self):
|
||||||
|
stanza.register_plugins()
|
||||||
|
|
||||||
|
for event in ('invite', 'reject', 'retract', 'leave', 'left'):
|
||||||
|
self.xmpp.register_handler(
|
||||||
|
Callback(f'Call {event}',
|
||||||
|
StanzaPath(f'message/call-{event}'),
|
||||||
|
self._handle_event))
|
||||||
|
def _handle_event(self, message):
|
||||||
|
for event in ('invite', 'reject', 'retract', 'leave', 'left'):
|
||||||
|
if message.get_plugin(f'call-{event}', check=True):
|
||||||
|
self.xmpp.event(f'call-{event}')
|
||||||
|
|
||||||
|
def plugin_end(self):
|
||||||
|
for event in ('invite', 'reject', 'retract', 'leave', 'left'):
|
||||||
|
self.xmpp.remove_handler(f'Call {event}')
|
102
slixmpp/plugins/xep_0482/stanza.py
Normal file
102
slixmpp/plugins/xep_0482/stanza.py
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
# Slixmpp: The Slick XMPP Library
|
||||||
|
# Copyright (C) 2025 Mathieu Pasquet
|
||||||
|
# This file is part of Slixmpp.
|
||||||
|
# See the file LICENSE for copying permission
|
||||||
|
|
||||||
|
from typing import Tuple, List, Optional
|
||||||
|
from slixmpp import Message
|
||||||
|
from slixmpp.jid import JID
|
||||||
|
from slixmpp.xmlstream import ElementBase, register_stanza_plugin
|
||||||
|
|
||||||
|
NS = 'urn:xmpp:call-invites:0'
|
||||||
|
|
||||||
|
|
||||||
|
class Jingle(ElementBase):
|
||||||
|
name = 'jingle'
|
||||||
|
namespace = NS
|
||||||
|
plugin_attrib = 'jingle'
|
||||||
|
plugin_multi_attrib = 'jingles'
|
||||||
|
interfaces = {'sid', 'jid'}
|
||||||
|
|
||||||
|
def set_jid(self, value: JID) -> None:
|
||||||
|
if not isinstance(value, JID):
|
||||||
|
try:
|
||||||
|
value = JID(value)
|
||||||
|
except ValueError:
|
||||||
|
raise ValueError(f'"jid" must be a valid JID object')
|
||||||
|
self.xml.attrib['jid'] = value.full
|
||||||
|
|
||||||
|
def get_jid(self) -> Optional[JID]:
|
||||||
|
try:
|
||||||
|
return JID(self.xml.attrib.get('jid', ''))
|
||||||
|
except ValueError:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class External(ElementBase):
|
||||||
|
name = 'external'
|
||||||
|
namespace = NS
|
||||||
|
plugin_attrib = 'external'
|
||||||
|
plugin_multi_attrib = 'externals'
|
||||||
|
interfaces = {'uri'}
|
||||||
|
|
||||||
|
|
||||||
|
class Invite(ElementBase):
|
||||||
|
name = 'invite'
|
||||||
|
namespace = NS
|
||||||
|
plugin_attrib = 'call-invite'
|
||||||
|
interfaces = {'video'}
|
||||||
|
|
||||||
|
def get_methods(self) -> Tuple[List[Jingle], List[External]]:
|
||||||
|
return (self['jingles'], self['externals'])
|
||||||
|
|
||||||
|
def set_video(self, value: bool) -> None:
|
||||||
|
if not isinstance(value, bool):
|
||||||
|
raise ValueError(f'Invalid value for the video attribute: {value}')
|
||||||
|
self.xml.attrib['video'] = str(value).lower()
|
||||||
|
|
||||||
|
def get_video(self) -> bool:
|
||||||
|
vid = self.xml.attrib.get('video', 'false').lower()
|
||||||
|
return vid == 'true'
|
||||||
|
|
||||||
|
|
||||||
|
class Retract(ElementBase):
|
||||||
|
name = 'retract'
|
||||||
|
namespace = NS
|
||||||
|
plugin_attrib = 'call-retract'
|
||||||
|
interfaces = {'id'}
|
||||||
|
|
||||||
|
|
||||||
|
class Accept(ElementBase):
|
||||||
|
name = 'accept'
|
||||||
|
namespace = NS
|
||||||
|
plugin_attrib = 'call-accept'
|
||||||
|
interfaces = {'id'}
|
||||||
|
|
||||||
|
|
||||||
|
class Reject(ElementBase):
|
||||||
|
name = 'reject'
|
||||||
|
namespace = NS
|
||||||
|
plugin_attrib = 'call-reject'
|
||||||
|
interfaces = {'id'}
|
||||||
|
|
||||||
|
|
||||||
|
class Left(ElementBase):
|
||||||
|
name = 'left'
|
||||||
|
namespace = NS
|
||||||
|
plugin_attrib = 'call-left'
|
||||||
|
interfaces = {'id'}
|
||||||
|
|
||||||
|
|
||||||
|
def register_plugins() -> None:
|
||||||
|
register_stanza_plugin(Message, Invite)
|
||||||
|
register_stanza_plugin(Message, Retract)
|
||||||
|
register_stanza_plugin(Message, Accept)
|
||||||
|
register_stanza_plugin(Message, Reject)
|
||||||
|
register_stanza_plugin(Message, Left)
|
||||||
|
|
||||||
|
register_stanza_plugin(Invite, Jingle, iterable=True)
|
||||||
|
register_stanza_plugin(Invite, External, iterable=True)
|
||||||
|
|
||||||
|
register_stanza_plugin(Accept, Jingle)
|
||||||
|
register_stanza_plugin(Accept, External)
|
13
slixmpp/plugins/xep_0492/__init__.py
Normal file
13
slixmpp/plugins/xep_0492/__init__.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Slixmpp: The Slick XMPP Library
|
||||||
|
# Copyright (C) 2025 nicoco
|
||||||
|
# This file is part of Slixmpp.
|
||||||
|
# See the file LICENSE for copying permission.
|
||||||
|
|
||||||
|
from slixmpp.plugins.base import register_plugin
|
||||||
|
|
||||||
|
from . import stanza
|
||||||
|
from .notify import XEP_0492
|
||||||
|
|
||||||
|
register_plugin(XEP_0492)
|
||||||
|
|
||||||
|
__all__ = ["stanza", "XEP_0492"]
|
21
slixmpp/plugins/xep_0492/notify.py
Normal file
21
slixmpp/plugins/xep_0492/notify.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Slixmpp: The Slick XMPP Library
|
||||||
|
# Copyright (C) 2025 nicoco
|
||||||
|
# This file is part of Slixmpp.
|
||||||
|
# See the file LICENSE for copying permission.
|
||||||
|
|
||||||
|
from slixmpp.plugins import BasePlugin
|
||||||
|
from . import stanza
|
||||||
|
|
||||||
|
|
||||||
|
class XEP_0492(BasePlugin):
|
||||||
|
"""
|
||||||
|
XEP-0492: Chat notification settings
|
||||||
|
"""
|
||||||
|
|
||||||
|
name = "xep_0492"
|
||||||
|
description = "XEP-0492: Chat notification settings"
|
||||||
|
dependencies = {"xep_0402"}
|
||||||
|
stanza = stanza
|
||||||
|
|
||||||
|
def plugin_init(self):
|
||||||
|
stanza.register_plugin()
|
106
slixmpp/plugins/xep_0492/stanza.py
Normal file
106
slixmpp/plugins/xep_0492/stanza.py
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
# Slixmpp: The Slick XMPP Library
|
||||||
|
# Copyright (C) 2025 nicoco
|
||||||
|
# This file is part of Slixmpp.
|
||||||
|
# See the file LICENSE for copying permission.
|
||||||
|
|
||||||
|
from typing import Literal, Optional, cast
|
||||||
|
|
||||||
|
from slixmpp import register_stanza_plugin
|
||||||
|
from slixmpp.plugins.xep_0402.stanza import Extensions
|
||||||
|
from slixmpp.types import ClientTypes
|
||||||
|
from slixmpp.xmlstream import ElementBase
|
||||||
|
|
||||||
|
NS = "urn:xmpp:notification-settings:0"
|
||||||
|
|
||||||
|
WhenLiteral = Literal["never", "always", "on-mention"]
|
||||||
|
|
||||||
|
|
||||||
|
class Notify(ElementBase):
|
||||||
|
"""
|
||||||
|
Chat notification settings element
|
||||||
|
|
||||||
|
|
||||||
|
To enable it on a Conference element, use configure() like this:
|
||||||
|
|
||||||
|
.. code-block::python
|
||||||
|
|
||||||
|
# C being a Conference element
|
||||||
|
C['extensions']["notify"].configure("always", client_type="pc")
|
||||||
|
|
||||||
|
Which will add the <notify> element to the <extensions> element.
|
||||||
|
"""
|
||||||
|
|
||||||
|
namespace = NS
|
||||||
|
name = "notify"
|
||||||
|
plugin_attrib = "notify"
|
||||||
|
interfaces = {"notify"}
|
||||||
|
|
||||||
|
def configure(self, when: WhenLiteral, client_type: Optional[ClientTypes] = None) -> None:
|
||||||
|
"""
|
||||||
|
Configure the chat notification settings for this bookmark.
|
||||||
|
|
||||||
|
This method ensures that there are no conflicting settings, e.g.,
|
||||||
|
both a <never /> and a <always /> element.
|
||||||
|
"""
|
||||||
|
cls = _CLASS_MAP[when]
|
||||||
|
element = cls()
|
||||||
|
if client_type is not None:
|
||||||
|
element["client-type"] = client_type
|
||||||
|
|
||||||
|
match = client_type if client_type is not None else ""
|
||||||
|
for child in self:
|
||||||
|
if isinstance(child, _Base) and child["client-type"] == match:
|
||||||
|
self.xml.remove(child.xml)
|
||||||
|
|
||||||
|
self.append(element)
|
||||||
|
|
||||||
|
def get_config(
|
||||||
|
self, client_type: Optional[ClientTypes] = None
|
||||||
|
) -> Optional[WhenLiteral]:
|
||||||
|
"""
|
||||||
|
Get the chat notification settings for this bookmark.
|
||||||
|
|
||||||
|
:param client_type: Optionally, get the notification for a specific client type.
|
||||||
|
If unset, returns the global notification setting.
|
||||||
|
|
||||||
|
:return: The chat notification setting as a string, or None if unset.
|
||||||
|
"""
|
||||||
|
match = client_type if client_type is not None else ""
|
||||||
|
for child in self:
|
||||||
|
if isinstance(child, _Base) and child["client-type"] == match:
|
||||||
|
return cast(WhenLiteral, child.name)
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
class _Base(ElementBase):
|
||||||
|
namespace = NS
|
||||||
|
interfaces = {"client-type"}
|
||||||
|
|
||||||
|
|
||||||
|
class Never(_Base):
|
||||||
|
name = "never"
|
||||||
|
|
||||||
|
|
||||||
|
class Always(_Base):
|
||||||
|
name = "always"
|
||||||
|
|
||||||
|
|
||||||
|
class OnMention(_Base):
|
||||||
|
name = "on-mention"
|
||||||
|
|
||||||
|
|
||||||
|
class Advanced(ElementBase):
|
||||||
|
namespace = NS
|
||||||
|
name = plugin_attrib = "advanced"
|
||||||
|
|
||||||
|
|
||||||
|
_CLASS_MAP = {
|
||||||
|
"never": Never,
|
||||||
|
"always": Always,
|
||||||
|
"on-mention": OnMention,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def register_plugin():
|
||||||
|
register_stanza_plugin(Extensions, Notify)
|
||||||
|
register_stanza_plugin(Notify, Advanced)
|
@ -97,6 +97,7 @@ ErrorConditions = Literal[
|
|||||||
"not-allowed",
|
"not-allowed",
|
||||||
"not-authorized",
|
"not-authorized",
|
||||||
"payment-required",
|
"payment-required",
|
||||||
|
"policy-violation",
|
||||||
"recipient-unavailable",
|
"recipient-unavailable",
|
||||||
"redirect",
|
"redirect",
|
||||||
"registration-required",
|
"registration-required",
|
||||||
@ -109,8 +110,21 @@ ErrorConditions = Literal[
|
|||||||
"unexpected-request",
|
"unexpected-request",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# https://xmpp.org/registrar/disco-categories.html#client
|
||||||
|
ClientTypes = Literal[
|
||||||
|
"bot",
|
||||||
|
"console",
|
||||||
|
"game",
|
||||||
|
"handheld",
|
||||||
|
"pc",
|
||||||
|
"phone",
|
||||||
|
"sms",
|
||||||
|
"tablet",
|
||||||
|
"web",
|
||||||
|
]
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'Protocol', 'TypedDict', 'Literal', 'OptJid', 'OptJidStr', 'JidStr', 'MAMDefault',
|
'Protocol', 'TypedDict', 'Literal', 'OptJid', 'OptJidStr', 'JidStr', 'MAMDefault',
|
||||||
'PresenceTypes', 'PresenceShows', 'MessageTypes', 'IqTypes', 'MucRole',
|
'PresenceTypes', 'PresenceShows', 'MessageTypes', 'IqTypes', 'MucRole',
|
||||||
'MucAffiliation', 'FilterString', 'ErrorConditions', 'ErrorTypes'
|
'MucAffiliation', 'FilterString', 'ErrorConditions', 'ErrorTypes', 'ClientTypes'
|
||||||
]
|
]
|
||||||
|
@ -281,7 +281,8 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
__slow_tasks: List[Task]
|
__slow_tasks: List[Task]
|
||||||
__queued_stanzas: List[Tuple[Union[StanzaBase, str], bool]]
|
__queued_stanzas: List[Tuple[Union[StanzaBase, str], bool]]
|
||||||
|
|
||||||
def __init__(self, host: str = '', port: int = 0):
|
def __init__(self, host: str = '', port: int = 0,
|
||||||
|
ssl_context: Optional[ssl.SSLContext] = None):
|
||||||
self.transport = None
|
self.transport = None
|
||||||
self.socket = None
|
self.socket = None
|
||||||
self._connect_loop_wait = 0
|
self._connect_loop_wait = 0
|
||||||
@ -298,9 +299,12 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
# A dict of {name: handle}
|
# A dict of {name: handle}
|
||||||
self.scheduled_events = {}
|
self.scheduled_events = {}
|
||||||
|
|
||||||
self.ssl_context = ssl.create_default_context()
|
if ssl_context is None:
|
||||||
self.ssl_context.check_hostname = True
|
self.ssl_context = ssl.create_default_context()
|
||||||
self.ssl_context.verify_mode = ssl.CERT_REQUIRED
|
self.ssl_context.check_hostname = True
|
||||||
|
self.ssl_context.verify_mode = ssl.CERT_REQUIRED
|
||||||
|
else:
|
||||||
|
self.ssl_context = ssl_context
|
||||||
|
|
||||||
self.event_when_connected = "connected"
|
self.event_when_connected = "connected"
|
||||||
|
|
||||||
@ -371,7 +375,23 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
@property
|
@property
|
||||||
def loop(self) -> AbstractEventLoop:
|
def loop(self) -> AbstractEventLoop:
|
||||||
if self._loop is None:
|
if self._loop is None:
|
||||||
self._loop = asyncio.get_event_loop()
|
try:
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
warnings.simplefilter("ignore")
|
||||||
|
self._loop = asyncio.get_event_loop()
|
||||||
|
# We do not know what exception will be raised in the future
|
||||||
|
# instead of the warning
|
||||||
|
except Exception:
|
||||||
|
try:
|
||||||
|
current = asyncio.get_running_loop()
|
||||||
|
except RuntimeError:
|
||||||
|
current = None
|
||||||
|
if current is not None:
|
||||||
|
self._loop = current
|
||||||
|
else:
|
||||||
|
loop = asyncio.new_event_loop()
|
||||||
|
asyncio.set_event_loop(loop)
|
||||||
|
self._loop = loop
|
||||||
return self._loop
|
return self._loop
|
||||||
|
|
||||||
@loop.setter
|
@loop.setter
|
||||||
@ -405,9 +425,10 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
self.disconnected.set_result(True)
|
self.disconnected.set_result(True)
|
||||||
self.disconnected = asyncio.Future()
|
self.disconnected = asyncio.Future()
|
||||||
|
|
||||||
def connect(self, host: str = '', port: int = 0, use_ssl: Optional[bool] = None,
|
def connect(self, host: str = '', port: int = 0,
|
||||||
|
use_ssl: Optional[bool] = None,
|
||||||
force_starttls: Optional[bool] = None,
|
force_starttls: Optional[bool] = None,
|
||||||
disable_starttls: Optional[bool] = None) -> None:
|
disable_starttls: Optional[bool] = None) -> asyncio.Future:
|
||||||
"""Create a new socket and connect to the server.
|
"""Create a new socket and connect to the server.
|
||||||
|
|
||||||
:param host: The name of the desired server for the connection.
|
:param host: The name of the desired server for the connection.
|
||||||
@ -426,6 +447,7 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
upgrade to TLS, even if the server provides
|
upgrade to TLS, even if the server provides
|
||||||
it. Use this for example if you’re on
|
it. Use this for example if you’re on
|
||||||
localhost
|
localhost
|
||||||
|
:returns: A future on the current connection attempt
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if self._run_out_filters is None or self._run_out_filters.done():
|
if self._run_out_filters is None or self._run_out_filters.done():
|
||||||
@ -457,8 +479,14 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
self._connect_routine(),
|
self._connect_routine(),
|
||||||
loop=self.loop,
|
loop=self.loop,
|
||||||
)
|
)
|
||||||
|
return self._current_connection_attempt
|
||||||
|
|
||||||
async def _connect_routine(self) -> None:
|
async def _connect_routine(self) -> Optional[asyncio.Future]:
|
||||||
|
"""
|
||||||
|
Returns None if the attempt was canceled or if the connection succeeded
|
||||||
|
(cancelling done manually by the library user, so that should be known)
|
||||||
|
or the next connection attempt future if a new try has been scheduled.
|
||||||
|
"""
|
||||||
self.event_when_connected = "connected"
|
self.event_when_connected = "connected"
|
||||||
|
|
||||||
if self._connect_loop_wait > 0:
|
if self._connect_loop_wait > 0:
|
||||||
@ -483,7 +511,7 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
ssl_context = None
|
ssl_context = None
|
||||||
|
|
||||||
if self._current_connection_attempt is None:
|
if self._current_connection_attempt is None:
|
||||||
return
|
return None
|
||||||
try:
|
try:
|
||||||
server_hostname = self.default_domain if self.use_ssl else None
|
server_hostname = self.default_domain if self.use_ssl else None
|
||||||
await self.loop.create_connection(lambda: self,
|
await self.loop.create_connection(lambda: self,
|
||||||
@ -495,11 +523,12 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
except Socket.gaierror as e:
|
except Socket.gaierror as e:
|
||||||
self.event('connection_failed',
|
self.event('connection_failed',
|
||||||
'No DNS record available for %s' % self.default_domain)
|
'No DNS record available for %s' % self.default_domain)
|
||||||
self.reschedule_connection_attempt()
|
return self.reschedule_connection_attempt()
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
log.debug('Connection failed: %s', e)
|
log.debug('Connection failed: %s', e)
|
||||||
self.event("connection_failed", e)
|
self.event("connection_failed", e)
|
||||||
self.reschedule_connection_attempt()
|
return self.reschedule_connection_attempt()
|
||||||
|
return None
|
||||||
|
|
||||||
def process(self, *, forever: bool = True, timeout: Optional[int] = None) -> None:
|
def process(self, *, forever: bool = True, timeout: Optional[int] = None) -> None:
|
||||||
"""Process all the available XMPP events (receiving or sending data on the
|
"""Process all the available XMPP events (receiving or sending data on the
|
||||||
@ -635,19 +664,22 @@ class XMLStream(asyncio.BaseProtocol):
|
|||||||
self._set_disconnected_future()
|
self._set_disconnected_future()
|
||||||
self.event("disconnected", self.disconnect_reason or exception)
|
self.event("disconnected", self.disconnect_reason or exception)
|
||||||
|
|
||||||
def reschedule_connection_attempt(self) -> None:
|
def reschedule_connection_attempt(self) -> Optional[asyncio.Future]:
|
||||||
"""
|
"""
|
||||||
Increase the exponential back-off and initate another background
|
Increase the exponential back-off and initate another background
|
||||||
_connect_routine call to connect to the server.
|
_connect_routine call to connect to the server.
|
||||||
|
|
||||||
|
:returns: A future on the next scheduled connection attempt.
|
||||||
"""
|
"""
|
||||||
# abort if there is no ongoing connection attempt
|
# abort if there is no ongoing connection attempt
|
||||||
if self._current_connection_attempt is None:
|
if self._current_connection_attempt is None:
|
||||||
return
|
return None
|
||||||
self._connect_loop_wait = min(300, self._connect_loop_wait * 2 + 1)
|
self._connect_loop_wait = min(300, self._connect_loop_wait * 2 + 1)
|
||||||
self._current_connection_attempt = asyncio.ensure_future(
|
self._current_connection_attempt = asyncio.ensure_future(
|
||||||
self._connect_routine(),
|
self._connect_routine(),
|
||||||
loop=self.loop,
|
loop=self.loop,
|
||||||
)
|
)
|
||||||
|
return self._current_connection_attempt
|
||||||
|
|
||||||
def cancel_connection_attempt(self) -> None:
|
def cancel_connection_attempt(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -95,6 +95,21 @@ class TestDataForms(SlixTest):
|
|||||||
</message>
|
</message>
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
def testMultiLineField(self):
|
||||||
|
msg = self.Message()
|
||||||
|
form = msg['form']
|
||||||
|
form.addField(var='f1',
|
||||||
|
value='Some text\non several\n\nlines')
|
||||||
|
self.check(msg, """
|
||||||
|
<message>
|
||||||
|
<x xmlns="jabber:x:data" type="form">
|
||||||
|
<field var="f1">
|
||||||
|
<value>Some text\non several\n\nlines</value>
|
||||||
|
</field>
|
||||||
|
</x>
|
||||||
|
</message>
|
||||||
|
""")
|
||||||
|
|
||||||
def testSetValues(self):
|
def testSetValues(self):
|
||||||
"""Testing setting form values"""
|
"""Testing setting form values"""
|
||||||
|
|
||||||
@ -117,7 +132,7 @@ class TestDataForms(SlixTest):
|
|||||||
<value>b</value>
|
<value>b</value>
|
||||||
</field>
|
</field>
|
||||||
</x>
|
</x>
|
||||||
</message>""")
|
</message>""", use_values=False)
|
||||||
|
|
||||||
def testSubmitType(self):
|
def testSubmitType(self):
|
||||||
"""Test that setting type to 'submit' clears extra details"""
|
"""Test that setting type to 'submit' clears extra details"""
|
||||||
|
@ -34,6 +34,7 @@ class TestJabberSearch(SlixTest):
|
|||||||
ifrom="juliet@capulet.com/balcony", ito="characters.shakespeare.lit"
|
ifrom="juliet@capulet.com/balcony", ito="characters.shakespeare.lit"
|
||||||
)
|
)
|
||||||
iq["search"]["form"].add_field(var="x-gender", value="male")
|
iq["search"]["form"].add_field(var="x-gender", value="male")
|
||||||
|
iq["id"] = "0"
|
||||||
self.check(
|
self.check(
|
||||||
iq,
|
iq,
|
||||||
"""
|
"""
|
||||||
|
26
tests/test_stanza_xep_0308.py
Normal file
26
tests/test_stanza_xep_0308.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import unittest
|
||||||
|
from slixmpp import Message
|
||||||
|
from slixmpp.test import SlixTest
|
||||||
|
from slixmpp.plugins.xep_0308 import Replace
|
||||||
|
from slixmpp.xmlstream import register_stanza_plugin
|
||||||
|
|
||||||
|
|
||||||
|
class TestCorrectStanza(SlixTest):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
register_stanza_plugin(Message, Replace)
|
||||||
|
|
||||||
|
def testBuild(self):
|
||||||
|
"""Test that the element is created correctly."""
|
||||||
|
msg = Message()
|
||||||
|
msg['type'] = 'chat'
|
||||||
|
msg['replace']['id'] = 'toto123'
|
||||||
|
|
||||||
|
self.check(msg, """
|
||||||
|
<message type="chat">
|
||||||
|
<replace xmlns="urn:xmpp:message-correct:0" id="toto123"/>
|
||||||
|
</message>
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestCorrectStanza)
|
@ -21,12 +21,12 @@ class TestModeration(SlixTest):
|
|||||||
|
|
||||||
self.check(iq, """
|
self.check(iq, """
|
||||||
<iq type='set' id='a'>
|
<iq type='set' id='a'>
|
||||||
<moderate xmlns='urn:xmpp:message-moderate:1'>
|
<moderate xmlns='urn:xmpp:message-moderate:1' id='some-id'>
|
||||||
<retract xmlns='urn:xmpp:message-retract:1'/>
|
<retract xmlns='urn:xmpp:message-retract:1'/>
|
||||||
<reason>R</reason>
|
<reason>R</reason>
|
||||||
</moderate>
|
</moderate>
|
||||||
</iq>
|
</iq>
|
||||||
""", use_values=False)
|
""")
|
||||||
|
|
||||||
def testModerated(self):
|
def testModerated(self):
|
||||||
message = Message()
|
message = Message()
|
||||||
|
101
tests/test_stanza_xep_0446.py
Normal file
101
tests/test_stanza_xep_0446.py
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
from slixmpp.test import SlixTest
|
||||||
|
from slixmpp.plugins.xep_0446 import stanza
|
||||||
|
|
||||||
|
|
||||||
|
class TestFileMeta(SlixTest):
|
||||||
|
def setUp(self):
|
||||||
|
stanza.register_plugins()
|
||||||
|
|
||||||
|
def test_simple(self):
|
||||||
|
file = stanza.File()
|
||||||
|
file["desc"] = "a description"
|
||||||
|
file["name"] = "toto.jpg"
|
||||||
|
file["media-type"] = "image/jpeg"
|
||||||
|
file["height"] = 1024
|
||||||
|
file["width"] = 768
|
||||||
|
file["size"] = 2048
|
||||||
|
self.check(
|
||||||
|
file,
|
||||||
|
"""
|
||||||
|
<file xmlns='urn:xmpp:file:metadata:0'>
|
||||||
|
<desc>a description</desc>
|
||||||
|
<name>toto.jpg</name>
|
||||||
|
<media-type>image/jpeg</media-type>
|
||||||
|
<height>1024</height>
|
||||||
|
<width>768</width>
|
||||||
|
<size>2048</size>
|
||||||
|
</file>
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_bad_value(self):
|
||||||
|
file = stanza.File()
|
||||||
|
file["desc"] = "My great video"
|
||||||
|
file["name"] = "toto.mp4"
|
||||||
|
file["media-type"] = "video/3gpp"
|
||||||
|
file["height"] = 1024
|
||||||
|
file["width"] = 768
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
file["length"] = -100
|
||||||
|
|
||||||
|
def test_hash_element(self):
|
||||||
|
file = stanza.File()
|
||||||
|
file["desc"] = "My great video"
|
||||||
|
file["name"] = "toto.3gp"
|
||||||
|
file["media-type"] = "video/3gpp"
|
||||||
|
file["height"] = 1024
|
||||||
|
file["width"] = 768
|
||||||
|
file["length"] = 2000
|
||||||
|
file["hash"]["algo"] = "sha3-256"
|
||||||
|
file["hash"]["value"] = "abcdef="
|
||||||
|
self.check(
|
||||||
|
file,
|
||||||
|
"""
|
||||||
|
<file xmlns='urn:xmpp:file:metadata:0'>
|
||||||
|
<desc>My great video</desc>
|
||||||
|
<name>toto.3gp</name>
|
||||||
|
<media-type>video/3gpp</media-type>
|
||||||
|
<height>1024</height>
|
||||||
|
<width>768</width>
|
||||||
|
<length>2000</length>
|
||||||
|
<hash xmlns='urn:xmpp:hashes:2' algo="sha3-256">abcdef=</hash>
|
||||||
|
</file>
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_thumbnail_element(self):
|
||||||
|
file = stanza.File()
|
||||||
|
file["desc"] = "a description"
|
||||||
|
file["name"] = "toto.jpg"
|
||||||
|
file["media-type"] = "image/jpeg"
|
||||||
|
file["height"] = 1024
|
||||||
|
file["width"] = 768
|
||||||
|
file["size"] = 2048
|
||||||
|
file["thumbnail"]["media-type"] = "image/png"
|
||||||
|
file["thumbnail"]["uri"] = "cid:sha1+deadbeef@bob.xmpp.org"
|
||||||
|
file["thumbnail"]["width"] = 128
|
||||||
|
file["thumbnail"]["height"] = 96
|
||||||
|
self.check(
|
||||||
|
file,
|
||||||
|
"""
|
||||||
|
<file xmlns='urn:xmpp:file:metadata:0'>
|
||||||
|
<desc>a description</desc>
|
||||||
|
<name>toto.jpg</name>
|
||||||
|
<media-type>image/jpeg</media-type>
|
||||||
|
<height>1024</height>
|
||||||
|
<width>768</width>
|
||||||
|
<size>2048</size>
|
||||||
|
<thumbnail xmlns='urn:xmpp:thumbs:1'
|
||||||
|
uri='cid:sha1+deadbeef@bob.xmpp.org'
|
||||||
|
media-type='image/png'
|
||||||
|
width='128'
|
||||||
|
height='96'/>
|
||||||
|
</file>
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestFileMeta)
|
42
tests/test_stanza_xep_0482.py
Normal file
42
tests/test_stanza_xep_0482.py
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import unittest
|
||||||
|
from slixmpp import Message
|
||||||
|
from slixmpp.jid import JID
|
||||||
|
from slixmpp.test import SlixTest
|
||||||
|
from slixmpp.plugins.xep_0482 import stanza
|
||||||
|
from slixmpp.plugins.xep_0482.stanza import External, Jingle
|
||||||
|
from slixmpp.xmlstream import register_stanza_plugin
|
||||||
|
|
||||||
|
|
||||||
|
class TestCallInviteStanza(SlixTest):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
stanza.register_plugins()
|
||||||
|
|
||||||
|
def test_invite(self):
|
||||||
|
"""Test that the element is created correctly."""
|
||||||
|
msg = Message()
|
||||||
|
msg['call-invite']['video'] = True
|
||||||
|
jingle = Jingle()
|
||||||
|
jingle['sid'] = 'toto'
|
||||||
|
jingle['jid'] = JID('toto@example.com/m')
|
||||||
|
external = External()
|
||||||
|
external['uri'] = "https://example.com/call"
|
||||||
|
msg['call-invite'].append(jingle)
|
||||||
|
msg['call-invite'].append(external)
|
||||||
|
|
||||||
|
self.check(msg, """
|
||||||
|
<message>
|
||||||
|
<invite xmlns="urn:xmpp:call-invites:0" video="true">
|
||||||
|
<jingle sid="toto" jid="toto@example.com/m" />
|
||||||
|
<external uri="https://example.com/call" />
|
||||||
|
</invite>
|
||||||
|
</message>
|
||||||
|
""")
|
||||||
|
|
||||||
|
self.assertEqual(
|
||||||
|
msg['call-invite'].get_methods(),
|
||||||
|
([jingle], [external]),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestCallInviteStanza)
|
178
tests/test_stanza_xep_0492.py
Normal file
178
tests/test_stanza_xep_0492.py
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
# Slixmpp: The Slick XMPP Library
|
||||||
|
# Copyright (C) 2025 nicoco
|
||||||
|
# This file is part of Slixmpp.
|
||||||
|
# See the file LICENSE for copying permission.
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from slixmpp import register_stanza_plugin, ElementBase
|
||||||
|
from slixmpp.test import SlixTest
|
||||||
|
from slixmpp.plugins.xep_0492 import stanza
|
||||||
|
from slixmpp.plugins.xep_0402 import stanza as b_stanza
|
||||||
|
|
||||||
|
|
||||||
|
class TestNotificationSetting(SlixTest):
|
||||||
|
def setUp(self):
|
||||||
|
b_stanza.register_plugin()
|
||||||
|
stanza.register_plugin()
|
||||||
|
|
||||||
|
def test_never(self):
|
||||||
|
bookmark = b_stanza.Conference()
|
||||||
|
bookmark["extensions"]["notify"].configure("never")
|
||||||
|
self.check(
|
||||||
|
bookmark,
|
||||||
|
"""
|
||||||
|
<conference xmlns='urn:xmpp:bookmarks:1'>
|
||||||
|
<extensions>
|
||||||
|
<notify xmlns='urn:xmpp:notification-settings:0'>
|
||||||
|
<never />
|
||||||
|
</notify>
|
||||||
|
</extensions>
|
||||||
|
</conference>
|
||||||
|
""",
|
||||||
|
use_values=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_always(self):
|
||||||
|
bookmark = b_stanza.Conference()
|
||||||
|
bookmark["extensions"]["notify"].configure("always")
|
||||||
|
self.check(
|
||||||
|
bookmark,
|
||||||
|
"""
|
||||||
|
<conference xmlns='urn:xmpp:bookmarks:1'>
|
||||||
|
<extensions>
|
||||||
|
<notify xmlns='urn:xmpp:notification-settings:0'>
|
||||||
|
<always />
|
||||||
|
</notify>
|
||||||
|
</extensions>
|
||||||
|
</conference>
|
||||||
|
""",
|
||||||
|
use_values=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_on_mention(self):
|
||||||
|
bookmark = b_stanza.Conference()
|
||||||
|
bookmark["extensions"]["notify"].configure("on-mention")
|
||||||
|
self.check(
|
||||||
|
bookmark,
|
||||||
|
"""
|
||||||
|
<conference xmlns='urn:xmpp:bookmarks:1'>
|
||||||
|
<extensions>
|
||||||
|
<notify xmlns='urn:xmpp:notification-settings:0'>
|
||||||
|
<on-mention />
|
||||||
|
</notify>
|
||||||
|
</extensions>
|
||||||
|
</conference>
|
||||||
|
""",
|
||||||
|
use_values=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_advanced(self):
|
||||||
|
bookmark = b_stanza.Conference()
|
||||||
|
bookmark["extensions"]["notify"].configure("never", client_type="pc")
|
||||||
|
bookmark["extensions"]["notify"].configure("on-mention", client_type="mobile")
|
||||||
|
|
||||||
|
register_stanza_plugin(stanza.Advanced, AdvancedExtension)
|
||||||
|
bookmark["extensions"]["notify"]["advanced"].enable("cool")
|
||||||
|
bookmark["extensions"]["notify"]["advanced"]["cool"]["attrib"] = "cool-attrib"
|
||||||
|
bookmark["extensions"]["notify"]["advanced"]["cool"]["content"] = "cool-content"
|
||||||
|
self.check(
|
||||||
|
bookmark,
|
||||||
|
"""
|
||||||
|
<conference xmlns='urn:xmpp:bookmarks:1'>
|
||||||
|
<extensions>
|
||||||
|
<notify xmlns='urn:xmpp:notification-settings:0'>
|
||||||
|
<never client-type="pc" />
|
||||||
|
<on-mention client-type="mobile" />
|
||||||
|
<advanced>
|
||||||
|
<cool xmlns="cool-ns" attrib="cool-attrib">cool-content</cool>
|
||||||
|
</advanced>
|
||||||
|
</notify>
|
||||||
|
</extensions>
|
||||||
|
</conference>
|
||||||
|
""",
|
||||||
|
use_values=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_change_config(self):
|
||||||
|
bookmark = b_stanza.Conference()
|
||||||
|
bookmark["extensions"]["notify"].configure("never")
|
||||||
|
bookmark["extensions"]["notify"].configure("never", client_type="pc")
|
||||||
|
bookmark["extensions"]["notify"].configure("on-mention", client_type="mobile")
|
||||||
|
|
||||||
|
self.check(
|
||||||
|
bookmark,
|
||||||
|
"""
|
||||||
|
<conference xmlns='urn:xmpp:bookmarks:1'>
|
||||||
|
<extensions>
|
||||||
|
<notify xmlns='urn:xmpp:notification-settings:0'>
|
||||||
|
<never />
|
||||||
|
<never client-type="pc" />
|
||||||
|
<on-mention client-type="mobile" />
|
||||||
|
</notify>
|
||||||
|
</extensions>
|
||||||
|
</conference>
|
||||||
|
""",
|
||||||
|
use_values=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
bookmark["extensions"]["notify"].configure("always")
|
||||||
|
|
||||||
|
self.check(
|
||||||
|
bookmark,
|
||||||
|
"""
|
||||||
|
<conference xmlns='urn:xmpp:bookmarks:1'>
|
||||||
|
<extensions>
|
||||||
|
<notify xmlns='urn:xmpp:notification-settings:0'>
|
||||||
|
<always />
|
||||||
|
<never client-type="pc" />
|
||||||
|
<on-mention client-type="mobile" />
|
||||||
|
</notify>
|
||||||
|
</extensions>
|
||||||
|
</conference>
|
||||||
|
""",
|
||||||
|
use_values=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
bookmark["extensions"]["notify"].configure("always", "mobile")
|
||||||
|
|
||||||
|
self.check(
|
||||||
|
bookmark,
|
||||||
|
"""
|
||||||
|
<conference xmlns='urn:xmpp:bookmarks:1'>
|
||||||
|
<extensions>
|
||||||
|
<notify xmlns='urn:xmpp:notification-settings:0'>
|
||||||
|
<always />
|
||||||
|
<never client-type="pc" />
|
||||||
|
<always client-type="mobile" />
|
||||||
|
</notify>
|
||||||
|
</extensions>
|
||||||
|
</conference>
|
||||||
|
""",
|
||||||
|
use_values=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_get_config(self):
|
||||||
|
bookmark = b_stanza.Conference()
|
||||||
|
bookmark["extensions"]["notify"].configure("never")
|
||||||
|
bookmark["extensions"]["notify"].configure("never", client_type="pc")
|
||||||
|
bookmark["extensions"]["notify"].configure("on-mention", client_type="mobile")
|
||||||
|
|
||||||
|
self.assertEqual(bookmark["extensions"]["notify"].get_config(), "never")
|
||||||
|
self.assertEqual(bookmark["extensions"]["notify"].get_config("pc"), "never")
|
||||||
|
self.assertEqual(
|
||||||
|
bookmark["extensions"]["notify"].get_config("mobile"), "on-mention"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class AdvancedExtension(ElementBase):
|
||||||
|
namespace = "cool-ns"
|
||||||
|
name = "cool"
|
||||||
|
plugin_attrib = name
|
||||||
|
interfaces = {"attrib", "content"}
|
||||||
|
|
||||||
|
def set_content(self, content: str):
|
||||||
|
self.xml.text = content
|
||||||
|
|
||||||
|
|
||||||
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestNotificationSetting)
|
28
tests/test_stream_xep_0223.py
Normal file
28
tests/test_stream_xep_0223.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import unittest
|
||||||
|
from slixmpp.test import SlixTest
|
||||||
|
|
||||||
|
|
||||||
|
class TestPrivatePEP(SlixTest):
|
||||||
|
|
||||||
|
def testConfigureNode(self):
|
||||||
|
self.stream_start(mode='client', plugins=['xep_0223'])
|
||||||
|
|
||||||
|
self.xmpp.plugin['xep_0223'].configure(node="toto")
|
||||||
|
self.send("""
|
||||||
|
<iq type="set" id="1">
|
||||||
|
<pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
|
||||||
|
<configure node='toto'>
|
||||||
|
<x xmlns='jabber:x:data' type='submit'>
|
||||||
|
<field var='FORM_TYPE' type='hidden'>
|
||||||
|
<value>http://jabber.org/protocol/pubsub#node_config</value>
|
||||||
|
</field>
|
||||||
|
<field var='pubsub#persist_items'><value>1</value></field>
|
||||||
|
<field var='pubsub#access_model'><value>whitelist</value></field>
|
||||||
|
</x>
|
||||||
|
</configure>
|
||||||
|
</pubsub>
|
||||||
|
</iq>
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestPrivatePEP)
|
53
tests/test_stream_xep_0308.py
Normal file
53
tests/test_stream_xep_0308.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import unittest
|
||||||
|
from slixmpp.jid import JID
|
||||||
|
from slixmpp.test import SlixTest
|
||||||
|
|
||||||
|
|
||||||
|
class TestStreamCorrect(SlixTest):
|
||||||
|
|
||||||
|
def test_recv_correct(self):
|
||||||
|
self.stream_start(mode='client', plugins=['xep_0308'])
|
||||||
|
|
||||||
|
recv = []
|
||||||
|
|
||||||
|
def recv_correct(msg):
|
||||||
|
recv.append(msg)
|
||||||
|
|
||||||
|
self.xmpp.add_event_handler('message_correction', recv_correct)
|
||||||
|
|
||||||
|
self.recv("""
|
||||||
|
<message from="example.com" to="toto@example">
|
||||||
|
<replace xmlns="urn:xmpp:message-correct:0" id="tototo"/>
|
||||||
|
<body>oucou</body>
|
||||||
|
</message>
|
||||||
|
""")
|
||||||
|
received = recv[0]
|
||||||
|
self.assertEqual(received['replace']['id'], "tototo")
|
||||||
|
|
||||||
|
|
||||||
|
def test_send_correct(self):
|
||||||
|
self.stream_start(mode='client', plugins=['xep_0308'])
|
||||||
|
|
||||||
|
corrected = self.xmpp.plugin['xep_0308'].build_correction(
|
||||||
|
id_to_replace="12345",
|
||||||
|
mto=JID('toto@example.com'),
|
||||||
|
mbody="I am replacing",
|
||||||
|
)
|
||||||
|
self.assertEqual(corrected['replace']['id'], '12345')
|
||||||
|
self.assertEqual(corrected['to'], JID('toto@example.com'))
|
||||||
|
self.assertEqual(corrected['body'], 'I am replacing')
|
||||||
|
corrected['id'] = 'my id'
|
||||||
|
|
||||||
|
corrected = self.xmpp.plugin['xep_0308'].correct_message(
|
||||||
|
corrected,
|
||||||
|
'This is new',
|
||||||
|
)
|
||||||
|
self.send("""
|
||||||
|
<message type="chat" to="toto@example.com">
|
||||||
|
<body>This is new</body>
|
||||||
|
<replace xmlns="urn:xmpp:message-correct:0" id="my id" />
|
||||||
|
</message>
|
||||||
|
""")
|
||||||
|
|
||||||
|
|
||||||
|
suite = unittest.TestLoader().loadTestsFromTestCase(TestStreamCorrect)
|
Loading…
x
Reference in New Issue
Block a user