Skip to content

Commit

Permalink
Add support for updating group avatar and access control.
Browse files Browse the repository at this point in the history
Co-authored-by: Lazlo Westerhof <[email protected]>
  • Loading branch information
sks444 and lwesterhof authored Jul 22, 2023
1 parent cfb1f27 commit cb9d61b
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
32 changes: 32 additions & 0 deletions semaphore/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,35 @@ async def update_group_role(self,
:return: Returns the updated GroupV2 object
"""
return await self._sender.update_group_role(group_id, member_id, role)

async def update_group_avatar(self, group_id: str, avatar: str) -> GroupV2:
"""
Change a group’s avatar.
:param group_id: Identifier of the group to update avatar for
:param avatar: Path to group avatar file
:return: Returns the updated GroupV2 object
"""
return await self._sender.update_group_avatar(group_id, avatar)

async def update_group_access_control(self,
group_id: str,
access_control: str,
role: str) -> GroupV2:
"""
Change a group’s access control.
:param group_id: Identifier of the group to update avatar for
:param access_control: Name of the access control,
options are: attributes|members|link
:param role: Set the role of an access control:
for attributes otions are: UNSATISFIABLE|ADMINISTRATOR|ANY
for members otions are: MEMBER|ADMINISTRATOR
for link options are: MEMBER|ADMINISTRATOR
:return: Returns the updated GroupV2 object
"""
return await self._sender.update_group_access_control(
group_id, access_control, role
)
44 changes: 44 additions & 0 deletions semaphore/message_sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,3 +566,47 @@ async def update_group_role(self,
'uuid': member_id
}
})

async def update_group_avatar(self, group_id: str, group_avatar: str) -> GroupV2:
"""
Change a group’s avatar.
:param group_id: Identifier of the group to update avatar for
:param group_avatar: Path to group avatar file
:return: Returns the updated GroupV2 object
"""
return await self._send({
"type": "update_group",
"version": "v1",
"account": self._username,
"groupID": group_id,
"avatar": group_avatar,
})

async def update_group_access_control(self,
group_id: str,
access_control: str,
role: str) -> GroupV2:
"""
Change a group’s access control.
:param group_id: Identifier of the group to update avatar for
:param access_control: Name of the access control,
options are: attributes|members|link
:param role: Set the role of an access control:
for attributes otions are: UNSATISFIABLE|ADMINISTRATOR|ANY
for members otions are: MEMBER|ADMINISTRATOR
for link options are: MEMBER|ADMINISTRATOR
:return: Returns the updated GroupV2 object
"""
return await self._send({
"type": "update_group",
"version": "v1",
"account": self._username,
"groupID": group_id,
"updateAccessControl": {
access_control: role
},
})

0 comments on commit cb9d61b

Please sign in to comment.