增加了单api的运行和返回聊天中所有用户接口 (#73)

add msg only api、add 单api运行方式、增加返回会话所有用户信息接口
This commit is contained in:
LVtomatoJ authored and GitHub committed 2024-02-04 11:28:30 +08:00
1 parent b8adbf1a96
commit 9e2f305921
3 files changed
+131 -1

No files matched your search

+40
View File
@@ -13,6 +13,7 @@ import shutil
from flask import Flask, request, render_template, g, Blueprint, send_file, make_response, session
from pywxdump import analyzer, read_img_dat, read_audio, get_wechat_db, get_core_db
from pywxdump.analyzer.export_chat import get_contact, get_room_user_list
from pywxdump.api.rjson import ReJson, RqJson
from pywxdump.api.utils import read_session, save_session, error9999
from pywxdump import read_info, VERSION_LIST, batch_decrypt, BiasAddr, merge_db, decrypt_merge
@@ -190,6 +191,45 @@ def contact_count_list():
except Exception as e:
return ReJson(9999, msg=str(e))
@api.route('/api/msgs_user_list',methods=['GET','POST'])
@error9999
def get_msg_user_list():
msg_path = request.headers.get("msg_path")
micro_path = request.headers.get("micro_path")
if not msg_path:
msg_path = read_session(g.sf, "msg_path")
if not micro_path:
micro_path = read_session(g.sf, "micro_path")
wxid = request.json.get("wxid")
# msg_list = analyzer.get_msg_list(msg_path, wxid, start_index=start, page_size=limit)
my_wxid = read_session(g.sf, "my_wxid")
userlist = []
if wxid.endswith("@chatroom"):
# 群聊
userlist = get_room_user_list(msg_path, wxid)
else:
# 单聊
user = get_contact(micro_path, wxid)
my_user = get_contact(micro_path,my_wxid)
userlist.append(user)
userlist.append(my_user)
return ReJson(0, {"user_list":userlist})
@api.route('/api/msgs_list',methods=['GET','POST'])
@error9999
def get_msg_list():
msg_path = request.headers.get("msg_path")
micro_path = request.headers.get("micro_path")
if not msg_path:
msg_path = read_session(g.sf, "msg_path")
if not micro_path:
micro_path = read_session(g.sf, "micro_path")
start = request.json.get("start")
limit = request.json.get("limit")
wxid = request.json.get("wxid")
my_wxid = read_session(g.sf, "my_wxid")
msg_list = analyzer.get_msg_list(msg_path, wxid, start_index=start, page_size=limit)
return ReJson(0, {"msg_list":msg_list,'my_wxid':my_wxid})
@api.route('/api/msgs', methods=["GET", 'POST'])
@error9999