Skip to content

Commit 7a912fe

Browse files
committed
增加数据库读取群成员备注功能
1 parent 59cc5ff commit 7a912fe

File tree

4 files changed

+214
-0
lines changed

4 files changed

+214
-0
lines changed

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
install_requires=[
2525
"requests",
2626
"pydantic",
27+
"protobuf==3.20.1",
2728
],
2829
long_description=long_description,
2930
long_description_content_type="text/markdown",

wechatrobot/Api.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import requests
33
import json
44
from .Modles import *
5+
import base64
6+
from wechatrobot import ChatRoomData_pb2 as ChatRoom
57

68
class Api:
79
port : int = 18888
@@ -151,6 +153,22 @@ def GetPictureBySql(self):
151153
self.db_handle = self.GetDBHandle()
152154
sql = "select usrName,bigHeadImgUrl from ContactHeadImgUrl"
153155
return self.QueryDatabase(db_handle=self.db_handle,sql=sql)
156+
157+
def GetAllGroupMembersBySql(self) -> Dict:
158+
group_data = {} #{"group_id" : { "wxID" : "displayName"}}
159+
if not self.db_handle:
160+
self.db_handle = self.GetDBHandle()
161+
sql = "select ChatRoomName,RoomData from ChatRoom"
162+
GroupMemberList = self.QueryDatabase(db_handle = self.db_handle, sql = sql)['data']
163+
chatroom = ChatRoom.ChatRoomData()
164+
for index in range(1 , len(GroupMemberList)):
165+
group_member = {}
166+
chatroom.ParseFromString(bytes(base64.b64decode(GroupMemberList[index][1])))
167+
for k in chatroom.members:
168+
if k.displayName != "":
169+
group_member[k.wxID] = k.displayName
170+
group_data[GroupMemberList[index][0]] = group_member
171+
return group_data
154172
#自定义]
155173

156174
def post(self , type : int, params : Body) -> Dict:

wechatrobot/ChatRoomData.proto

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
syntax = "proto3";
2+
package RS_WXBOT_COM.protobuf;
3+
4+
message ChatRoomData {
5+
6+
message ChatRoomMember {
7+
string wxID = 1;
8+
string displayName = 2;
9+
int32 state = 3;
10+
}
11+
12+
repeated ChatRoomMember members = 1;
13+
14+
int32 field_2 = 2;
15+
int32 field_3 = 3;
16+
int32 field_4 = 4;
17+
int32 room_capacity = 5;
18+
int32 field_6 = 6;
19+
int64 field_7 = 7;
20+
int64 field_8 = 8;
21+
}

wechatrobot/ChatRoomData_pb2.py

Lines changed: 174 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)