Skip to content
This repository was archived by the owner on Jun 11, 2025. It is now read-only.

Commit 225f2f3

Browse files
committed
Fix parsing of moderated chat flag, tweak docs
1 parent c81ba42 commit 225f2f3

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

skpy/chat.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,12 @@ class SkypeGroupChat(SkypeChat):
338338
active (bool):
339339
Whether the full group chat was retrieved from the server. This may be ``False`` if a group conversation
340340
still appears in the recent list despite being left or deleted.
341+
moderated (bool):
342+
Whether the group chat is a Skype Moderated Group.
341343
"""
342344

343-
attrs = SkypeChat.attrs + ("topic", "creatorId", "userIds", "adminIds", "open", "history", "picture", "active", "moderatedthread")
345+
attrs = SkypeChat.attrs + ("topic", "creatorId", "userIds", "adminIds", "open", "history", "picture", "active",
346+
"moderated")
344347

345348
@classmethod
346349
def rawToFields(cls, raw={}, active=False):
@@ -357,11 +360,11 @@ def rawToFields(cls, raw={}, active=False):
357360
"creatorId": SkypeUtils.noPrefix(props.get("creator")),
358361
"userIds": userIds,
359362
"adminIds": adminIds,
363+
"moderated": props.get("moderatedthread") == "true",
360364
"open": props.get("joiningenabled", "") == "true",
361365
"history": props.get("historydisclosed", "") == "true",
362366
"picture": props.get("picture", "")[4:] or None,
363-
"active": active,
364-
"moderatedthread": props.get("moderatedthread")})
367+
"active": active})
365368
return fields
366369

367370
@property
@@ -382,16 +385,17 @@ def setTopic(self, topic):
382385
auth=SkypeConnection.Auth.RegToken, params={"name": "topic"}, json={"topic": topic})
383386
self.topic = topic
384387

385-
def setModerated(self, moderate=True):
388+
def setModerated(self, moderated=True):
386389
"""
387390
Update the chat type, and make chat moderated.
388391
389392
Args:
390-
moderate (bool): moderating value. True as default
393+
moderated (bool): whether to enable moderation restrictions
391394
"""
392395
self.skype.conn("PUT", "{0}/threads/{1}/properties".format(self.skype.conn.msgsHost, self.id),
393-
auth=SkypeConnection.Auth.RegToken, params={"name": "moderatedthread"}, json={"moderatedthread": moderate})
394-
self.moderatedthread = moderate
396+
auth=SkypeConnection.Auth.RegToken, params={"name": "moderatedthread"},
397+
json={"moderatedthread": moderated})
398+
self.moderated = moderated
395399

396400
def setOpen(self, open):
397401
"""
@@ -509,12 +513,12 @@ def create(self, members=(), admins=(), moderated=False):
509513
Create a new group chat with the given users.
510514
511515
The current user is automatically added to the conversation as an admin. Any other admin identifiers must also
512-
be present in the member list. You can also make the chat moderated by passing moderated value
516+
be present in the member list.
513517
514518
Args:
515519
members (str list): user identifiers to initially join the conversation
516520
admins (str list): user identifiers to gain admin privileges
517-
moderate (bool): moderating value. False as default
521+
moderate (bool): whether to enable moderation restrictions
518522
519523
Returns:
520524
:class:`SkypeGroupChat`: newly created group conversation

0 commit comments

Comments
 (0)