| ... |
... |
@@ -24,6 +24,7 @@ from nbxmpp.protocol import NS_STANZAS |
|
24
|
24
|
from nbxmpp.protocol import NS_MAM_1
|
|
25
|
25
|
from nbxmpp.protocol import NS_MAM_2
|
|
26
|
26
|
from nbxmpp.protocol import NS_MUC
|
|
|
27
|
+from nbxmpp.protocol import NS_MUC_INFO
|
|
27
|
28
|
from nbxmpp.const import MessageType
|
|
28
|
29
|
from nbxmpp.const import AvatarState
|
|
29
|
30
|
from nbxmpp.const import StatusCode
|
| ... |
... |
@@ -132,6 +133,20 @@ class DiscoInfo(namedtuple('DiscoInfo', 'jid node identities features dataforms' |
|
132
|
133
|
except Exception:
|
|
133
|
134
|
return None
|
|
134
|
135
|
|
|
|
136
|
+ def _get_form_value(self, form_type, var):
|
|
|
137
|
+ for dataform in self.dataforms:
|
|
|
138
|
+ try:
|
|
|
139
|
+ is_info_form = dataform['FORM_TYPE'] != form_type
|
|
|
140
|
+ if not is_info_form:
|
|
|
141
|
+ continue
|
|
|
142
|
+
|
|
|
143
|
+ if dataform[var].type_ == 'jid-multi':
|
|
|
144
|
+ return dataform[var].values or None
|
|
|
145
|
+ return dataform[var].value or None
|
|
|
146
|
+
|
|
|
147
|
+ except Exception:
|
|
|
148
|
+ continue
|
|
|
149
|
+
|
|
135
|
150
|
@property
|
|
136
|
151
|
def is_muc(self):
|
|
137
|
152
|
for identity in self.identities:
|
| ... |
... |
@@ -139,7 +154,95 @@ class DiscoInfo(namedtuple('DiscoInfo', 'jid node identities features dataforms' |
|
139
|
154
|
if NS_MUC in self.features:
|
|
140
|
155
|
return True
|
|
141
|
156
|
return False
|
|
142
|
|
-
|
|
|
157
|
+
|
|
|
158
|
+ @property
|
|
|
159
|
+ def muc_name(self):
|
|
|
160
|
+ for identity in self.identities:
|
|
|
161
|
+ if identity.category == 'conference':
|
|
|
162
|
+ return identity.name
|
|
|
163
|
+
|
|
|
164
|
+ @property
|
|
|
165
|
+ def muc_description(self):
|
|
|
166
|
+ return self._get_form_value(NS_MUC_INFO, 'muc#roominfo_description')
|
|
|
167
|
+
|
|
|
168
|
+ @property
|
|
|
169
|
+ def muc_log_uri(self):
|
|
|
170
|
+ return self._get_form_value(NS_MUC_INFO, 'muc#roominfo_logs')
|
|
|
171
|
+
|
|
|
172
|
+ @property
|
|
|
173
|
+ def muc_users(self):
|
|
|
174
|
+ return self._get_form_value(NS_MUC_INFO, 'muc#roominfo_occupants')
|
|
|
175
|
+
|
|
|
176
|
+ @property
|
|
|
177
|
+ def muc_contacts(self):
|
|
|
178
|
+ return self._get_form_value(NS_MUC_INFO, 'muc#roominfo_contactjid')
|
|
|
179
|
+
|
|
|
180
|
+ @property
|
|
|
181
|
+ def muc_subject(self):
|
|
|
182
|
+ return self._get_form_value(NS_MUC_INFO, 'muc#roominfo_subject')
|
|
|
183
|
+
|
|
|
184
|
+ @property
|
|
|
185
|
+ def muc_subjectmod(self):
|
|
|
186
|
+ # muc#roominfo_changesubject stems from a wrong example in the MUC XEP
|
|
|
187
|
+ # Ejabberd and Prosody use this value
|
|
|
188
|
+ return (self._get_form_value(NS_MUC_INFO, 'muc#roominfo_subjectmod') or
|
|
|
189
|
+ self._get_form_value(NS_MUC_INFO, 'muc#roominfo_changesubject'))
|
|
|
190
|
+
|
|
|
191
|
+ @property
|
|
|
192
|
+ def muc_lang(self):
|
|
|
193
|
+ return self._get_form_value(NS_MUC_INFO, 'muc#roominfo_lang')
|
|
|
194
|
+
|
|
|
195
|
+ @property
|
|
|
196
|
+ def muc_has_mam(self):
|
|
|
197
|
+ return NS_MAM_2 in self.features or NS_MAM_1 in self.features
|
|
|
198
|
+
|
|
|
199
|
+ @property
|
|
|
200
|
+ def muc_is_persistent(self):
|
|
|
201
|
+ return 'muc_persistent' in self.features
|
|
|
202
|
+
|
|
|
203
|
+ @property
|
|
|
204
|
+ def muc_is_moderated(self):
|
|
|
205
|
+ return 'muc_moderated' in self.features
|
|
|
206
|
+
|
|
|
207
|
+ @property
|
|
|
208
|
+ def muc_is_open(self):
|
|
|
209
|
+ return 'muc_open' in self.features
|
|
|
210
|
+
|
|
|
211
|
+ @property
|
|
|
212
|
+ def muc_is_members_only(self):
|
|
|
213
|
+ return 'muc_membersonly' in self.features
|
|
|
214
|
+
|
|
|
215
|
+ @property
|
|
|
216
|
+ def muc_is_hidden(self):
|
|
|
217
|
+ return 'muc_hidden' in self.features
|
|
|
218
|
+
|
|
|
219
|
+ @property
|
|
|
220
|
+ def muc_is_nonanonymous(self):
|
|
|
221
|
+ return 'muc_nonanonymous' in self.features
|
|
|
222
|
+
|
|
|
223
|
+ @property
|
|
|
224
|
+ def muc_is_passwordprotected(self):
|
|
|
225
|
+ return 'muc_passwordprotected' in self.features
|
|
|
226
|
+
|
|
|
227
|
+ @property
|
|
|
228
|
+ def muc_is_public(self):
|
|
|
229
|
+ return 'muc_public' in self.features
|
|
|
230
|
+
|
|
|
231
|
+ @property
|
|
|
232
|
+ def muc_is_semianonymous(self):
|
|
|
233
|
+ return 'muc_semianonymous' in self.features
|
|
|
234
|
+
|
|
|
235
|
+ @property
|
|
|
236
|
+ def muc_is_temporary(self):
|
|
|
237
|
+ return 'muc_temporary' in self.features
|
|
|
238
|
+
|
|
|
239
|
+ @property
|
|
|
240
|
+ def muc_is_unmoderated(self):
|
|
|
241
|
+ return 'muc_unmoderated' in self.features
|
|
|
242
|
+
|
|
|
243
|
+ @property
|
|
|
244
|
+ def muc_is_unsecured(self):
|
|
|
245
|
+ return 'muc_unsecured' in self.features
|
|
143
|
246
|
|
|
144
|
247
|
|
|
145
|
248
|
class DiscoIdentity(namedtuple('DiscoIdentity', 'category type name lang')):
|