from wxauto import *
import time
import random
repeat_rate = .3
wait_seconds = 5
start_num = 20
file_name = 'db.txt'
split_tag = '6lol6'
chat_name = '群名称'
def save_content(content):
f = open(file_name, mode='a', encoding='utf-8')
f.write(content + split_tag)
f.close()
def send_content():
if random.random() < repeat_rate:
f = open(file_name, mode='r', encoding='utf-8')
line = f.readline()
repeats = line.split(split_tag)
if len(repeats) - 2 > start_num:
index = random.randint(0, len(repeats) - 2)
wx.SendMsg(repeats[index], chat_name)
f.close()
else:
print('对[' + msg.content + ']不回复')
if __name__ == '__main__':
wx = WeChat()
wx.AddListenChat(chat_name)
try:
while True:
new_msgs = wx.GetListenMessage(chat_name)
if len(new_msgs) == 0:
continue
for msg in new_msgs:
if (msg.content.startswith('[图片]')
or msg.content.startswith('[文件]')
or msg.content.startswith('[语音]')):
print('不处理')
continue
if msg.type == 'friend':
save_content(msg.content)
send_content()
time.sleep(wait_seconds)
except KeyboardInterrupt:
print('\n程序结束')
quit()
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】