From f6754c0db8561620bfa073fb1c8d3a08c9a41ef2 Mon Sep 17 00:00:00 2001 From: CoderKang Date: Wed, 6 Dec 2023 23:54:12 +0800 Subject: [PATCH 1/3] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E8=81=8A?= =?UTF-8?q?=E5=A4=A9=E8=AE=B0=E5=BD=95=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8?= =?UTF-8?q?=20#88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/msg.py | 28 +++++++++++++++++++++++----- app/components/bubble_message.py | 2 ++ app/ui_pc/chat/chat_info.py | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/app/DataBase/msg.py b/app/DataBase/msg.py index a6bdc7e..580d6e8 100644 --- a/app/DataBase/msg.py +++ b/app/DataBase/msg.py @@ -58,7 +58,7 @@ class Msg: sql = ''' select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID from MSG - where StrTalker=? + where TRIM(StrTalker)=? order by CreateTime ''' try: @@ -87,11 +87,29 @@ class Msg: result.sort(key=lambda x: x[5]) return result + def get_messages_length(self): + sql = ''' + select count(*) + from MSG + ''' + if not self.open_flag: + return None + try: + lock.acquire(True) + self.cursor.execute(sql) + result = self.cursor.fetchone() + except Exception as e: + result = None + finally: + lock.release() + return result[0] + + def get_message_by_num(self, username_, local_id): sql = ''' select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime from MSG - where StrTalker = ? and localId < ? + where TRIM(StrTalker) = ? and localId < ? order by CreateTime desc limit 10 ''' @@ -115,7 +133,7 @@ class Msg: sql = ''' select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID from MSG - where StrTalker=? and Type=? + where TRIM(StrTalker)=? and Type=? order by CreateTime ''' try: @@ -132,7 +150,7 @@ class Msg: sql = ''' select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID from MSG - where StrTalker=? and Type=1 and LENGTH(StrContent) None: From db0277fbd7b398ca09af63d92c61b066dc8b0095 Mon Sep 17 00:00:00 2001 From: shuaikangzhou <863909694@qq.com> Date: Thu, 7 Dec 2023 00:19:16 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E7=BC=BA=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/output_pc.py | 2 +- app/util/dat2pic.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/DataBase/output_pc.py b/app/DataBase/output_pc.py index 77f0adf..76dc719 100644 --- a/app/DataBase/output_pc.py +++ b/app/DataBase/output_pc.py @@ -890,7 +890,7 @@ const chatMessages = [ if match: continue image_path = hard_link_db.get_image(content=str_content, thumb=False) - image_path = path.get_relative_path(image_path, base_path=f'./data/聊天记录/{self.contact.remark}/image') + image_path = path.get_relative_path(image_path, base_path=f'/data/聊天记录/{self.contact.remark}/image') image_path = image_path.replace('\\', '/') # print(f"tohtml:---{image_path}") if self.is_5_min(timestamp): diff --git a/app/util/dat2pic.py b/app/util/dat2pic.py index 9c7df78..7a36d9c 100644 --- a/app/util/dat2pic.py +++ b/app/util/dat2pic.py @@ -50,14 +50,15 @@ def decode_dat(file_path, out_path): if decode_code == -1: return + filename = os.path.basename(file_path) if file_type == 1: pic_name = os.path.basename(file_path)[:-4] + ".jpg" elif file_type == 3: - pic_name = file_path[:-4] + ".png" + pic_name = filename[:-4] + ".png" elif file_type == 5: - pic_name = file_path[:-4] + ".gif" + pic_name = filename[:-4] + ".gif" else: - pic_name = file_path[:-4] + ".jpg" + pic_name = filename[:-4] + ".jpg" file_outpath = os.path.join(out_path, pic_name) if os.path.exists(file_outpath): return file_outpath From 2efc52840ac0c3659e4cf2000ee27196fe961705 Mon Sep 17 00:00:00 2001 From: shuaikangzhou <863909694@qq.com> Date: Thu, 7 Dec 2023 00:44:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E5=90=8E=E7=9A=84=E8=81=8A=E5=A4=A9=E6=95=B0=E6=8D=AE=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/merge.py | 2 +- app/DataBase/msg.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/DataBase/merge.py b/app/DataBase/merge.py index 7679821..c3aa63a 100644 --- a/app/DataBase/merge.py +++ b/app/DataBase/merge.py @@ -13,7 +13,7 @@ def merge_databases(source_paths, target_path): if not os.path.exists(source_path): break db = sqlite3.connect(source_path) - db.text_factory = bytes + # db.text_factory = bytes cursor = db.cursor() sql = ''' SELECT TalkerId,MsgsvrID,Type,SubType,IsSender,CreateTime,Sequence,StrTalker,StrContent,DisplayContent,BytesExtra diff --git a/app/DataBase/msg.py b/app/DataBase/msg.py index a6bdc7e..1b03ce7 100644 --- a/app/DataBase/msg.py +++ b/app/DataBase/msg.py @@ -213,4 +213,4 @@ if __name__ == '__main__': pprint(msg.get_message_by_num('wxid_0o18ef858vnu22', local_id)) print(msg.get_messages_by_keyword(wxid, '干嘛')) pprint(msg.get_messages_by_keyword(wxid, '干嘛')[0]) - print(msg.get_first_time_of_message('wxid_0o18ef858vnu22')) + print(msg.get_first_time_of_message('wxid_fervbwign7m822'))