mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-23 03:22:17 +08:00
读取消息记录数
This commit is contained in:
parent
4d1d1a631d
commit
a8d72d2894
@ -87,6 +87,24 @@ class Msg:
|
|||||||
result.sort(key=lambda x: x[5])
|
result.sort(key=lambda x: x[5])
|
||||||
return result
|
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):
|
def get_message_by_num(self, username_, local_id):
|
||||||
sql = '''
|
sql = '''
|
||||||
select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime
|
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))
|
pprint(msg.get_message_by_num('wxid_0o18ef858vnu22', local_id))
|
||||||
print(msg.get_messages_by_keyword(wxid, '干嘛'))
|
print(msg.get_messages_by_keyword(wxid, '干嘛'))
|
||||||
pprint(msg.get_messages_by_keyword(wxid, '干嘛')[0])
|
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'))
|
||||||
|
@ -142,7 +142,7 @@ class ShowChatThread(QThread):
|
|||||||
# heightSingal = pyqtSignal(int)
|
# heightSingal = pyqtSignal(int)
|
||||||
def __init__(self, contact):
|
def __init__(self, contact):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.last_message_id = 9999999
|
self.last_message_id = msg_db.get_messages_length() or 9999999
|
||||||
self.wxid = contact.wxid
|
self.wxid = contact.wxid
|
||||||
|
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user