slidge 0.1.0rc1__py3-none-any.whl → 0.1.2__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- slidge/__init__.py +54 -31
- slidge/__main__.py +51 -5
- slidge/command/__init__.py +28 -0
- slidge/command/adhoc.py +258 -0
- slidge/command/admin.py +193 -0
- slidge/command/base.py +441 -0
- slidge/command/categories.py +3 -0
- slidge/command/chat_command.py +288 -0
- slidge/command/register.py +179 -0
- slidge/command/user.py +250 -0
- slidge/contact/__init__.py +8 -0
- slidge/contact/contact.py +452 -0
- slidge/contact/roster.py +192 -0
- slidge/core/__init__.py +2 -0
- slidge/core/cache.py +121 -39
- slidge/core/config.py +116 -11
- slidge/core/gateway/__init__.py +3 -0
- slidge/core/gateway/base.py +895 -0
- slidge/core/gateway/caps.py +63 -0
- slidge/core/gateway/delivery_receipt.py +52 -0
- slidge/core/gateway/disco.py +80 -0
- slidge/core/gateway/mam.py +75 -0
- slidge/core/gateway/muc_admin.py +35 -0
- slidge/core/gateway/ping.py +66 -0
- slidge/core/gateway/presence.py +95 -0
- slidge/core/gateway/registration.py +53 -0
- slidge/core/gateway/search.py +102 -0
- slidge/core/gateway/session_dispatcher.py +795 -0
- slidge/core/gateway/vcard_temp.py +130 -0
- slidge/core/mixins/__init__.py +9 -1
- slidge/core/mixins/attachment.py +506 -0
- slidge/core/mixins/avatar.py +167 -0
- slidge/core/mixins/base.py +6 -19
- slidge/core/mixins/disco.py +66 -15
- slidge/core/mixins/lock.py +31 -0
- slidge/core/mixins/message.py +254 -252
- slidge/core/mixins/message_maker.py +154 -0
- slidge/core/mixins/presence.py +128 -31
- slidge/core/mixins/recipient.py +43 -0
- slidge/core/pubsub.py +275 -116
- slidge/core/session.py +586 -518
- slidge/group/__init__.py +10 -0
- slidge/group/archive.py +125 -0
- slidge/group/bookmarks.py +163 -0
- slidge/group/participant.py +458 -0
- slidge/group/room.py +1103 -0
- slidge/migration.py +18 -0
- slidge/slixfix/__init__.py +68 -0
- slidge/{util/xep_0050 → slixfix/link_preview}/__init__.py +4 -5
- slidge/slixfix/link_preview/link_preview.py +17 -0
- slidge/slixfix/link_preview/stanza.py +99 -0
- slidge/slixfix/roster.py +60 -0
- slidge/{util → slixfix}/xep_0077/register.py +1 -2
- slidge/slixfix/xep_0077/stanza.py +104 -0
- slidge/{util → slixfix}/xep_0100/gateway.py +17 -12
- slidge/slixfix/xep_0153/__init__.py +10 -0
- slidge/slixfix/xep_0153/stanza.py +25 -0
- slidge/slixfix/xep_0153/vcard_avatar.py +23 -0
- slidge/slixfix/xep_0264/__init__.py +5 -0
- slidge/slixfix/xep_0264/stanza.py +36 -0
- slidge/slixfix/xep_0264/thumbnail.py +23 -0
- slidge/slixfix/xep_0292/__init__.py +5 -0
- slidge/slixfix/xep_0292/vcard4.py +100 -0
- slidge/slixfix/xep_0313/__init__.py +12 -0
- slidge/slixfix/xep_0313/mam.py +262 -0
- slidge/slixfix/xep_0313/stanza.py +359 -0
- slidge/slixfix/xep_0317/__init__.py +5 -0
- slidge/slixfix/xep_0317/hats.py +17 -0
- slidge/slixfix/xep_0317/stanza.py +28 -0
- slidge/{util → slixfix}/xep_0356_old/privilege.py +9 -7
- slidge/slixfix/xep_0424/__init__.py +9 -0
- slidge/slixfix/xep_0424/retraction.py +77 -0
- slidge/slixfix/xep_0424/stanza.py +28 -0
- slidge/slixfix/xep_0490/__init__.py +8 -0
- slidge/slixfix/xep_0490/mds.py +47 -0
- slidge/slixfix/xep_0490/stanza.py +17 -0
- slidge/util/__init__.py +4 -6
- slidge/util/archive_msg.py +61 -0
- slidge/util/conf.py +25 -4
- slidge/util/db.py +23 -69
- slidge/util/schema.sql +126 -0
- slidge/util/sql.py +508 -0
- slidge/util/test.py +136 -86
- slidge/util/types.py +155 -14
- slidge/util/util.py +225 -51
- slidge-0.1.2.dist-info/METADATA +111 -0
- slidge-0.1.2.dist-info/RECORD +96 -0
- {slidge-0.1.0rc1.dist-info → slidge-0.1.2.dist-info}/WHEEL +1 -1
- slidge/core/adhoc.py +0 -492
- slidge/core/chat_command.py +0 -197
- slidge/core/contact.py +0 -441
- slidge/core/disco.py +0 -59
- slidge/core/gateway.py +0 -899
- slidge/core/muc/__init__.py +0 -3
- slidge/core/muc/bookmarks.py +0 -74
- slidge/core/muc/participant.py +0 -152
- slidge/core/muc/room.py +0 -348
- slidge/plugins/discord/__init__.py +0 -121
- slidge/plugins/discord/client.py +0 -121
- slidge/plugins/discord/session.py +0 -172
- slidge/plugins/dummy.py +0 -334
- slidge/plugins/facebook.py +0 -591
- slidge/plugins/hackernews.py +0 -209
- slidge/plugins/mattermost/__init__.py +0 -1
- slidge/plugins/mattermost/api.py +0 -288
- slidge/plugins/mattermost/gateway.py +0 -417
- slidge/plugins/mattermost/websocket.py +0 -248
- slidge/plugins/signal/__init__.py +0 -4
- slidge/plugins/signal/config.py +0 -4
- slidge/plugins/signal/contact.py +0 -104
- slidge/plugins/signal/gateway.py +0 -379
- slidge/plugins/signal/group.py +0 -76
- slidge/plugins/signal/session.py +0 -515
- slidge/plugins/signal/txt.py +0 -13
- slidge/plugins/signal/util.py +0 -32
- slidge/plugins/skype.py +0 -310
- slidge/plugins/steam.py +0 -400
- slidge/plugins/telegram/__init__.py +0 -6
- slidge/plugins/telegram/client.py +0 -325
- slidge/plugins/telegram/config.py +0 -21
- slidge/plugins/telegram/contact.py +0 -154
- slidge/plugins/telegram/gateway.py +0 -182
- slidge/plugins/telegram/group.py +0 -184
- slidge/plugins/telegram/session.py +0 -275
- slidge/plugins/telegram/util.py +0 -153
- slidge/plugins/whatsapp/__init__.py +0 -6
- slidge/plugins/whatsapp/config.py +0 -17
- slidge/plugins/whatsapp/contact.py +0 -33
- slidge/plugins/whatsapp/event.go +0 -455
- slidge/plugins/whatsapp/gateway.go +0 -156
- slidge/plugins/whatsapp/gateway.py +0 -69
- slidge/plugins/whatsapp/go.mod +0 -17
- slidge/plugins/whatsapp/go.sum +0 -22
- slidge/plugins/whatsapp/session.go +0 -371
- slidge/plugins/whatsapp/session.py +0 -370
- slidge/util/xep_0030/__init__.py +0 -13
- slidge/util/xep_0030/disco.py +0 -811
- slidge/util/xep_0030/stanza/__init__.py +0 -7
- slidge/util/xep_0030/stanza/info.py +0 -270
- slidge/util/xep_0030/stanza/items.py +0 -147
- slidge/util/xep_0030/static.py +0 -467
- slidge/util/xep_0050/adhoc.py +0 -631
- slidge/util/xep_0050/stanza.py +0 -180
- slidge/util/xep_0077/stanza.py +0 -71
- slidge/util/xep_0292/__init__.py +0 -1
- slidge/util/xep_0292/stanza.py +0 -167
- slidge/util/xep_0292/vcard4.py +0 -74
- slidge/util/xep_0356/__init__.py +0 -7
- slidge/util/xep_0356/permissions.py +0 -35
- slidge/util/xep_0356/privilege.py +0 -160
- slidge/util/xep_0356/stanza.py +0 -44
- slidge/util/xep_0461/__init__.py +0 -6
- slidge/util/xep_0461/reply.py +0 -48
- slidge/util/xep_0461/stanza.py +0 -80
- slidge-0.1.0rc1.dist-info/METADATA +0 -171
- slidge-0.1.0rc1.dist-info/RECORD +0 -99
- /slidge/{plugins/__init__.py → py.typed} +0 -0
- /slidge/{util → slixfix}/xep_0077/__init__.py +0 -0
- /slidge/{util → slixfix}/xep_0100/__init__.py +0 -0
- /slidge/{util → slixfix}/xep_0100/stanza.py +0 -0
- /slidge/{util → slixfix}/xep_0356_old/__init__.py +0 -0
- /slidge/{util → slixfix}/xep_0356_old/stanza.py +0 -0
- {slidge-0.1.0rc1.dist-info → slidge-0.1.2.dist-info}/LICENSE +0 -0
- {slidge-0.1.0rc1.dist-info → slidge-0.1.2.dist-info}/entry_points.txt +0 -0
slidge/util/xep_0030/static.py
DELETED
@@ -1,467 +0,0 @@
|
|
1
|
-
# Slixmpp: The Slick XMPP Library
|
2
|
-
# Copyright (C) 2010 Nathanael C. Fritz, Lance J.T. Stout
|
3
|
-
# This file is part of Slixmpp.
|
4
|
-
# See the file LICENSE for copying permission.
|
5
|
-
from __future__ import annotations
|
6
|
-
|
7
|
-
import logging
|
8
|
-
from typing import TYPE_CHECKING, Any, Collection, Dict, Optional, Tuple, Union
|
9
|
-
|
10
|
-
from slixmpp import JID, BaseXMPP
|
11
|
-
from slixmpp.exceptions import IqError, IqTimeout, XMPPError
|
12
|
-
from slixmpp.plugins.xep_0030 import DiscoInfo, DiscoItems
|
13
|
-
from slixmpp.stanza import Iq
|
14
|
-
from slixmpp.types import OptJid, OptJidStr, TypedDict
|
15
|
-
|
16
|
-
log = logging.getLogger(__name__)
|
17
|
-
|
18
|
-
if TYPE_CHECKING:
|
19
|
-
from slixmpp.plugins.xep_0030 import XEP_0030
|
20
|
-
|
21
|
-
|
22
|
-
class NodeType(TypedDict):
|
23
|
-
info: DiscoInfo
|
24
|
-
items: DiscoItems
|
25
|
-
|
26
|
-
|
27
|
-
NodesType = Dict[
|
28
|
-
Tuple[str, str, str],
|
29
|
-
NodeType
|
30
|
-
]
|
31
|
-
|
32
|
-
|
33
|
-
class StaticDisco:
|
34
|
-
|
35
|
-
"""
|
36
|
-
While components will likely require fully dynamic handling
|
37
|
-
of service discovery information, most clients and simple bots
|
38
|
-
only need to manage a few disco nodes that will remain mostly
|
39
|
-
static.
|
40
|
-
|
41
|
-
StaticDisco provides a set of node handlers that will store
|
42
|
-
static sets of disco info and items in memory.
|
43
|
-
|
44
|
-
:var nodes: A dictionary mapping (JID, node) tuples to a dict
|
45
|
-
containing a disco#info and a disco#items stanza.
|
46
|
-
:var xmpp: The main Slixmpp object.
|
47
|
-
:var disco: The instance of the XEP-0030 plugin.
|
48
|
-
"""
|
49
|
-
|
50
|
-
def __init__(self, xmpp: 'BaseXMPP', disco: 'XEP_0030'):
|
51
|
-
"""
|
52
|
-
Create a static disco interface. Sets of disco#info and
|
53
|
-
disco#items are maintained for every given JID and node
|
54
|
-
combination. These stanzas are used to store disco
|
55
|
-
information in memory without any additional processing.
|
56
|
-
|
57
|
-
:param xmpp: The main Slixmpp object.
|
58
|
-
:param disco: The XEP-0030 plugin.
|
59
|
-
"""
|
60
|
-
self.nodes: NodesType = {}
|
61
|
-
self.xmpp: BaseXMPP = xmpp
|
62
|
-
self.disco: 'XEP_0030' = disco
|
63
|
-
|
64
|
-
def add_node(self, jid: OptJidStr = None, node: Optional[str] = None,
|
65
|
-
ifrom: OptJidStr = None) -> NodeType:
|
66
|
-
if jid is None:
|
67
|
-
node_jid = self.xmpp.boundjid.full
|
68
|
-
elif isinstance(jid, JID):
|
69
|
-
node_jid = jid.full
|
70
|
-
if ifrom is None:
|
71
|
-
node_ifrom = ''
|
72
|
-
elif isinstance(ifrom, JID):
|
73
|
-
node_ifrom = ifrom.full
|
74
|
-
else:
|
75
|
-
node_ifrom = ifrom
|
76
|
-
if node is None:
|
77
|
-
node = ''
|
78
|
-
if (node_jid, node, node_ifrom) not in self.nodes:
|
79
|
-
node_dict: NodeType = {
|
80
|
-
'info': DiscoInfo(),
|
81
|
-
'items': DiscoItems(),
|
82
|
-
}
|
83
|
-
node_dict['info']['node'] = node
|
84
|
-
node_dict['items']['node'] = node
|
85
|
-
self.nodes[(node_jid, node, node_ifrom)] = node_dict
|
86
|
-
return self.nodes[(node_jid, node, node_ifrom)]
|
87
|
-
|
88
|
-
def get_node(self, jid: OptJidStr = None, node: Optional[str] = None,
|
89
|
-
ifrom: OptJidStr = None) -> NodeType:
|
90
|
-
if jid is None:
|
91
|
-
node_jid = self.xmpp.boundjid.full
|
92
|
-
elif isinstance(jid, JID):
|
93
|
-
node_jid = jid.full
|
94
|
-
else:
|
95
|
-
node_jid = jid
|
96
|
-
if node is None:
|
97
|
-
node = ''
|
98
|
-
if ifrom is None:
|
99
|
-
node_ifrom = ''
|
100
|
-
elif isinstance(ifrom, JID):
|
101
|
-
node_ifrom = ifrom.full
|
102
|
-
else:
|
103
|
-
node_ifrom = ifrom
|
104
|
-
if (node_jid, node, node_ifrom) not in self.nodes:
|
105
|
-
self.add_node(node_jid, node, node_ifrom)
|
106
|
-
return self.nodes[(node_jid, node, node_ifrom)]
|
107
|
-
|
108
|
-
def node_exists(self, jid: OptJidStr = None, node: Optional[str] = None,
|
109
|
-
ifrom: OptJidStr = None) -> bool:
|
110
|
-
if jid is None:
|
111
|
-
node_jid = self.xmpp.boundjid.full
|
112
|
-
elif isinstance(jid, JID):
|
113
|
-
node_jid = jid.full
|
114
|
-
else:
|
115
|
-
node_jid = jid
|
116
|
-
if node is None:
|
117
|
-
node = ''
|
118
|
-
if ifrom is None:
|
119
|
-
node_ifrom = ''
|
120
|
-
elif isinstance(ifrom, JID):
|
121
|
-
node_ifrom = ifrom.full
|
122
|
-
else:
|
123
|
-
node_ifrom = ifrom
|
124
|
-
return (node_jid, node, node_ifrom) in self.nodes
|
125
|
-
|
126
|
-
# =================================================================
|
127
|
-
# Node Handlers
|
128
|
-
#
|
129
|
-
# Each handler accepts four arguments: jid, node, ifrom, and data.
|
130
|
-
# The jid and node parameters together determine the set of info
|
131
|
-
# and items stanzas that will be retrieved or added. Additionally,
|
132
|
-
# the ifrom value allows for cached results when results vary based
|
133
|
-
# on the requester's JID. The data parameter is a dictionary with
|
134
|
-
# additional parameters that will be passed to other calls.
|
135
|
-
#
|
136
|
-
# This implementation does not allow different responses based on
|
137
|
-
# the requester's JID, except for cached results. To do that,
|
138
|
-
# register a custom node handler.
|
139
|
-
|
140
|
-
async def supports(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
141
|
-
data: Any) -> Optional[bool]:
|
142
|
-
"""
|
143
|
-
Check if a JID supports a given feature.
|
144
|
-
|
145
|
-
The data parameter may provide:
|
146
|
-
|
147
|
-
:param feature: The feature to check for support.
|
148
|
-
:param local: If true, then the query is for a JID/node
|
149
|
-
combination handled by this Slixmpp instance and
|
150
|
-
no stanzas need to be sent.
|
151
|
-
Otherwise, a disco stanza must be sent to the
|
152
|
-
remove JID to retrieve the info.
|
153
|
-
:param cached: If true, then look for the disco info data from
|
154
|
-
the local cache system. If no results are found,
|
155
|
-
send the query as usual. The self.use_cache
|
156
|
-
setting must be set to true for this option to
|
157
|
-
be useful. If set to false, then the cache will
|
158
|
-
be skipped, even if a result has already been
|
159
|
-
cached. Defaults to false.
|
160
|
-
"""
|
161
|
-
feature = data.get('feature', None)
|
162
|
-
|
163
|
-
data = {'local': data.get('local', False),
|
164
|
-
'cached': data.get('cached', True)}
|
165
|
-
|
166
|
-
if not feature:
|
167
|
-
return False
|
168
|
-
|
169
|
-
try:
|
170
|
-
info = await self.disco.get_info(jid=jid, node=node,
|
171
|
-
ifrom=ifrom, **data)
|
172
|
-
info = self.disco._wrap(ifrom, jid, info, True)
|
173
|
-
features = info['disco_info']['features']
|
174
|
-
return feature in features
|
175
|
-
except IqError:
|
176
|
-
return False
|
177
|
-
except IqTimeout:
|
178
|
-
return None
|
179
|
-
|
180
|
-
async def has_identity(self, jid: OptJid, node: Optional[str],
|
181
|
-
ifrom: OptJid, data: Dict[str, Any]
|
182
|
-
) -> Optional[bool]:
|
183
|
-
"""
|
184
|
-
Check if a JID has a given identity.
|
185
|
-
|
186
|
-
The data parameter may provide:
|
187
|
-
|
188
|
-
:param category: The category of the identity to check.
|
189
|
-
:param itype: The type of the identity to check.
|
190
|
-
:param lang: The language of the identity to check.
|
191
|
-
:param local: If true, then the query is for a JID/node
|
192
|
-
combination handled by this Slixmpp instance and
|
193
|
-
no stanzas need to be sent.
|
194
|
-
Otherwise, a disco stanza must be sent to the
|
195
|
-
remove JID to retrieve the info.
|
196
|
-
:param cached: If true, then look for the disco info data from
|
197
|
-
the local cache system. If no results are found,
|
198
|
-
send the query as usual. The self.use_cache
|
199
|
-
setting must be set to true for this option to
|
200
|
-
be useful. If set to false, then the cache will
|
201
|
-
be skipped, even if a result has already been
|
202
|
-
cached. Defaults to false.
|
203
|
-
"""
|
204
|
-
identity = (data.get('category', None),
|
205
|
-
data.get('itype', None),
|
206
|
-
data.get('lang', None))
|
207
|
-
|
208
|
-
data = {'local': data.get('local', False),
|
209
|
-
'cached': data.get('cached', True)}
|
210
|
-
|
211
|
-
try:
|
212
|
-
info = await self.disco.get_info(jid=jid, node=node,
|
213
|
-
ifrom=ifrom, **data)
|
214
|
-
info = self.disco._wrap(ifrom, jid, info, True)
|
215
|
-
|
216
|
-
def trunc(i):
|
217
|
-
return (i[0], i[1], i[2])
|
218
|
-
return identity in map(trunc, info['disco_info']['identities'])
|
219
|
-
except IqError:
|
220
|
-
return False
|
221
|
-
except IqTimeout:
|
222
|
-
return None
|
223
|
-
|
224
|
-
def get_info(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
225
|
-
data: Any) -> Optional[DiscoInfo]:
|
226
|
-
"""
|
227
|
-
Return the stored info data for the requested JID/node combination.
|
228
|
-
|
229
|
-
The data parameter is not used.
|
230
|
-
"""
|
231
|
-
if not self.node_exists(jid, node):
|
232
|
-
if not node:
|
233
|
-
return DiscoInfo()
|
234
|
-
else:
|
235
|
-
raise XMPPError(condition='item-not-found')
|
236
|
-
else:
|
237
|
-
return self.get_node(jid, node)['info']
|
238
|
-
|
239
|
-
def set_info(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
240
|
-
data: DiscoInfo):
|
241
|
-
"""
|
242
|
-
Set the entire info stanza for a JID/node at once.
|
243
|
-
|
244
|
-
The data parameter is a disco#info substanza.
|
245
|
-
"""
|
246
|
-
new_node = self.add_node(jid, node)
|
247
|
-
new_node['info'] = data
|
248
|
-
|
249
|
-
def del_info(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
250
|
-
data: Any):
|
251
|
-
"""
|
252
|
-
Reset the info stanza for a given JID/node combination.
|
253
|
-
|
254
|
-
The data parameter is not used.
|
255
|
-
"""
|
256
|
-
if self.node_exists(jid, node):
|
257
|
-
self.get_node(jid, node)['info'] = DiscoInfo()
|
258
|
-
|
259
|
-
def get_items(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
260
|
-
data: Any) -> Optional[DiscoItems]:
|
261
|
-
"""
|
262
|
-
Return the stored items data for the requested JID/node combination.
|
263
|
-
|
264
|
-
The data parameter is not used.
|
265
|
-
"""
|
266
|
-
if not self.node_exists(jid, node):
|
267
|
-
if not node:
|
268
|
-
return DiscoItems()
|
269
|
-
else:
|
270
|
-
raise XMPPError(condition='item-not-found')
|
271
|
-
else:
|
272
|
-
return self.get_node(jid, node)['items']
|
273
|
-
|
274
|
-
def set_items(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
275
|
-
data: Dict[str, Collection[Tuple]]):
|
276
|
-
"""
|
277
|
-
Replace the stored items data for a JID/node combination.
|
278
|
-
|
279
|
-
The data parameter may provide:
|
280
|
-
items -- A set of items in tuple format.
|
281
|
-
"""
|
282
|
-
items = data.get('items', set())
|
283
|
-
new_node = self.add_node(jid, node)
|
284
|
-
new_node['items']['items'] = items
|
285
|
-
|
286
|
-
def del_items(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
287
|
-
data: Any):
|
288
|
-
"""
|
289
|
-
Reset the items stanza for a given JID/node combination.
|
290
|
-
|
291
|
-
The data parameter is not used.
|
292
|
-
"""
|
293
|
-
if self.node_exists(jid, node):
|
294
|
-
self.get_node(jid, node)['items'] = DiscoItems()
|
295
|
-
|
296
|
-
def add_identity(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
297
|
-
data: Dict[str, Optional[str]]):
|
298
|
-
"""
|
299
|
-
Add a new identity to the JID/node combination.
|
300
|
-
|
301
|
-
The data parameter may provide:
|
302
|
-
|
303
|
-
:param category: The general category to which the agent belongs.
|
304
|
-
:param itype: A more specific designation with the category.
|
305
|
-
:param name: Optional human readable name for this identity.
|
306
|
-
:param lang: Optional standard xml:lang value.
|
307
|
-
"""
|
308
|
-
new_node = self.add_node(jid, node)
|
309
|
-
new_node['info'].add_identity(
|
310
|
-
data.get('category', ''),
|
311
|
-
data.get('itype', ''),
|
312
|
-
data.get('name', None),
|
313
|
-
data.get('lang', None))
|
314
|
-
|
315
|
-
def set_identities(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
316
|
-
data: Dict[str, Collection[str]]):
|
317
|
-
"""
|
318
|
-
Add or replace all identities for a JID/node combination.
|
319
|
-
|
320
|
-
The data parameter should include:
|
321
|
-
|
322
|
-
:param identities: A list of identities in tuple form:
|
323
|
-
(category, type, name, lang)
|
324
|
-
"""
|
325
|
-
identities = data.get('identities', set())
|
326
|
-
new_node = self.add_node(jid, node)
|
327
|
-
new_node['info']['identities'] = identities
|
328
|
-
|
329
|
-
def del_identity(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
330
|
-
data: Dict[str, Optional[str]]):
|
331
|
-
"""
|
332
|
-
Remove an identity from a JID/node combination.
|
333
|
-
|
334
|
-
The data parameter may provide:
|
335
|
-
|
336
|
-
:param category: The general category to which the agent belonged.
|
337
|
-
:param itype: A more specific designation with the category.
|
338
|
-
:param name: Optional human readable name for this identity.
|
339
|
-
:param lang: Optional, standard xml:lang value.
|
340
|
-
"""
|
341
|
-
if self.node_exists(jid, node):
|
342
|
-
self.get_node(jid, node)['info'].del_identity(
|
343
|
-
data.get('category', ''),
|
344
|
-
data.get('itype', ''),
|
345
|
-
data.get('name', None),
|
346
|
-
data.get('lang', None))
|
347
|
-
|
348
|
-
def del_identities(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
349
|
-
data: Any):
|
350
|
-
"""
|
351
|
-
Remove all identities from a JID/node combination.
|
352
|
-
|
353
|
-
The data parameter is not used.
|
354
|
-
"""
|
355
|
-
if self.node_exists(jid, node):
|
356
|
-
del self.get_node(jid, node)['info']['identities']
|
357
|
-
|
358
|
-
def add_feature(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
359
|
-
data: Dict[str, str]):
|
360
|
-
"""
|
361
|
-
Add a feature to a JID/node combination.
|
362
|
-
|
363
|
-
The data parameter should include:
|
364
|
-
|
365
|
-
:param feature: The namespace of the supported feature.
|
366
|
-
"""
|
367
|
-
new_node = self.add_node(jid, node)
|
368
|
-
new_node['info'].add_feature(
|
369
|
-
data.get('feature', ''))
|
370
|
-
|
371
|
-
def set_features(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
372
|
-
data: Dict[str, Collection[str]]):
|
373
|
-
"""
|
374
|
-
Add or replace all features for a JID/node combination.
|
375
|
-
|
376
|
-
The data parameter should include:
|
377
|
-
|
378
|
-
:param features: The new set of supported features.
|
379
|
-
"""
|
380
|
-
features = data.get('features', set())
|
381
|
-
new_node = self.add_node(jid, node)
|
382
|
-
new_node['info']['features'] = features
|
383
|
-
|
384
|
-
def del_feature(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
385
|
-
data: Dict[str, str]):
|
386
|
-
"""
|
387
|
-
Remove a feature from a JID/node combination.
|
388
|
-
|
389
|
-
The data parameter should include:
|
390
|
-
|
391
|
-
:param feature: The namespace of the removed feature.
|
392
|
-
"""
|
393
|
-
if self.node_exists(jid, node):
|
394
|
-
self.get_node(jid, node)['info'].del_feature(
|
395
|
-
data.get('feature', ''))
|
396
|
-
|
397
|
-
def del_features(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
398
|
-
data: Any):
|
399
|
-
"""
|
400
|
-
Remove all features from a JID/node combination.
|
401
|
-
|
402
|
-
The data parameter is not used.
|
403
|
-
"""
|
404
|
-
if not self.node_exists(jid, node):
|
405
|
-
return
|
406
|
-
del self.get_node(jid, node)['info']['features']
|
407
|
-
|
408
|
-
def add_item(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
409
|
-
data: Dict[str, str]):
|
410
|
-
"""
|
411
|
-
Add an item to a JID/node combination.
|
412
|
-
|
413
|
-
The data parameter may include:
|
414
|
-
|
415
|
-
:param ijid: The JID for the item.
|
416
|
-
:param inode: Optional additional information to reference
|
417
|
-
non-addressable items.
|
418
|
-
:param name: Optional human readable name for the item.
|
419
|
-
"""
|
420
|
-
new_node = self.add_node(jid, node)
|
421
|
-
new_node['items'].add_item(
|
422
|
-
data.get('ijid', ''),
|
423
|
-
node=data.get('inode', ''),
|
424
|
-
name=data.get('name', ''))
|
425
|
-
|
426
|
-
def del_item(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
427
|
-
data: Dict[str, str]):
|
428
|
-
"""
|
429
|
-
Remove an item from a JID/node combination.
|
430
|
-
|
431
|
-
The data parameter may include:
|
432
|
-
|
433
|
-
:param ijid: JID of the item to remove.
|
434
|
-
:param inode: Optional extra identifying information.
|
435
|
-
"""
|
436
|
-
if self.node_exists(jid, node):
|
437
|
-
self.get_node(jid, node)['items'].del_item(
|
438
|
-
data.get('ijid', ''),
|
439
|
-
node=data.get('inode', None))
|
440
|
-
|
441
|
-
def cache_info(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
442
|
-
data: Union[Iq, DiscoInfo]):
|
443
|
-
"""
|
444
|
-
Cache disco information for an external JID.
|
445
|
-
|
446
|
-
The data parameter is the Iq result stanza
|
447
|
-
containing the disco info to cache, or
|
448
|
-
the disco#info substanza itself.
|
449
|
-
"""
|
450
|
-
if isinstance(data, Iq):
|
451
|
-
info = data['disco_info']
|
452
|
-
else:
|
453
|
-
info = data
|
454
|
-
|
455
|
-
new_node = self.add_node(jid, node, ifrom)
|
456
|
-
new_node['info'] = info
|
457
|
-
|
458
|
-
def get_cached_info(self, jid: OptJid, node: Optional[str], ifrom: OptJid,
|
459
|
-
data: Any) -> Optional[DiscoInfo]:
|
460
|
-
"""
|
461
|
-
Retrieve cached disco info data.
|
462
|
-
|
463
|
-
The data parameter is not used.
|
464
|
-
"""
|
465
|
-
if not self.node_exists(jid, node, ifrom):
|
466
|
-
return None
|
467
|
-
return self.get_node(jid, node, ifrom)['info']
|