From a8d72d2894e0a82c1563ef3148a12afaad142619 Mon Sep 17 00:00:00 2001 From: ZhangKang Date: Thu, 7 Dec 2023 11:15:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=B6=88=E6=81=AF=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/msg.py | 20 +++++++++++++++++++- app/ui_pc/chat/chat_info.py | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/DataBase/msg.py b/app/DataBase/msg.py index a6bdc7e..915efa7 100644 --- a/app/DataBase/msg.py +++ b/app/DataBase/msg.py @@ -87,6 +87,24 @@ 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 @@ -213,4 +231,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')) diff --git a/app/ui_pc/chat/chat_info.py b/app/ui_pc/chat/chat_info.py index 9e8e36a..5464be6 100644 --- a/app/ui_pc/chat/chat_info.py +++ b/app/ui_pc/chat/chat_info.py @@ -142,7 +142,7 @@ class ShowChatThread(QThread): # heightSingal = pyqtSignal(int) def __init__(self, contact): super().__init__() - self.last_message_id = 9999999 + self.last_message_id = msg_db.get_messages_length() or 9999999 self.wxid = contact.wxid def run(self) -> None: