Skip to content

Commit

Permalink
Merge pull request LC044#14 from LC044/dev_zsk
Browse files Browse the repository at this point in the history
Dev zsk
  • Loading branch information
LC044 authored Nov 18, 2023
2 parents 3b27782 + 9544549 commit 2621577
Show file tree
Hide file tree
Showing 13 changed files with 339 additions and 196 deletions.
161 changes: 79 additions & 82 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 6 additions & 12 deletions app/DataBase/micro_msg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os.path
import sqlite3
import time
import threading

lock = threading.Lock()
DB = None
cursor = None
micromsg_path = "./app/Database/Msg/MicroMsg.db"
Expand All @@ -27,23 +28,16 @@ def is_database_exist():

def get_contact():
try:
lock.acquire(True)
sql = '''select UserName,Alias,Type,Remark,NickName,PYInitial,RemarkPYInitial,ContactHeadImgUrl.smallHeadImgUrl,ContactHeadImgUrl.bigHeadImgUrl
from Contact inner join ContactHeadImgUrl on Contact.UserName = ContactHeadImgUrl.usrName
where Type=3 and Alias is not null
where Type%2=1 and Alias is not null
order by PYInitial
limit 30
'''
cursor.execute(sql)
result = cursor.fetchall()
except:
time.sleep(0.2)
sql = '''select UserName,Alias,Type,Remark,NickName,PYInitial,RemarkPYInitial,ContactHeadImgUrl.smallHeadImgUrl,ContactHeadImgUrl.bigHeadImgUrl
from Contact inner join ContactHeadImgUrl on Contact.UserName = ContactHeadImgUrl.usrName
where Type=3 and Alias is not null
order by PYInitial
'''
cursor.execute(sql)
result = cursor.fetchall()
finally:
lock.release()
# DB.commit()
return result

Expand Down
16 changes: 10 additions & 6 deletions app/DataBase/msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
import sqlite3
import threading
from pprint import pprint

DB = []
cursor = []
Expand Down Expand Up @@ -56,20 +57,20 @@ def get_messages(username_):
return result


def get_message_by_num(username_, n):
def get_message_by_num(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=?
order by CreateTime
limit 10
where StrTalker = ? and localId < ?
order by CreateTime desc
limit 30
'''
result = []
try:
lock.acquire(True)
for cur in cursor:
cur = cursor[-1]
cur.execute(sql, [username_])
cur.execute(sql, [username_, local_id])
result_ = cur.fetchall()
result += result_
return result_
Expand All @@ -92,5 +93,8 @@ def close():
# result = get_messages(username)
# pprint(result)
# pprint(len(result))
result = get_message_by_num('wxid_0o18ef858vnu22', 0)
result = get_message_by_num('wxid_0o18ef858vnu22', 9999999)
print(result)
print(result[-1][0])
local_id = result[-1][0]
pprint(get_message_by_num('wxid_0o18ef858vnu22', local_id))
Loading

0 comments on commit 2621577

Please sign in to comment.