mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-22 10:52:18 +08:00
导出word文档
This commit is contained in:
parent
f5989290f9
commit
3a5bd4d5d5
@ -121,11 +121,14 @@ def get_conRemark(username):
|
|||||||
else:
|
else:
|
||||||
return result[1]
|
return result[1]
|
||||||
|
|
||||||
|
|
||||||
def get_nickname(username):
|
def get_nickname(username):
|
||||||
sql = 'select nickname,alias from rcontact where username=?'
|
sql = 'select nickname,alias from rcontact where username=?'
|
||||||
cursor.execute(sql, [username])
|
cursor.execute(sql, [username])
|
||||||
result = cursor.fetchone()
|
result = cursor.fetchone()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def avatar_md5(wxid):
|
def avatar_md5(wxid):
|
||||||
m = hashlib.md5()
|
m = hashlib.md5()
|
||||||
# 参数必须是byte类型,否则报Unicode-objects must be encoded before hashing错误
|
# 参数必须是byte类型,否则报Unicode-objects must be encoded before hashing错误
|
||||||
@ -160,6 +163,43 @@ def get_message(wxid, num):
|
|||||||
return cursor.fetchall()
|
return cursor.fetchall()
|
||||||
|
|
||||||
|
|
||||||
|
def search_send_message(start_time, end_time):
|
||||||
|
start_time = '2022-1-1 00:00:00'
|
||||||
|
end_time = '2023-1-1 00:00:00'
|
||||||
|
start = time.mktime(time.strptime(start_time, '%Y-%m-%d %H:%M:%S'))
|
||||||
|
end = time.mktime(time.strptime(end_time, '%Y-%m-%d %H:%M:%S'))
|
||||||
|
sql = '''
|
||||||
|
select count(*) from message
|
||||||
|
where createTime >? and createTime < ? and isSend=0 and talker like '%wxid%';
|
||||||
|
'''
|
||||||
|
cursor.execute(sql,[start*1000 , end*1000])
|
||||||
|
return cursor.fetchone()
|
||||||
|
|
||||||
|
|
||||||
|
def clearImagePath(imgpath):
|
||||||
|
path = imgpath.split('/')
|
||||||
|
newPath = '/'.join(path[:-1]) + '/' + path[-1][3:] + '.jpg'
|
||||||
|
if os.path.exists(newPath):
|
||||||
|
return newPath
|
||||||
|
newPath = '/'.join(path[:-1]) + '/' + path[-1][3:] + '.png'
|
||||||
|
if os.path.exists(newPath):
|
||||||
|
return newPath
|
||||||
|
newPath = '/'.join(path[:-1]) + '/' + path[-1] + 'hd'
|
||||||
|
if os.path.exists(newPath):
|
||||||
|
return newPath
|
||||||
|
return imgpath
|
||||||
|
|
||||||
|
|
||||||
|
def get_all_message(wxid):
|
||||||
|
sql = '''
|
||||||
|
select * from message
|
||||||
|
where talker = ?
|
||||||
|
order by msgId
|
||||||
|
'''
|
||||||
|
cursor.execute(sql, [wxid])
|
||||||
|
return cursor.fetchall()
|
||||||
|
|
||||||
|
|
||||||
def get_emoji(imgPath):
|
def get_emoji(imgPath):
|
||||||
newPath = f"{os.path.abspath('.')}/app/data/emoji/{imgPath}"
|
newPath = f"{os.path.abspath('.')}/app/data/emoji/{imgPath}"
|
||||||
if os.path.exists(newPath):
|
if os.path.exists(newPath):
|
||||||
@ -182,6 +222,7 @@ def download_emoji(imgPath, url):
|
|||||||
f.write(resp.content)
|
f.write(resp.content)
|
||||||
return imgPath
|
return imgPath
|
||||||
|
|
||||||
|
|
||||||
def get_chatroom_displayname(chatroom, username):
|
def get_chatroom_displayname(chatroom, username):
|
||||||
sql = 'select memberlist,displayname from chatroom where chatroomname =?'
|
sql = 'select memberlist,displayname from chatroom where chatroomname =?'
|
||||||
cursor.execute(sql, [chatroom])
|
cursor.execute(sql, [chatroom])
|
||||||
@ -194,6 +235,8 @@ def get_chatroom_displayname(chatroom,username):
|
|||||||
for i in wxids:
|
for i in wxids:
|
||||||
print(get_conRemark(i))
|
print(get_conRemark(i))
|
||||||
return names[id]
|
return names[id]
|
||||||
|
|
||||||
|
|
||||||
def get_contacts():
|
def get_contacts():
|
||||||
sql = '''
|
sql = '''
|
||||||
select * from rcontact
|
select * from rcontact
|
||||||
@ -202,11 +245,14 @@ def get_contacts():
|
|||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
result = cursor.fetchall()
|
result = cursor.fetchall()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# rconversation = get_rconversation()
|
# rconversation = get_rconversation()
|
||||||
# for i in rconversation:
|
# for i in rconversation:
|
||||||
# print(i)
|
# print(i)
|
||||||
contacts = get_contacts()
|
# contacts = get_all_message('wxid_vqave8lcp49r22')
|
||||||
for contact in contacts:
|
# for contact in contacts:
|
||||||
print(contact)
|
# print(contact)
|
||||||
|
# [(177325,)] (73546,) (103770,)
|
||||||
|
print(search_send_message(1,1))
|
||||||
|
@ -68,6 +68,7 @@ def get_avator(wxid):
|
|||||||
break
|
break
|
||||||
return Path + '/' + avatar
|
return Path + '/' + avatar
|
||||||
|
|
||||||
|
|
||||||
def read_csv(conRemark):
|
def read_csv(conRemark):
|
||||||
'''
|
'''
|
||||||
:param conRemark: (str) 要导出的联系人备注名
|
:param conRemark: (str) 要导出的联系人备注名
|
||||||
@ -118,9 +119,6 @@ def time_format(timestamp):
|
|||||||
return time.strftime("%Y-%m-%d %H:%M:%S", time_tuple)
|
return time.strftime("%Y-%m-%d %H:%M:%S", time_tuple)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def IS_5_min(last_m, now_m):
|
def IS_5_min(last_m, now_m):
|
||||||
'''
|
'''
|
||||||
#! 判断两次聊天时间是不是大于五分钟
|
#! 判断两次聊天时间是不是大于五分钟
|
||||||
@ -140,11 +138,6 @@ def judge_type(Type):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
'''合并word文档到一个文件里'''
|
'''合并word文档到一个文件里'''
|
||||||
|
|
||||||
|
|
||||||
@ -176,6 +169,7 @@ class MyThread(QThread):
|
|||||||
self_text = pyqtSignal(str)
|
self_text = pyqtSignal(str)
|
||||||
ta_text = pyqtSignal(str)
|
ta_text = pyqtSignal(str)
|
||||||
bar = pyqtSignal(int)
|
bar = pyqtSignal(int)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(MyThread, self).__init__()
|
super(MyThread, self).__init__()
|
||||||
self.ta_info = {}
|
self.ta_info = {}
|
||||||
@ -206,6 +200,7 @@ class MyThread(QThread):
|
|||||||
# print(user_data)
|
# print(user_data)
|
||||||
self.total_num = len(user_data)
|
self.total_num = len(user_data)
|
||||||
return user_data
|
return user_data
|
||||||
|
|
||||||
def create_table(self, doc, isSend):
|
def create_table(self, doc, isSend):
|
||||||
'''
|
'''
|
||||||
#! 创建一个1*2表格
|
#! 创建一个1*2表格
|
||||||
@ -392,7 +387,6 @@ class MyThread(QThread):
|
|||||||
reply_p.paragraph_format.alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT
|
reply_p.paragraph_format.alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT
|
||||||
doc.add_paragraph()
|
doc.add_paragraph()
|
||||||
|
|
||||||
|
|
||||||
def pat_a_pat(self, doc, isSend, content, status):
|
def pat_a_pat(self, doc, isSend, content, status):
|
||||||
'''
|
'''
|
||||||
#! 添加拍一拍信息
|
#! 添加拍一拍信息
|
||||||
@ -509,6 +503,7 @@ class MyThread(QThread):
|
|||||||
# doc.add_paragraph(str(i))
|
# doc.add_paragraph(str(i))
|
||||||
# print(filename)
|
# print(filename)
|
||||||
doc.save(filename)
|
doc.save(filename)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
if 1:
|
if 1:
|
||||||
# try:
|
# try:
|
||||||
@ -541,6 +536,8 @@ class MyThread(QThread):
|
|||||||
# self.self_text.emit('发生异常')
|
# self.self_text.emit('发生异常')
|
||||||
# print(e)
|
# print(e)
|
||||||
# self.self_text.emit(e)
|
# self.self_text.emit(e)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# # conRemark = '张三' #! 微信备注名
|
# # conRemark = '张三' #! 微信备注名
|
||||||
# n = 100 # ! 分割的文件个数
|
# n = 100 # ! 分割的文件个数
|
||||||
|
@ -22,6 +22,7 @@ from .chatUi import *
|
|||||||
from ...DataBase import data
|
from ...DataBase import data
|
||||||
from ...ImageBox.ui import MainDemo
|
from ...ImageBox.ui import MainDemo
|
||||||
|
|
||||||
|
|
||||||
class ChatController(QWidget, Ui_Dialog):
|
class ChatController(QWidget, Ui_Dialog):
|
||||||
exitSignal = pyqtSignal()
|
exitSignal = pyqtSignal()
|
||||||
urlSignal = pyqtSignal(QUrl)
|
urlSignal = pyqtSignal(QUrl)
|
||||||
@ -341,27 +342,16 @@ class ChatController(QWidget, Ui_Dialog):
|
|||||||
<td max-width = 300 style="background-color: #fff;border-radius: 4px;"> %s </td>
|
<td max-width = 300 style="background-color: #fff;border-radius: 4px;"> %s </td>
|
||||||
''' % (content)
|
''' % (content)
|
||||||
self.left(html)
|
self.left(html)
|
||||||
def clearImagePath(self,imgpath):
|
|
||||||
path = imgpath.split('/')
|
|
||||||
newPath = '/'.join(path[:-1])+'/'+path[-1][3:]+'.jpg'
|
|
||||||
if os.path.exists(newPath):
|
|
||||||
return newPath
|
|
||||||
newPath = '/'.join(path[:-1]) + '/' + path[-1][3:] + '.png'
|
|
||||||
if os.path.exists(newPath):
|
|
||||||
return newPath
|
|
||||||
newPath = '/'.join(path[:-1]) + '/' + path[-1]+ 'hd'
|
|
||||||
if os.path.exists(newPath):
|
|
||||||
return newPath
|
|
||||||
return imgpath
|
|
||||||
def hyperlink(self, url: QUrl):
|
def hyperlink(self, url: QUrl):
|
||||||
path = self.clearImagePath(url.path())
|
path = data.clearImagePath(url.path())
|
||||||
print(url.path(), path)
|
print(url.path(), path)
|
||||||
self.imagebox = MainDemo()
|
self.imagebox = MainDemo()
|
||||||
self.imagebox.show()
|
self.imagebox.show()
|
||||||
self.imagebox.box.set_image(path)
|
self.imagebox.box.set_image(path)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def right(self, content, style='vertical-align: middle'):
|
def right(self, content, style='vertical-align: middle'):
|
||||||
html = '''
|
html = '''
|
||||||
<div>
|
<div>
|
||||||
|
@ -102,7 +102,7 @@ class MainWinController(QMainWindow, Ui_Dialog):
|
|||||||
|
|
||||||
def about(self):
|
def about(self):
|
||||||
QMessageBox.about(self, "关于",
|
QMessageBox.about(self, "关于",
|
||||||
"关于作者\n姓名:周帅康\n联系方式:863909694"
|
"关于作者\n姓名:周帅康\n邮箱:lc863854@mail.nwpu.edu.cn"
|
||||||
)
|
)
|
||||||
|
|
||||||
def setviewVisible(self, view):
|
def setviewVisible(self, view):
|
||||||
|
Loading…
Reference in New Issue
Block a user