增加msg查询字段

This commit is contained in:
shuaikangzhou 2023-12-07 21:34:27 +08:00
parent 26c752a710
commit 1f611e3341

View File

@ -106,7 +106,7 @@ class Msg:
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,MsgSvrID,BytesExtra
from MSG from MSG
where StrTalker = ? and localId < ? where StrTalker = ? and localId < ?
order by CreateTime desc order by CreateTime desc
@ -130,7 +130,7 @@ class Msg:
if not self.open_flag: if not self.open_flag:
return None return None
sql = ''' sql = '''
select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID,BytesExtra
from MSG from MSG
where StrTalker=? and Type=? where StrTalker=? and Type=?
order by CreateTime order by CreateTime
@ -147,7 +147,7 @@ class Msg:
if not self.open_flag: if not self.open_flag:
return None return None
sql = ''' sql = '''
select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID select localId,TalkerId,Type,SubType,IsSender,CreateTime,Status,StrContent,strftime('%Y-%m-%d %H:%M:%S',CreateTime,'unixepoch','localtime') as StrTime,MsgSvrID,BytesExtra
from MSG from MSG
where StrTalker=? and Type=1 and LENGTH(StrContent)<? and StrContent like ? where StrTalker=? and Type=1 and LENGTH(StrContent)<? and StrContent like ?
order by CreateTime desc order by CreateTime desc
@ -284,10 +284,7 @@ if __name__ == '__main__':
msg.init_database() msg.init_database()
result = msg.get_message_by_num('wxid_0o18ef858vnu22', 9999999) result = msg.get_message_by_num('wxid_0o18ef858vnu22', 9999999)
print(result) print(result)
print(result[-1][0]) result = msg.get_messages_by_type('wxid_0o18ef858vnu22',43)
local_id = result[-1][0] bytes_ = result[-1][-1]
wxid = 'wxid_0o18ef858vnu22' print(bytes_)
pprint(msg.get_message_by_num('wxid_0o18ef858vnu22', local_id)) print(bytes_)
print(msg.get_messages_by_keyword(wxid, '干嘛'))
pprint(msg.get_messages_by_keyword(wxid, '干嘛')[0])
print(msg.get_first_time_of_message('wxid_0o18ef858vnu22'))