Skip to content

Commit 5763e06

Browse files
committed
Enhance group functionality: add join and create group result types, update group methods, and increment version to 0.1.2
1 parent 498303f commit 5763e06

3 files changed

Lines changed: 9 additions & 14 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
StealthIMSDK.egg-info
2+
stealthimpysdk.egg-info
23
__pycache__

StealthIM/group.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import StealthIM
22
from StealthIM import User
33
from StealthIM.apis.group import GroupInfoResult, GroupPublicInfoResult, InviteGroupResult, \
4-
GroupMemberType, SetMemberRoleResult, KickMemberResult, ChangeGroupNameResult, ChangeGroupPasswordResult
4+
GroupMemberType, SetMemberRoleResult, KickMemberResult, ChangeGroupNameResult, ChangeGroupPasswordResult, \
5+
JoinGroupResult, CreateGroupResult
56
from StealthIM.apis.message import SendMessageResult
67

78

@@ -11,7 +12,7 @@ def __init__(self, user: User, group_id: int):
1112
self.group_id = group_id
1213

1314
@classmethod
14-
async def create(cls, user: User, group_name: str) -> "Group":
15+
async def create(cls, user: User, group_name: str) -> CreateGroupResult:
1516
"""
1617
Create a new Group.
1718
@@ -25,19 +26,14 @@ async def create(cls, user: User, group_name: str) -> "Group":
2526
Raises:
2627
RuntimeError: If the request failed.
2728
"""
28-
res = await StealthIM.apis.group.create_group(user.server.url, user.session, group_name)
29-
if res.result.code != 800:
30-
raise RuntimeError(res.result.msg)
31-
return cls(user, res.groupid)
29+
return await StealthIM.apis.group.create_group(user.server.url, user.session, group_name)
3230

33-
@classmethod
34-
async def join(cls, user: User, group_id: int, password: str) -> "Group":
31+
async def join(self, password: str) -> JoinGroupResult:
3532
"""
3633
Join a Group.
3734
3835
Args:
3936
user (User): The user to join.
40-
group_id (int): The ID of the group.
4137
password (str): The password.
4238
4339
Returns:
@@ -46,10 +42,8 @@ async def join(cls, user: User, group_id: int, password: str) -> "Group":
4642
Raises:
4743
RuntimeError: If the request failed.
4844
"""
49-
res = await StealthIM.apis.group.join_group(user.server.url, user.session, group_id, password)
50-
if res.result.code != 800:
51-
raise RuntimeError(res.result.msg)
52-
return cls(user, group_id)
45+
return await StealthIM.apis.group.join_group(self.user.server.url, self.user.session, self.group_id, password)
46+
5347

5448
async def get_members(self) -> GroupInfoResult:
5549
"""

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "stealthimpysdk" # pip 安装名
7-
version = "0.1.1" # 版本
7+
version = "0.1.2" # 版本
88
description = "The SDK for StealthIM"
99
readme = "README.md"
1010
license = {file = "LICENSE"}

0 commit comments

Comments
 (0)