11 Star 116 Fork 47

贾斯汀/deep-seek wechat

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
app.py 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
import ai
import db
from wxauto import *
import time
wx = WeChat()
listen_list = []
# 读取好友列表
file_path = 'names.txt'
try:
with open(file_path, 'r', encoding='utf-8') as file:
names = file.readlines()
listen_list = [name.strip() for name in names]
except FileNotFoundError:
print(f"文件 {file_path} 未找到,请检查文件路径是否正确!")
except Exception as e:
print(f"读取文件时发生错误:{e}")
for i in listen_list:
print(f"开始监听好友 {i} 的消息...")
wx.AddListenChat(who=i, savepic=True)
ai.add_user(i)
wait = 1 # 设置间隔时间
# 创建数据库
db.create_db()
while True:
msgs = wx.GetListenMessage()
for chat in msgs:
who = chat.who # 获取聊天窗口名(人或群名)
one_msgs = msgs[chat] # 获取消息内容
for msg in one_msgs:
msgtype = msg.type # 获取消息类型
content = msg.content # 获取消息内容
print(f'【{who}】:{content}')
if msgtype == 'friend':
chat.SendMsg(ai.chat(who, content))
time.sleep(wait)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/jiasizhe/deep-seek-wechat.git
git@gitee.com:jiasizhe/deep-seek-wechat.git
jiasizhe
deep-seek-wechat
deep-seek wechat
master

搜索帮助