@@ -338,9 +338,12 @@ class SkypeGroupChat(SkypeChat):
338
338
active (bool):
339
339
Whether the full group chat was retrieved from the server. This may be ``False`` if a group conversation
340
340
still appears in the recent list despite being left or deleted.
341
+ moderated (bool):
342
+ Whether the group chat is a Skype Moderated Group.
341
343
"""
342
344
343
- attrs = SkypeChat .attrs + ("topic" , "creatorId" , "userIds" , "adminIds" , "open" , "history" , "picture" , "active" )
345
+ attrs = SkypeChat .attrs + ("topic" , "creatorId" , "userIds" , "adminIds" , "open" , "history" , "picture" , "active" ,
346
+ "moderated" )
344
347
345
348
@classmethod
346
349
def rawToFields (cls , raw = {}, active = False ):
@@ -357,6 +360,7 @@ def rawToFields(cls, raw={}, active=False):
357
360
"creatorId" : SkypeUtils .noPrefix (props .get ("creator" )),
358
361
"userIds" : userIds ,
359
362
"adminIds" : adminIds ,
363
+ "moderated" : props .get ("moderatedthread" ) == "true" ,
360
364
"open" : props .get ("joiningenabled" , "" ) == "true" ,
361
365
"history" : props .get ("historydisclosed" , "" ) == "true" ,
362
366
"picture" : props .get ("picture" , "" )[4 :] or None ,
@@ -381,6 +385,18 @@ def setTopic(self, topic):
381
385
auth = SkypeConnection .Auth .RegToken , params = {"name" : "topic" }, json = {"topic" : topic })
382
386
self .topic = topic
383
387
388
+ def setModerated (self , moderated = True ):
389
+ """
390
+ Update the chat type, and make chat moderated.
391
+
392
+ Args:
393
+ moderated (bool): whether to enable moderation restrictions
394
+ """
395
+ self .skype .conn ("PUT" , "{0}/threads/{1}/properties" .format (self .skype .conn .msgsHost , self .id ),
396
+ auth = SkypeConnection .Auth .RegToken , params = {"name" : "moderatedthread" },
397
+ json = {"moderatedthread" : moderated })
398
+ self .moderated = moderated
399
+
384
400
def setOpen (self , open ):
385
401
"""
386
402
Enable or disable joining by URL. This does not affect current participants inviting others.
@@ -492,7 +508,7 @@ def chat(self, id):
492
508
auth = SkypeConnection .Auth .RegToken , params = {"view" : "msnp24Equivalent" }).json ()
493
509
return self .merge (SkypeChat .fromRaw (self .skype , json ))
494
510
495
- def create (self , members = (), admins = ()):
511
+ def create (self , members = (), admins = (), moderated = False ):
496
512
"""
497
513
Create a new group chat with the given users.
498
514
@@ -502,17 +518,19 @@ def create(self, members=(), admins=()):
502
518
Args:
503
519
members (str list): user identifiers to initially join the conversation
504
520
admins (str list): user identifiers to gain admin privileges
521
+ moderate (bool): whether to enable moderation restrictions
505
522
506
523
Returns:
507
524
:class:`SkypeGroupChat`: newly created group conversation
508
525
"""
509
526
memberObjs = [{"id" : "8:{0}" .format (self .skype .userId ), "role" : "Admin" }]
527
+ props = {"moderatedthread" : moderated }
510
528
for id in members :
511
529
if id == self .skype .userId :
512
530
continue
513
531
memberObjs .append ({"id" : "8:{0}" .format (id ), "role" : "Admin" if id in admins else "User" })
514
532
resp = self .skype .conn ("POST" , "{0}/threads" .format (self .skype .conn .msgsHost ),
515
- auth = SkypeConnection .Auth .RegToken , json = {"members" : memberObjs })
533
+ auth = SkypeConnection .Auth .RegToken , json = {"members" : memberObjs , "properties" : props })
516
534
return self .chat (resp .headers ["Location" ].rsplit ("/" , 1 )[1 ])
517
535
518
536
@staticmethod
0 commit comments