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

Commit c81ba42

Browse files
committed
changed name and description for method setIsModerate, added "modearted" attr in attrs tuple, and populated it during rawToFields, changed group chat creation method for adding moderated attr
1 parent 4c34600 commit c81ba42

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
manual_test.py
2+
__pycache__/
3+
*.tokens-app

skpy/chat.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ class SkypeGroupChat(SkypeChat):
340340
still appears in the recent list despite being left or deleted.
341341
"""
342342

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

345345
@classmethod
346346
def rawToFields(cls, raw={}, active=False):
@@ -360,7 +360,8 @@ def rawToFields(cls, raw={}, active=False):
360360
"open": props.get("joiningenabled", "") == "true",
361361
"history": props.get("historydisclosed", "") == "true",
362362
"picture": props.get("picture", "")[4:] or None,
363-
"active": active})
363+
"active": active,
364+
"moderatedthread": props.get("moderatedthread")})
364365
return fields
365366

366367
@property
@@ -381,12 +382,12 @@ def setTopic(self, topic):
381382
auth=SkypeConnection.Auth.RegToken, params={"name": "topic"}, json={"topic": topic})
382383
self.topic = topic
383384

384-
def setIsModerateThread(self, moderate=True):
385+
def setModerated(self, moderate=True):
385386
"""
386-
Update the chat type, and make chat moderated. An empty value make chat moderating.
387+
Update the chat type, and make chat moderated.
387388
388389
Args:
389-
moderate (bool): moderating value
390+
moderate (bool): moderating value. True as default
390391
"""
391392
self.skype.conn("PUT", "{0}/threads/{1}/properties".format(self.skype.conn.msgsHost, self.id),
392393
auth=SkypeConnection.Auth.RegToken, params={"name": "moderatedthread"}, json={"moderatedthread": moderate})
@@ -503,27 +504,29 @@ def chat(self, id):
503504
auth=SkypeConnection.Auth.RegToken, params={"view": "msnp24Equivalent"}).json()
504505
return self.merge(SkypeChat.fromRaw(self.skype, json))
505506

506-
def create(self, members=(), admins=()):
507+
def create(self, members=(), admins=(), moderated=False):
507508
"""
508509
Create a new group chat with the given users.
509510
510511
The current user is automatically added to the conversation as an admin. Any other admin identifiers must also
511-
be present in the member list.
512+
be present in the member list. You can also make the chat moderated by passing moderated value
512513
513514
Args:
514515
members (str list): user identifiers to initially join the conversation
515516
admins (str list): user identifiers to gain admin privileges
517+
moderate (bool): moderating value. False as default
516518
517519
Returns:
518520
:class:`SkypeGroupChat`: newly created group conversation
519521
"""
520522
memberObjs = [{"id": "8:{0}".format(self.skype.userId), "role": "Admin"}]
523+
props = {"moderatedthread": moderated}
521524
for id in members:
522525
if id == self.skype.userId:
523526
continue
524527
memberObjs.append({"id": "8:{0}".format(id), "role": "Admin" if id in admins else "User"})
525528
resp = self.skype.conn("POST", "{0}/threads".format(self.skype.conn.msgsHost),
526-
auth=SkypeConnection.Auth.RegToken, json={"members": memberObjs})
529+
auth=SkypeConnection.Auth.RegToken, json={"members": memberObjs, "properties": props})
527530
return self.chat(resp.headers["Location"].rsplit("/", 1)[1])
528531

529532
@staticmethod

0 commit comments

Comments
 (0)