import itchat import time '''获取微信好友头像''' #get_mps 获取公众号 #set_alias 设置微信别名 #set_pinned 设置好友或聊天室置顶 #add_friend 新增好友 #get_head_img 获取头像 #create_chatroom 创建聊天室 #set_chatroom_name 设置聊天室名称 #delete_member_from_chatroom 从聊天室删除成员 #add_member_into_chatroom 将会员加入聊天室 #send_raw_msg 发送一条消息 #send_msg 发送纯文本消息 #upload_file 上传文件 #send_file 发送文件给好友 #send_image 发送图片 #send_video 发送视频 #send 可以发送所有类型消息 #dump_login_status 打印登录状态 #load_login_status 加载登录状态 #auto_login 自动登录 #run 启动自动响应 #search_friends 搜索朋友 #search_chatrooms 搜索聊天群 #search_mps 搜索公众号 #登录微信 itchat.auto_login(hotReload=True) myUserName = itchat.get_friends(update=True)[0]["UserName"] #找出僵尸粉并返回列表 def qingfeng(): friends = itchat.get_friends(update=True) length = len(friends) itchat.send('检测到共'+ str(length) +'个好友', 'filehelper') i = 0 jiangshi = [] #获取微信好友列表 for friend in friends: i = i + 1 res = itchat.send("该消息为检测僵尸粉,无需理会~",toUserName=friend['UserName']) # print("正在检测"+friend['NickName']) itchat.send('当前检测进度'+ str(i) +'/'+ str(length), 'filehelper') print('当前检测进度'+ str(i) +'/'+ str(length)) print(res) if res['BaseResponse']['Ret'] != 0 : jiangshi.append(friend['NickName']) time.sleep(1) # print(jiangshi) return jiangshi @itchat.msg_register('Text') def auto_zhiling(msg): strs = '' if msg != '111': if msg['Content'] == '我要清僵尸粉': jsf = qingfeng() itchat.send('检测完毕,请查看微信', 'filehelper') auto_zhiling('111') itchat.run()

武英斌-博客