diff --git a/python/ichika/core/__init__.pyi b/python/ichika/core/__init__.pyi index 88e0586..8482f5e 100644 --- a/python/ichika/core/__init__.pyi +++ b/python/ichika/core/__init__.pyi @@ -188,15 +188,19 @@ class PlumbingClient: async def get_group_raw(self, uin: int) -> Group: ... async def find_group(self, uin: int) -> Group | None: ... async def get_groups(self) -> VTuple[Group]: ... + async def get_group_admins(self, uin: int) -> list[tuple[int, int]]: ... + async def mute_group(self, uin: int, mute: bool) -> None: ... + async def quit_group(self, uin: int) -> None: ... # [impl 4] async def get_member(self, group_uin: int, uin: int) -> Member: ... async def get_member_raw(self, group_uin: int, uin: int) -> Member: ... async def nudge_member(self, group_uin: int, uin: int) -> None: ... # Duration -> 0: Unmute async def mute_member(self, group_uin: int, uin: int, duration: int) -> None: ... - async def mute_group(self, uin: int, mute: bool) -> None: ... - async def quit_group(self, uin: int) -> None: ... async def kick_member(self, group_uin: int, uin: int, msg: str, block: bool) -> None: ... + async def modify_member_special_title(self, group_uin: int, uin: int, special_title: str) -> None: ... + async def modify_member_card(self, group_uin: int, uin: int, card_name: str) -> None: ... + async def modify_member_admin(self, group_uin: int, uin: int, admin: bool) -> None: ... # [impl 5] async def upload_friend_image(self, uin: int, data: bytes) -> dict[str, Any]: ... async def send_friend_message(self, uin: int, chain: list[dict[str, Any]]) -> RawMessageReceipt: ... diff --git a/src/client/mod.rs b/src/client/mod.rs index e2ea0a2..76f4e18 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -266,6 +266,35 @@ impl PlumbingClient { })) }) } + + pub fn get_group_admins<'py>(&self, py: Python<'py>, uin: i64) -> PyResult<&'py PyAny> { + let client = self.client.clone(); + py_future(py, async move { + let admins = client + .get_group_admin_list(uin) + .await? + .into_iter() + .map(|(member_uin, perm)| (member_uin, perm as u8)) + .collect::>(); // TODO: Better Perm handling + Ok(admins) + }) + } + + pub fn mute_group<'py>(&self, py: Python<'py>, uin: i64, mute: bool) -> PyResult<&'py PyAny> { + let client = self.client.clone(); + py_future(py, async move { + client.group_mute_all(uin, mute).await?; + Ok(()) + }) + } + + pub fn quit_group<'py>(&self, py: Python<'py>, uin: i64) -> PyResult<&'py PyAny> { + let client = self.client.clone(); + py_future(py, async move { + client.group_quit(uin).await?; + Ok(()) + }) + } } #[pymethods] @@ -327,33 +356,63 @@ impl PlumbingClient { }) } - pub fn mute_group<'py>(&self, py: Python<'py>, uin: i64, mute: bool) -> PyResult<&'py PyAny> { + pub fn kick_member<'py>( + &self, + py: Python<'py>, + group_uin: i64, + uin: i64, + msg: String, + block: bool, + ) -> PyResult<&'py PyAny> { let client = self.client.clone(); py_future(py, async move { - client.group_mute_all(uin, mute).await?; + client.group_kick(group_uin, vec![uin], &msg, block).await?; Ok(()) }) } - pub fn quit_group<'py>(&self, py: Python<'py>, uin: i64) -> PyResult<&'py PyAny> { + pub fn modify_member_special_title<'py>( + &self, + py: Python<'py>, + group_uin: i64, + uin: i64, + special_title: String, + ) -> PyResult<&'py PyAny> { let client = self.client.clone(); py_future(py, async move { - client.group_quit(uin).await?; + client + .group_edit_special_title(group_uin, uin, special_title) + .await?; Ok(()) }) } - pub fn kick_member<'py>( + pub fn modify_member_card<'py>( &self, py: Python<'py>, group_uin: i64, uin: i64, - msg: String, - block: bool, + card_name: String, ) -> PyResult<&'py PyAny> { let client = self.client.clone(); py_future(py, async move { - client.group_kick(group_uin, vec![uin], &msg, block).await?; + client + .edit_group_member_card(group_uin, uin, card_name) + .await?; + Ok(()) + }) + } + + pub fn modify_member_admin<'py>( + &self, + py: Python<'py>, + group_uin: i64, + uin: i64, + admin: bool, + ) -> PyResult<&'py PyAny> { + let client = self.client.clone(); + py_future(py, async move { + client.group_set_admin(group_uin, uin, admin).await?; Ok(()) }) }