slidge 0.1.0b2__py3-none-any.whl → 0.1.1__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. slidge/__init__.py +55 -31
  2. slidge/__main__.py +118 -116
  3. slidge/command/__init__.py +28 -0
  4. slidge/command/adhoc.py +258 -0
  5. slidge/command/admin.py +193 -0
  6. slidge/command/base.py +441 -0
  7. slidge/command/categories.py +3 -0
  8. slidge/command/chat_command.py +288 -0
  9. slidge/command/register.py +179 -0
  10. slidge/command/user.py +250 -0
  11. slidge/contact/__init__.py +8 -0
  12. slidge/contact/contact.py +452 -0
  13. slidge/contact/roster.py +192 -0
  14. slidge/core/__init__.py +2 -0
  15. slidge/core/cache.py +183 -0
  16. slidge/core/config.py +216 -0
  17. slidge/core/gateway/__init__.py +3 -0
  18. slidge/core/gateway/base.py +895 -0
  19. slidge/core/gateway/caps.py +63 -0
  20. slidge/core/gateway/delivery_receipt.py +52 -0
  21. slidge/core/gateway/disco.py +80 -0
  22. slidge/core/gateway/mam.py +75 -0
  23. slidge/core/gateway/muc_admin.py +35 -0
  24. slidge/core/gateway/ping.py +66 -0
  25. slidge/core/gateway/presence.py +95 -0
  26. slidge/core/gateway/registration.py +53 -0
  27. slidge/core/gateway/search.py +102 -0
  28. slidge/core/gateway/session_dispatcher.py +789 -0
  29. slidge/core/gateway/vcard_temp.py +130 -0
  30. slidge/core/mixins/__init__.py +19 -0
  31. slidge/core/mixins/attachment.py +506 -0
  32. slidge/core/mixins/avatar.py +167 -0
  33. slidge/core/mixins/base.py +31 -0
  34. slidge/core/mixins/disco.py +130 -0
  35. slidge/core/mixins/lock.py +31 -0
  36. slidge/core/mixins/message.py +398 -0
  37. slidge/core/mixins/message_maker.py +154 -0
  38. slidge/core/mixins/presence.py +217 -0
  39. slidge/core/mixins/recipient.py +43 -0
  40. slidge/core/pubsub.py +282 -116
  41. slidge/core/session.py +595 -372
  42. slidge/group/__init__.py +10 -0
  43. slidge/group/archive.py +125 -0
  44. slidge/group/bookmarks.py +163 -0
  45. slidge/group/participant.py +458 -0
  46. slidge/group/room.py +1103 -0
  47. slidge/migration.py +18 -0
  48. slidge/slixfix/__init__.py +68 -0
  49. slidge/{util/xep_0084 → slixfix/link_preview}/__init__.py +3 -5
  50. slidge/slixfix/link_preview/link_preview.py +17 -0
  51. slidge/slixfix/link_preview/stanza.py +99 -0
  52. slidge/slixfix/roster.py +60 -0
  53. slidge/{util → slixfix}/xep_0077/register.py +14 -2
  54. slidge/slixfix/xep_0077/stanza.py +104 -0
  55. slidge/{util → slixfix}/xep_0100/gateway.py +25 -15
  56. slidge/slixfix/xep_0100/stanza.py +9 -0
  57. slidge/slixfix/xep_0153/__init__.py +10 -0
  58. slidge/slixfix/xep_0153/stanza.py +25 -0
  59. slidge/slixfix/xep_0153/vcard_avatar.py +23 -0
  60. slidge/slixfix/xep_0264/__init__.py +5 -0
  61. slidge/slixfix/xep_0264/stanza.py +36 -0
  62. slidge/slixfix/xep_0264/thumbnail.py +23 -0
  63. slidge/slixfix/xep_0292/__init__.py +5 -0
  64. slidge/slixfix/xep_0292/vcard4.py +100 -0
  65. slidge/slixfix/xep_0313/__init__.py +12 -0
  66. slidge/slixfix/xep_0313/mam.py +262 -0
  67. slidge/slixfix/xep_0313/stanza.py +359 -0
  68. slidge/slixfix/xep_0317/__init__.py +5 -0
  69. slidge/slixfix/xep_0317/hats.py +17 -0
  70. slidge/slixfix/xep_0317/stanza.py +28 -0
  71. slidge/{util → slixfix}/xep_0356_old/privilege.py +9 -7
  72. slidge/slixfix/xep_0424/__init__.py +9 -0
  73. slidge/slixfix/xep_0424/retraction.py +77 -0
  74. slidge/slixfix/xep_0424/stanza.py +28 -0
  75. slidge/slixfix/xep_0490/__init__.py +8 -0
  76. slidge/slixfix/xep_0490/mds.py +47 -0
  77. slidge/slixfix/xep_0490/stanza.py +17 -0
  78. slidge/util/__init__.py +4 -6
  79. slidge/util/archive_msg.py +61 -0
  80. slidge/util/conf.py +206 -0
  81. slidge/util/db.py +57 -76
  82. slidge/util/schema.sql +126 -0
  83. slidge/util/sql.py +508 -0
  84. slidge/util/test.py +215 -25
  85. slidge/util/types.py +177 -4
  86. slidge/util/util.py +225 -59
  87. slidge-0.1.1.dist-info/METADATA +110 -0
  88. slidge-0.1.1.dist-info/RECORD +96 -0
  89. {slidge-0.1.0b2.dist-info → slidge-0.1.1.dist-info}/WHEEL +1 -1
  90. slidge/core/contact.py +0 -891
  91. slidge/core/gateway.py +0 -916
  92. slidge/plugins/discord/__init__.py +0 -90
  93. slidge/plugins/discord/client.py +0 -108
  94. slidge/plugins/discord/session.py +0 -162
  95. slidge/plugins/dummy.py +0 -203
  96. slidge/plugins/facebook.py +0 -493
  97. slidge/plugins/hackernews.py +0 -213
  98. slidge/plugins/mattermost/__init__.py +0 -1
  99. slidge/plugins/mattermost/api.py +0 -280
  100. slidge/plugins/mattermost/gateway.py +0 -365
  101. slidge/plugins/mattermost/websocket.py +0 -252
  102. slidge/plugins/signal/__init__.py +0 -3
  103. slidge/plugins/signal/contact.py +0 -106
  104. slidge/plugins/signal/gateway.py +0 -282
  105. slidge/plugins/signal/session.py +0 -448
  106. slidge/plugins/signal/txt.py +0 -53
  107. slidge/plugins/skype.py +0 -325
  108. slidge/plugins/steam.py +0 -310
  109. slidge/plugins/telegram/__init__.py +0 -5
  110. slidge/plugins/telegram/client.py +0 -228
  111. slidge/plugins/telegram/config.py +0 -12
  112. slidge/plugins/telegram/contact.py +0 -176
  113. slidge/plugins/telegram/gateway.py +0 -150
  114. slidge/plugins/telegram/session.py +0 -256
  115. slidge/util/xep_0030/__init__.py +0 -13
  116. slidge/util/xep_0030/disco.py +0 -811
  117. slidge/util/xep_0030/stanza/__init__.py +0 -7
  118. slidge/util/xep_0030/stanza/info.py +0 -270
  119. slidge/util/xep_0030/stanza/items.py +0 -147
  120. slidge/util/xep_0030/static.py +0 -467
  121. slidge/util/xep_0055/__init__.py +0 -5
  122. slidge/util/xep_0055/search.py +0 -75
  123. slidge/util/xep_0055/stanza.py +0 -10
  124. slidge/util/xep_0077/stanza.py +0 -71
  125. slidge/util/xep_0084/avatar.py +0 -137
  126. slidge/util/xep_0084/stanza.py +0 -104
  127. slidge/util/xep_0115/__init__.py +0 -12
  128. slidge/util/xep_0115/caps.py +0 -379
  129. slidge/util/xep_0115/stanza.py +0 -16
  130. slidge/util/xep_0115/static.py +0 -137
  131. slidge/util/xep_0292/__init__.py +0 -1
  132. slidge/util/xep_0292/stanza.py +0 -167
  133. slidge/util/xep_0292/vcard4.py +0 -75
  134. slidge/util/xep_0333/__init__.py +0 -10
  135. slidge/util/xep_0333/markers.py +0 -96
  136. slidge/util/xep_0333/stanza.py +0 -34
  137. slidge/util/xep_0356/__init__.py +0 -7
  138. slidge/util/xep_0356/permissions.py +0 -35
  139. slidge/util/xep_0356/privilege.py +0 -160
  140. slidge/util/xep_0356/stanza.py +0 -44
  141. slidge/util/xep_0363/__init__.py +0 -16
  142. slidge/util/xep_0363/http_upload.py +0 -215
  143. slidge/util/xep_0363/stanza.py +0 -46
  144. slidge/util/xep_0461/__init__.py +0 -6
  145. slidge/util/xep_0461/reply.py +0 -48
  146. slidge/util/xep_0461/stanza.py +0 -47
  147. slidge-0.1.0b2.dist-info/METADATA +0 -171
  148. slidge-0.1.0b2.dist-info/RECORD +0 -81
  149. /slidge/{plugins/__init__.py → py.typed} +0 -0
  150. /slidge/{util → slixfix}/xep_0077/__init__.py +0 -0
  151. /slidge/{util → slixfix}/xep_0100/__init__.py +0 -0
  152. /slidge/{util → slixfix}/xep_0356_old/__init__.py +0 -0
  153. /slidge/{util → slixfix}/xep_0356_old/stanza.py +0 -0
  154. {slidge-0.1.0b2.dist-info → slidge-0.1.1.dist-info}/LICENSE +0 -0
  155. {slidge-0.1.0b2.dist-info → slidge-0.1.1.dist-info}/entry_points.txt +0 -0
