fix
This commit is contained in:
parent
56968b7dd5
commit
c119e6c88b
@ -11,6 +11,8 @@ from .analyzer.db_parsing import read_img_dat, read_emoji, decompress_CompressCo
|
|||||||
parse_xml_string, read_BytesExtra
|
parse_xml_string, read_BytesExtra
|
||||||
from .analyzer import export_csv, export_json, DBPool
|
from .analyzer import export_csv, export_json, DBPool
|
||||||
from .ui import app_show_chat, get_user_list, export
|
from .ui import app_show_chat, get_user_list, export
|
||||||
|
from .dbpreprocess import get_user_list, get_recent_user_list, wxid2userinfo, ParsingMSG, ParsingMicroMsg, \
|
||||||
|
ParsingMediaMSG, ParsingOpenIMContact
|
||||||
from .server import start_falsk
|
from .server import start_falsk
|
||||||
|
|
||||||
import os, json
|
import os, json
|
||||||
@ -26,4 +28,4 @@ except:
|
|||||||
PYWXDUMP_ROOT_PATH = os.path.dirname(__file__)
|
PYWXDUMP_ROOT_PATH = os.path.dirname(__file__)
|
||||||
db_init = DBPool("DBPOOL_INIT")
|
db_init = DBPool("DBPOOL_INIT")
|
||||||
|
|
||||||
__version__ = "3.0.0"
|
__version__ = "3.0.1"
|
||||||
|
@ -6,7 +6,9 @@
|
|||||||
# Date: 2024/04/15
|
# Date: 2024/04/15
|
||||||
# -------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------
|
||||||
from .dbbase import DatabaseBase
|
from .dbbase import DatabaseBase
|
||||||
from .utils import timestamp2str
|
from .utils import timestamp2str, bytes2str
|
||||||
|
|
||||||
|
import blackboxprotobuf
|
||||||
|
|
||||||
|
|
||||||
class ParsingMicroMsg(DatabaseBase):
|
class ParsingMicroMsg(DatabaseBase):
|
||||||
@ -15,6 +17,26 @@ class ParsingMicroMsg(DatabaseBase):
|
|||||||
def __init__(self, db_path):
|
def __init__(self, db_path):
|
||||||
super().__init__(db_path)
|
super().__init__(db_path)
|
||||||
|
|
||||||
|
def get_BytesExtra(self, BytesExtra):
|
||||||
|
if BytesExtra is None or not isinstance(BytesExtra, bytes):
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
deserialize_data, message_type = blackboxprotobuf.decode_message(BytesExtra)
|
||||||
|
return deserialize_data
|
||||||
|
except Exception as e:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def ChatRoom_RoomData(self, RoomData):
|
||||||
|
# 读取群聊数据,主要为 wxid,以及对应昵称
|
||||||
|
if RoomData is None or not isinstance(RoomData, bytes):
|
||||||
|
return None
|
||||||
|
try:
|
||||||
|
data = self.get_BytesExtra(RoomData)
|
||||||
|
bytes2str(data)
|
||||||
|
return data
|
||||||
|
except Exception as e:
|
||||||
|
return None
|
||||||
|
|
||||||
def wxid2userinfo(self, wxid):
|
def wxid2userinfo(self, wxid):
|
||||||
"""
|
"""
|
||||||
获取单个联系人信息
|
获取单个联系人信息
|
||||||
@ -93,7 +115,7 @@ class ParsingMicroMsg(DatabaseBase):
|
|||||||
{"wxid": username, "LastReadedCreateTime": LastReadedCreateTime, "LastReadedSvrId": LastReadedSvrId})
|
{"wxid": username, "LastReadedCreateTime": LastReadedCreateTime, "LastReadedSvrId": LastReadedSvrId})
|
||||||
return users
|
return users
|
||||||
|
|
||||||
def chatroom_list(self):
|
def chatroom_list(self, roomwxid=None):
|
||||||
"""
|
"""
|
||||||
获取群聊列表
|
获取群聊列表
|
||||||
:param MicroMsg_db_path: MicroMsg.db 文件路径
|
:param MicroMsg_db_path: MicroMsg.db 文件路径
|
||||||
@ -101,19 +123,32 @@ class ParsingMicroMsg(DatabaseBase):
|
|||||||
"""
|
"""
|
||||||
rooms = []
|
rooms = []
|
||||||
# 连接 MicroMsg.db 数据库,并执行查询
|
# 连接 MicroMsg.db 数据库,并执行查询
|
||||||
sql = ("SELECT A.ChatRoomName,A.UserNameList, A.DisplayNameList, B.Announcement,B.AnnouncementEditor "
|
sql = (
|
||||||
"FROM ChatRoom A,ChatRoomInfo B "
|
"SELECT A.ChatRoomName,A.UserNameList, A.DisplayNameList,A.RoomData, B.Announcement,B.AnnouncementEditor "
|
||||||
"where A.ChatRoomName==B.ChatRoomName "
|
"FROM ChatRoom A,ChatRoomInfo B "
|
||||||
"ORDER BY A.ChatRoomName ASC;")
|
"where A.ChatRoomName==B.ChatRoomName "
|
||||||
|
"ORDER BY A.ChatRoomName ASC;")
|
||||||
|
if roomwxid:
|
||||||
|
sql = sql.replace("ORDER BY A.ChatRoomName ASC;",
|
||||||
|
f"where A.ChatRoomName LIKE '%{roomwxid}%' "
|
||||||
|
"ORDER BY A.ChatRoomName ASC;")
|
||||||
result = self.execute_sql(sql)
|
result = self.execute_sql(sql)
|
||||||
|
room_datas = []
|
||||||
for row in result:
|
for row in result:
|
||||||
# 获取用户名、昵称、备注和聊天记录数量
|
# 获取用户名、昵称、备注和聊天记录数量
|
||||||
ChatRoomName, UserNameList, DisplayNameList, Announcement, AnnouncementEditor = row
|
ChatRoomName, UserNameList, DisplayNameList, RoomData, Announcement, AnnouncementEditor = row
|
||||||
UserNameList = UserNameList.split("^G")
|
UserNameList = UserNameList.split("^G")
|
||||||
DisplayNameList = DisplayNameList.split("^G")
|
DisplayNameList = DisplayNameList.split("^G")
|
||||||
|
RoomData = self.ChatRoom_RoomData(RoomData)
|
||||||
|
rd = []
|
||||||
|
if RoomData:
|
||||||
|
for k, v in RoomData.items():
|
||||||
|
if isinstance(v, list):
|
||||||
|
rd += v
|
||||||
|
room_datas.append(rd)
|
||||||
|
else:
|
||||||
|
print(f"ChatRoomName:{ChatRoomName} RoomData is None")
|
||||||
rooms.append(
|
rooms.append(
|
||||||
{"ChatRoomName": ChatRoomName, "UserNameList": UserNameList, "DisplayNameList": DisplayNameList,
|
{"ChatRoomName": ChatRoomName, "UserNameList": UserNameList, "DisplayNameList": DisplayNameList,
|
||||||
"Announcement": Announcement, "AnnouncementEditor": AnnouncementEditor})
|
"Announcement": Announcement, "AnnouncementEditor": AnnouncementEditor})
|
||||||
return rooms
|
return rooms
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user