mirror of
https://github.com/LC044/WeChatMsg
synced 2024-11-12 20:21:21 +08:00
修复年度分析报告第二页溢出的问题#69
This commit is contained in:
parent
b3745867c6
commit
b6f041b67a
@ -126,19 +126,19 @@ class Msg:
|
||||
lock.release()
|
||||
return result
|
||||
|
||||
def get_messages_by_keyword(self, username_, keyword, num=5):
|
||||
def get_messages_by_keyword(self, username_, keyword, num=5, max_len=10):
|
||||
if not self.open_flag:
|
||||
return None
|
||||
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 StrContent like ?
|
||||
where StrTalker=? and Type=1 and LENGTH(StrContent)<? and StrContent like ?
|
||||
order by CreateTime desc
|
||||
'''
|
||||
temp = []
|
||||
try:
|
||||
lock.acquire(True)
|
||||
self.cursor.execute(sql, [username_, f'%{keyword}%'])
|
||||
self.cursor.execute(sql, [username_, max_len, f'%{keyword}%'])
|
||||
messages = self.cursor.fetchall()
|
||||
finally:
|
||||
lock.release()
|
||||
@ -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_0o18ef858vnu22'))
|
||||
|
@ -26,7 +26,7 @@ def wordcloud(wxid):
|
||||
# 统计词频
|
||||
word_count = Counter(words)
|
||||
# 过滤停用词
|
||||
stopwords_file = './app/data/stopwords.txt'
|
||||
stopwords_file = './app000/data/stopwords.txt'
|
||||
try:
|
||||
with open(stopwords_file, "r", encoding="utf-8") as stopword_file:
|
||||
stopwords = set(stopword_file.read().splitlines())
|
||||
@ -65,7 +65,7 @@ def wordcloud(wxid):
|
||||
'chart_data': w.dump_options_with_quotes(),
|
||||
'keyword': keyword,
|
||||
'max_num': str(max_num),
|
||||
'dialogs': msg_db.get_messages_by_keyword(wxid, keyword, num=5)
|
||||
'dialogs': msg_db.get_messages_by_keyword(wxid, keyword, num=5, max_len=12)
|
||||
}
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -16,6 +16,7 @@ wxid
|
||||
裂开
|
||||
苦涩
|
||||
叹气
|
||||
凋谢
|
||||
让我看看
|
||||
酷
|
||||
奋斗
|
||||
|
@ -42,16 +42,16 @@ def index0():
|
||||
@app.route('/home')
|
||||
def home():
|
||||
try:
|
||||
data = {
|
||||
'sub_title': '二零二三年度报告',
|
||||
'avatar_path': contact.avatar_path,
|
||||
'nickname': contact.remark,
|
||||
'first_time': msg_db.get_first_time_of_message(contact.wxid)[1],
|
||||
}
|
||||
return render_template('home.html', **data)
|
||||
first_message, first_time = msg_db.get_first_time_of_message(contact.wxid)
|
||||
except IndexError:
|
||||
return set_text('咱就是说,一次都没聊过就别分析了')
|
||||
|
||||
data = {
|
||||
'sub_title': '二零二三年度报告',
|
||||
'avatar_path': contact.avatar_path,
|
||||
'nickname': contact.remark,
|
||||
'first_time': first_time,
|
||||
}
|
||||
return render_template('home.html', **data)
|
||||
|
||||
|
||||
@app.route('/wordcloud')
|
||||
|
@ -295,7 +295,7 @@ python main.py
|
||||
---
|
||||
|
||||
> 声明:该项目有且仅有一个目的:“留痕”——我的数据我做主,前提是“我的数据”其次才是“我做主”,禁止任何人以任何形式将其用于任何非法用途,对于使用该程序所造成的任何后果,所有创作者不承担任何责任🙄<br>
|
||||
> 该软件不会对您使用的微信造成任何影响,更不会对他人的微信造成任何影响,任何企图篡改微信聊天数据的想法都是无稽之谈。本项目所有功能均建立在”前言“的基础之上,基于该项目的所有开发者均不能接受任何有悖于”前言“的功能需求,违者后果自负。
|
||||
> 该软件不会对您使用的微信造成任何影响,更不会对他人的微信造成任何影响,不能找回删除的聊天记录,任何企图篡改微信聊天数据的想法都是无稽之谈。本项目所有功能均建立在”前言“的基础之上,基于该项目的所有开发者均不能接受任何有悖于”前言“的功能需求,违者后果自负。
|
||||
|
||||
[![Star History Chart](https://api.star-history.com/svg?repos=LC044/WeChatMsg&type=Date)](https://star-history.com/?utm_source=bestxtools.com#LC044/WeChatMsg&Date)
|
||||
|
||||
|
@ -12,4 +12,6 @@ requests
|
||||
flask==3.0.0
|
||||
pyecharts==2.0.1
|
||||
jieba==0.42.1
|
||||
google==3.0.0
|
||||
protobuf==4.25.1
|
||||
soupsieve==2.5
|
||||
|
Loading…
Reference in New Issue
Block a user