mirror of
https://github.com/LC044/WeChatMsg
synced 2024-11-09 09:31:18 +08:00
update readme.md
This commit is contained in:
parent
163b2ef269
commit
7ba44f92e3
@ -785,7 +785,55 @@ class Msg:
|
||||
finally:
|
||||
lock.release()
|
||||
return result
|
||||
def get_message_length(
|
||||
self,
|
||||
username_='',
|
||||
time_range: Tuple[int | float | str | date, int | float | str | date] = None,
|
||||
)->int:
|
||||
"""
|
||||
统计自己总共发消息的字数,包含type=1的文本和type=49,subtype=57里面自己发的文本
|
||||
"""
|
||||
if time_range:
|
||||
start_time, end_time = convert_to_timestamp(time_range)
|
||||
sql_type_1 = f"""
|
||||
SELECT sum(length(strContent))
|
||||
from MSG
|
||||
where StrTalker = ? and
|
||||
type = 1
|
||||
{'AND CreateTime>' + str(start_time) + ' AND CreateTime<' + str(end_time) if time_range else ''}
|
||||
"""
|
||||
sql_type_49 = f"""
|
||||
SELECT CompressContent
|
||||
from MSG
|
||||
where StrTalker = ? and
|
||||
type = 49 and subtype = 57
|
||||
{'AND CreateTime>' + str(start_time) + ' AND CreateTime<' + str(end_time) if time_range else ''}
|
||||
"""
|
||||
sum_type_1 = 0
|
||||
result_type_1 = 0
|
||||
result_type_49 = 0
|
||||
sum_type_49 = 0
|
||||
|
||||
if not self.open_flag:
|
||||
return None
|
||||
try:
|
||||
lock.acquire(True)
|
||||
self.cursor.execute(sql_type_1,[username_])
|
||||
result_type_1 = self.cursor.fetchall()[0][0]
|
||||
self.cursor.execute(sql_type_49,[username_])
|
||||
result_type_49 = self.cursor.fetchall()
|
||||
except sqlite3.DatabaseError:
|
||||
logger.error(f'{traceback.format_exc()}\n数据库损坏请删除msg文件夹重试')
|
||||
finally:
|
||||
lock.release()
|
||||
for message in result_type_49:
|
||||
message = message[0]
|
||||
content = parser_reply(message)
|
||||
if content["is_error"]:
|
||||
continue
|
||||
sum_type_49 += len(content["title"])
|
||||
sum_type_1 = result_type_1 if result_type_1 else 0
|
||||
return sum_type_1 + sum_type_49
|
||||
def close(self):
|
||||
if self.open_flag:
|
||||
try:
|
||||
|
@ -94,7 +94,10 @@ def get_wordcloud(text):
|
||||
|
||||
text_data = data[:100] if len(data) > 100 else data
|
||||
# 创建词云图
|
||||
keyword, max_num = text_data[0]
|
||||
if text_data:
|
||||
keyword, max_num = text_data[0]
|
||||
else:
|
||||
keyword, max_num = '', 0
|
||||
w = (
|
||||
WordCloud()
|
||||
.add(series_name="聊天文字", data_pair=text_data, word_size_range=[5, 40])
|
||||
@ -483,7 +486,7 @@ def my_message_counter(time_range, my_name=''):
|
||||
'chart_data_wordcloud': w.get('chart_data_wordcloud'),
|
||||
'keyword': w.get('keyword'),
|
||||
'keyword_max_num': w.get('keyword_max_num'),
|
||||
'total_text_num':total_text_num,
|
||||
'total_text_num': total_text_num,
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,9 +14,8 @@ try:
|
||||
from .chatInfoUi import Ui_Form
|
||||
except:
|
||||
from chatInfoUi import Ui_Form
|
||||
from app.DataBase import msg_db, hard_link_db
|
||||
from app.components.bubble_message import BubbleMessage, ChatWidget, Notice
|
||||
from app.person import Me, Contact, ContactDefault
|
||||
from app.components.bubble_message import BubbleMessage
|
||||
from app.person import Me,ContactDefault
|
||||
|
||||
|
||||
class Message(QWidget):
|
||||
@ -145,7 +144,14 @@ class AIChatThread(QThread):
|
||||
}
|
||||
]
|
||||
}
|
||||
message = '''
|
||||
幼儿园三班一共有35人,上个月34人满勤。\n其中1月15日,小明同学感冒了,他的妈妈给他请了一天的病假。
|
||||
'''
|
||||
try:
|
||||
# for s in message:
|
||||
# self.msgSignal.emit(s)
|
||||
# time.sleep(0.05)
|
||||
# return
|
||||
resp = requests.post(url, json=data, stream=True)
|
||||
if resp.status_code == 200:
|
||||
for line in resp.iter_lines():
|
||||
|
@ -324,14 +324,14 @@ p {
|
||||
<h1>年度聊天好友</h1>
|
||||
<h2>聊天榜单</h2>
|
||||
<ul>
|
||||
{% for contact,msg_num in contact_topN:%}
|
||||
{% for contact,msg_num,text_length in contact_topN:%}
|
||||
<li>
|
||||
<a href="/charts/{{contact.wxid}}" target="_blank">
|
||||
<div class="contact-container">
|
||||
<p class="nickname">{{contact.remark}}</p>
|
||||
<img class="avatar" src="{{contact.smallHeadImgUrl}}">
|
||||
</div>
|
||||
<div style="color: blueviolet;"><span class="number">{{msg_num}}</span>条消息<br><span class="number">000</span>字</div>
|
||||
<div style="color: blueviolet;"><span class="number">{{msg_num}}</span>条消息<br><span class="number">{{text_length}}</span>字</div>
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
@ -49,7 +49,8 @@ def index():
|
||||
contact_topN_num = msg_db.get_chatted_top_contacts(time_range=time_range, top_n=9999999, contain_chatroom=False)
|
||||
for wxid, num in contact_topN_num[:6]:
|
||||
contact = get_contact(wxid)
|
||||
contact_topN.append([contact, num])
|
||||
text_length = msg_db.get_message_length(wxid,time_range)
|
||||
contact_topN.append([contact, num,text_length])
|
||||
my_message_counter_data = analysis.my_message_counter(time_range=time_range)
|
||||
data = {
|
||||
'avatar': Me().smallHeadImgUrl,
|
||||
|
BIN
doc/images/why.gif
Normal file
BIN
doc/images/why.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 342 KiB |
BIN
doc/images/病假.gif
Normal file
BIN
doc/images/病假.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 128 KiB |
Loading…
Reference in New Issue
Block a user