@@ -1,137 +0,0 @@
1
- # Slixmpp: The Slick XMPP Library
2
- # Copyright (C) 2011 Nathanael C. Fritz, Lance J.T. Stout
3
- # This file is part of Slixmpp.
4
- # See the file LICENSE for copying permission.
5
- import logging
6
-
7
- from slixmpp.exceptions import IqError, IqTimeout
8
- from slixmpp.xmlstream import JID
9
-
10
- log = logging.getLogger(__name__)
11
-
12
-
13
- class StaticCaps(object):
14
-
15
- """
16
- Extend the default StaticDisco implementation to provide
17
- support for extended identity information.
18
- """
19
-
20
- def __init__(self, xmpp, static):
21
- """
22
- Augment the default XEP-0030 static handler object.
23
-
24
- Arguments:
25
- static -- The default static XEP-0030 handler object.
26
- """
27
- self.xmpp = xmpp
28
- self.disco = self.xmpp["xep_0030"]
29
- self.caps = self.xmpp["xep_0115"]
30
- self.static = static
31
- self.jid_vers = {}
32
-
33
- async def supports(self, jid, node, ifrom, data):
34
- """
35
- Check if a JID supports a given feature.
36
-
37
- The data parameter may provide:
38
- feature -- The feature to check for support.
39
- local -- If true, then the query is for a JID/node
40
- combination handled by this Slixmpp instance and
41
- no stanzas need to be sent.
42
- Otherwise, a disco stanza must be sent to the
43
- remove JID to retrieve the info.
44
- cached -- If true, then look for the disco info data from
45
- the local cache system. If no results are found,
46
- send the query as usual. The self.use_cache
47
- setting must be set to true for this option to
48
- be useful. If set to false, then the cache will
49
- be skipped, even if a result has already been
50
- cached. Defaults to false.
51
- """
52
- feature = data.get("feature", None)
53
-
54
- data = {"local": data.get("local", False), "cached": data.get("cached", True)}
55
-
56
- if not feature:
57
- return False
58
-
59
- if node in (None, ""):
60
- info = await self.caps.get_caps(jid) # Missing await
61
- if info and feature in info["features"]:
62
- return True
63
-
64
- try:
65
- info = await self.disco.get_info(jid=jid, node=node, ifrom=ifrom, **data)
66
- info = self.disco._wrap(ifrom, jid, info, True)
67
- return feature in info["disco_info"]["features"]
68
- except IqError:
69
- return False
70
- except IqTimeout:
71
- return None
72
-
73
- async def has_identity(self, jid, node, ifrom, data):
74
- """
75
- Check if a JID has a given identity.
76
-
77
- The data parameter may provide:
78
- category -- The category of the identity to check.
79
- itype -- The type of the identity to check.
80
- lang -- The language of the identity to check.
81
- local -- If true, then the query is for a JID/node
82
- combination handled by this Slixmpp instance and
83
- no stanzas need to be sent.
84
- Otherwise, a disco stanza must be sent to the
85
- remove JID to retrieve the info.
86
- cached -- If true, then look for the disco info data from
87
- the local cache system. If no results are found,
88
- send the query as usual. The self.use_cache
89
- setting must be set to true for this option to
90
- be useful. If set to false, then the cache will
91
- be skipped, even if a result has already been
92
- cached. Defaults to false.
93
- """
94
- identity = (
95
- data.get("category", None),
96
- data.get("itype", None),
97
- data.get("lang", None),
98
- )
99
-
100
- data = {"local": data.get("local", False), "cached": data.get("cached", True)}
101
-
102
- trunc = lambda i: (i[0], i[1], i[2])
103
-
104
- if node in (None, ""):
105
- info = self.caps.get_caps(jid)
106
- if info and identity in map(trunc, info["identities"]):
107
- return True
108
-
109
- try:
110
- info = await self.disco.get_info(jid=jid, node=node, ifrom=ifrom, **data)
111
- info = self.disco._wrap(ifrom, jid, info, True)
112
- return identity in map(trunc, info["disco_info"]["identities"])
113
- except IqError:
114
- return False
115
- except IqTimeout:
116
- return None
117
-
118
- def cache_caps(self, jid, node, ifrom, data):
119
- verstring = data.get("verstring", None)
120
- info = data.get("info", None)
121
- if not verstring or not info:
122
- return
123
- self.caps.cache.store(verstring, info)
124
-
125
- def assign_verstring(self, jid, node, ifrom, data):
126
- if isinstance(jid, JID):
127
- jid = jid.full
128
- self.jid_vers[jid] = data.get("verstring", None)
129
-
130
- def get_verstring(self, jid, node, ifrom, data):
131
- return self.jid_vers.get(jid, None)
132
-
133
- def get_caps(self, jid, node, ifrom, data):
134
- verstring = data.get("verstring", None)
135
- if verstring is None:
136
- return None
137
- return self.caps.cache.retrieve(verstring)
@@ -1 +0,0 @@
1
- from . import stanza, vcard4
@@ -1,167 +0,0 @@
1
- import datetime
2
- from typing import Optional
3
-
4
- from slixmpp import ElementBase, Iq, register_stanza_plugin
5
-
6
- NS = "urn:ietf:params:xml:ns:vcard-4.0"
7
-
8
-
9
- class _VCardElementBase(ElementBase):
10
- namespace = NS
11
-
12
-
13
- class VCard4(_VCardElementBase):
14
- name = plugin_attrib = "vcard"
15
- interfaces = {"full_name", "given", "surname", "birthday"}
16
-
17
- def set_full_name(self, full_name: str):
18
- self["fn"]["text"] = full_name
19
-
20
- def get_full_name(self):
21
- return self["fn"]["text"]
22
-
23
- def set_given(self, given: str):
24
- self["n"]["given"] = given
25
-
26
- def get_given(self):
27
- return self["n"]["given"]
28
-
29
- def set_surname(self, surname: str):
30
- self["n"]["surname"] = surname
31
-
32
- def get_surname(self):
33
- return self["n"]["surname"]
34
-
35
- def set_birthday(self, birthday: datetime.date):
36
- self["bday"]["date"] = birthday
37
-
38
- def get_birthday(self):
39
- return self["bday"]["date"]
40
-
41
- def add_tel(self, number: str, name: Optional[str] = None):
42
- tel = Tel()
43
- if name:
44
- tel["parameters"]["type_"]["text"] = name
45
- tel["uri"] = f"tel:{number}"
46
- self.append(tel)
47
-
48
- def add_address(
49
- self, country: Optional[str] = None, locality: Optional[str] = None
50
- ):
51
- adr = Adr()
52
- if locality:
53
- adr["locality"] = locality
54
- if country:
55
- adr["country"] = country
56
- self.append(adr)
57
-
58
- def add_nickname(self, nick: str):
59
- el = Nickname()
60
- el["text"] = nick
61
- self.append(el)
62
-
63
- def add_note(self, note: str):
64
- el = Note()
65
- el["text"] = note
66
- self.append(el)
67
-
68
- def add_impp(self, impp: str):
69
- el = Impp()
70
- el["uri"] = impp
71
- self.append(el)
72
-
73
- def add_url(self, url: str):
74
- el = Url()
75
- el["uri"] = url
76
- self.append(el)
77
-
78
- def add_email(self, email: str):
79
- el = Email()
80
- el["text"] = email
81
- self.append(el)
82
-
83
-
84
- class _VCardTextElementBase(_VCardElementBase):
85
- interfaces = {"text"}
86
- sub_interfaces = {"text"}
87
-
88
-
89
- class Fn(_VCardTextElementBase):
90
- name = plugin_attrib = "fn"
91
-
92
-
93
- class Nickname(_VCardTextElementBase):
94
- name = plugin_attrib = "nickname"
95
-
96
-
97
- class Note(_VCardTextElementBase):
98
- name = plugin_attrib = "note"
99
-
100
-
101
- class _VCardUriElementBase(_VCardElementBase):
102
- interfaces = {"uri"}
103
- sub_interfaces = {"uri"}
104
-
105
-
106
- class Url(_VCardUriElementBase):
107
- name = plugin_attrib = "url"
108
-
109
-
110
- class Impp(_VCardUriElementBase):
111
- name = plugin_attrib = "impp"
112
-
113
-
114
- class Email(_VCardTextElementBase):
115
- name = plugin_attrib = "email"
116
-
117
-
118
- class N(_VCardElementBase):
119
- name = "n"
120
- plugin_attrib = "n"
121
- interfaces = sub_interfaces = {"given", "surname", "additional"}
122
-
123
-
124
- class BDay(_VCardElementBase):
125
- name = plugin_attrib = "bday"
126
- interfaces = {"date"}
127
-
128
- def set_date(self, date: datetime.date):
129
- d = Date()
130
- d.xml.text = date.strftime("%Y-%m-%d")
131
- self.append(d)
132
-
133
- def get_date(self):
134
- for elem in self.xml:
135
- try:
136
- return datetime.date.fromisoformat(elem.text)
137
- except ValueError:
138
- return None
139
-
140
-
141
- class Date(_VCardElementBase):
142
- name = "date"
143
-
144
-
145
- class Tel(_VCardUriElementBase):
146
- name = plugin_attrib = "tel"
147
-
148
-
149
- class Parameters(_VCardElementBase):
150
- name = plugin_attrib = "parameters"
151
-
152
-
153
- class Type(_VCardTextElementBase):
154
- name = "type"
155
- plugin_attrib = "type_"
156
-
157
-
158
- class Adr(_VCardElementBase):
159
- name = plugin_attrib = "adr"
160
- interfaces = sub_interfaces = {"locality", "country"}
161
-
162
-
163
- register_stanza_plugin(Parameters, Type)
164
- register_stanza_plugin(Tel, Parameters)
165
- for p in N, Fn, Nickname, Note, Url, Impp, Email, BDay, Tel, Adr:
166
- register_stanza_plugin(VCard4, p, iterable=True)
167
- register_stanza_plugin(Iq, VCard4)
@@ -1,75 +0,0 @@
1
- import logging
2
- from dataclasses import dataclass, field
3
- from typing import Optional
4
-
5
- from slixmpp import JID, ComponentXMPP, CoroutineCallback, Iq, StanzaPath
6
- from slixmpp.plugins.base import BasePlugin, register_plugin
7
- from slixmpp.types import JidStr
8
-
9
- from .stanza import NS, VCard4
10
-
11
-
12
- @dataclass
13
- class StoredVCard:
14
- content: VCard4
15
- authorized_jids: set[JidStr] = field(default_factory=set)
16
-
17
-
18
- class VCard4Provider(BasePlugin):
19
- xmpp: ComponentXMPP
20
-
21
- name = "xep_0292_provider"
22
- description = "VCard4 Provider"
23
- dependencies = {"xep_0030"}
24
-
25
- def __init__(self, *a, **k):
26
- super(VCard4Provider, self).__init__(*a, **k)
27
- self._vcards = dict[JidStr, StoredVCard]()
28
-
29
- def plugin_init(self):
30
- self.xmpp.register_handler(
31
- CoroutineCallback(
32
- "get_vcard",
33
- StanzaPath(f"iq@type=get/vcard"),
34
- self.handle_vcard_get, # type:ignore
35
- )
36
- )
37
-
38
- self.xmpp.plugin["xep_0030"].add_feature(NS)
39
-
40
- def get_vcard(self, jid: JidStr, requested_by: JidStr) -> Optional[VCard4]:
41
- vcard = self._vcards.get(JID(jid).bare)
42
- log.debug("VCARDS: %s", self._vcards)
43
- if vcard:
44
- if auth := vcard.authorized_jids:
45
- if JID(requested_by).bare in auth:
46
- return vcard.content
47
- else:
48
- return vcard.content
49
- return None
50
-
51
- async def handle_vcard_get(self, iq: Iq):
52
- r = iq.reply()
53
- if vcard := self.get_vcard(iq.get_to().bare, iq.get_from().bare):
54
- r.append(vcard)
55
- else:
56
- r.enable("vcard")
57
- r.send()
58
-
59
- def set_vcard(
60
- self,
61
- jid: JidStr,
62
- vcard: VCard4,
63
- /,
64
- authorized_jids: Optional[set[JidStr]] = None,
65
- ):
66
- self._vcards[jid] = StoredVCard(
67
- vcard, authorized_jids if authorized_jids is not None else set()
68
- )
69
- if self.xmpp["pubsub"] and authorized_jids:
70
- for to in authorized_jids:
71
- self.xmpp["pubsub"].broadcast_vcard_event(jid, to)
72
-
73
-
74
- register_plugin(VCard4Provider)
75
- log = logging.getLogger(__name__)
@@ -1,10 +0,0 @@
1
- # slixmpp: The Slick XMPP Library
2
- # Copyright (C) 2016 Emmanuel Gil Peyrot
3
- # This file is part of slixmpp.
4
- # See the file LICENSE for copying permission.
5
- from slixmpp.plugins.base import register_plugin
6
-
7
- from .markers import XEP_0333
8
- from .stanza import Acknowledged, Displayed, Markable, Received
9
-
10
- register_plugin(XEP_0333)
@@ -1,96 +0,0 @@
1
- # slixmpp: The Slick XMPP Library
2
- # Copyright (C) 2016 Emmanuel Gil Peyrot
3
- # This file is part of slixmpp.
4
- # See the file LICENSE for copying permission.
5
- import logging
6
- from typing import Optional
7
-
8
- from slixmpp import JID, Message
9
- from slixmpp.plugins import BasePlugin
10
- from slixmpp.plugins.xep_0333 import Acknowledged, Displayed, Markable, Received, stanza
11
- from slixmpp.xmlstream import register_stanza_plugin
12
- from slixmpp.xmlstream.handler import Callback
13
- from slixmpp.xmlstream.matcher import StanzaPath
14
-
15
- log = logging.getLogger(__name__)
16
-
17
-
18
- class XEP_0333(BasePlugin):
19
-
20
- name = "xep_0333"
21
- description = "XEP-0333: Chat Markers (slidge)"
22
- stanza = stanza
23
- dependencies = {"xep_0030"}
24
-
25
- def plugin_init(self):
26
- register_stanza_plugin(Message, Markable)
27
- register_stanza_plugin(Message, Received)
28
- register_stanza_plugin(Message, Displayed)
29
- register_stanza_plugin(Message, Acknowledged)
30
-
31
- self.xmpp.register_handler(
32
- Callback(
33
- "Received Chat Marker",
34
- StanzaPath("message/received"),
35
- self._handle_received,
36
- )
37
- )
38
- self.xmpp.register_handler(
39
- Callback(
40
- "Displayed Chat Marker",
41
- StanzaPath("message/displayed"),
42
- self._handle_displayed,
43
- )
44
- )
45
- self.xmpp.register_handler(
46
- Callback(
47
- "Acknowledged Chat Marker",
48
- StanzaPath("message/acknowledged"),
49
- self._handle_acknowledged,
50
- )
51
- )
52
-
53
- def session_bind(self, jid):
54
- self.xmpp.plugin["xep_0030"].add_feature(stanza.NS)
55
-
56
- def plugin_end(self):
57
- self.xmpp.plugin["xep_0030"].del_feature(feature=stanza.NS)
58
-
59
- def _handle_received(self, message):
60
- self.xmpp.event("marker_received", message)
61
- self.xmpp.event("marker", message)
62
-
63
- def _handle_displayed(self, message):
64
- self.xmpp.event("marker_displayed", message)
65
- self.xmpp.event("marker", message)
66
-
67
- def _handle_acknowledged(self, message):
68
- self.xmpp.event("marker_acknowledged", message)
69
- self.xmpp.event("marker", message)
70
-
71
- def send_marker(
72
- self,
73
- mto: JID,
74
- id: str,
75
- marker: str,
76
- thread: Optional[str] = None,
77
- *,
78
- mfrom: Optional[JID] = None
79
- ):
80
- """
81
- Send a chat marker.
82
-
83
- :param JID mto: recipient of the marker
84
- :param str id: Identifier of the marked message
85
- :param str marker: Marker to send (one of
86
- displayed, received, or acknowledged)
87
- :param str thread: Message thread
88
- :param str mfrom: Use a specific JID to send the message
89
- """
90
- if marker not in ("displayed", "received", "acknowledged"):
91
- raise ValueError("Invalid marker: %s" % marker)
92
- msg = self.xmpp.make_message(mto=mto, mfrom=mfrom)
93
- if thread:
94
- msg["thread"] = thread
95
- msg[marker]["id"] = id
96
- msg.send()
@@ -1,34 +0,0 @@
1
-
2
- # slixmpp: The Slick XMPP Library
3
- # Copyright (C) 2016 Emmanuel Gil Peyrot
4
- # This file is part of slixmpp.
5
- # See the file LICENSE for copying permission.
6
- from slixmpp.xmlstream import ElementBase
7
-
8
- NS ='urn:xmpp:chat-markers:0'
9
-
10
- class Markable(ElementBase):
11
- name = 'markable'
12
- plugin_attrib = 'markable'
13
- namespace = NS
14
-
15
-
16
- class Received(ElementBase):
17
- name = 'received'
18
- plugin_attrib = 'received'
19
- namespace = NS
20
- interfaces = {'id'}
21
-
22
-
23
- class Displayed(ElementBase):
24
- name = 'displayed'
25
- plugin_attrib = 'displayed'
26
- namespace = NS
27
- interfaces = {'id'}
28
-
29
-
30
- class Acknowledged(ElementBase):
31
- name = 'acknowledged'
32
- plugin_attrib = 'acknowledged'
33
- namespace = NS
34
- interfaces = {'id'}
@@ -1,7 +0,0 @@
1
- from slixmpp.plugins.base import register_plugin
2
-
3
- from . import stanza
4
- from .privilege import XEP_0356
5
- from .stanza import Perm, Privilege
6
-
7
- register_plugin(XEP_0356)
@@ -1,35 +0,0 @@
1
- import dataclasses
2
- from enum import Enum
3
-
4
-
5
- class RosterAccess(str, Enum):
6
- NONE = "none"
7
- GET = "get"
8
- SET = "set"
9
- BOTH = "both"
10
-
11
-
12
- class MessagePermission(str, Enum):
13
- NONE = "none"
14
- OUTGOING = "outgoing"
15
-
16
-
17
- class IqPermission(str, Enum):
18
- NONE = "none"
19
- GET = "get"
20
- SET = "set"
21
- BOTH = "both"
22
-
23
-
24
- class PresencePermission(str, Enum):
25
- NONE = "none"
26
- MANAGED_ENTITY = "managed_entity"
27
- ROSTER = "roster"
28
-
29
-
30
- @dataclasses.dataclass
31
- class Permissions:
32
- roster = RosterAccess.NONE
33
- message = MessagePermission.NONE
34
- iq = MessagePermission.NONE
35
- presence = PresencePermission.NONE