Skip to content

Commit

Permalink
update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
LC044 committed Feb 9, 2024
1 parent 163b2ef commit 7ba44f9
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 8 deletions.
48 changes: 48 additions & 0 deletions app/DataBase/msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,55 @@ def get_send_messages_number_by_hour(
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:
Expand Down
7 changes: 5 additions & 2 deletions app/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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,
}


Expand Down
12 changes: 9 additions & 3 deletions app/ui/chat/ai_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
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):
Expand Down Expand Up @@ -145,7 +144,14 @@ def run(self) -> None:
}
]
}
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():
Expand Down
4 changes: 2 additions & 2 deletions app/web_ui/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,14 @@ <h1>年度关键词</h1>
<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 %}
Expand Down
3 changes: 2 additions & 1 deletion app/web_ui/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Binary file added doc/images/why.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/images/病假.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@

![](./doc/images/微信图片_20240130214341.jpg)

![](./doc/images/why.gif)

![](./doc/images/病假.gif)

![image-20230520235351749](./doc/images/20231227211149.png)

![image-20230520235351749](./doc/images/20231227211215.png)
Expand Down

0 comments on commit 7ba44f9

Please sign in to comment.