def analysis(com_queue=None): global all_friend_list, friends_in_chatrooms, duplicate, has_return_qr,\ base_path, result_path, title_path, summary_path, shixoong_qr_path,\ user_header, user_nickname, \ friends_num, remarked_friends, star_friends # 扫码登录微信 init() if itchat.check_login(): itchat.logout() # 登录微信,需要扫面下方输出结果的二维码 # 网页版 # itchat.auto_login(enableCmdQR=True, qrCallback=qrcode_handle) # PC版 uuid = open_qr(com_queue=com_queue) waitForConfirm = False while 1: status = itchat.check_login(uuid) if status == '200': if com_queue: com_queue.put({"mode": 6}) break elif status == '201': if not waitForConfirm: print('Please press confirm') # TODO 提示手机确认 if com_queue: com_queue.put({"mode": 2}) waitForConfirm = True elif status == '408': print('Reloading QR Code') uuid = open_qr(com_queue=com_queue) waitForConfirm = False itchat.web_init() itchat.show_mobile_login() # ------------------------------------------------------------------ """ 获取数据并去重 联系人列表 已保存到通讯录中群聊的人员 """ # 获取当前好友列表 _friends_list = itchat.get_friends(update=True) # 获取头像并保存本地待用 user = _friends_list[0] user.get_head_image(user_header) # 获取昵称 user_nickname = user.NickName # todo 回调登录成功 if com_queue: com_queue.put({"mode": 3}) # 好友个数 friends_num = len(_friends_list[1:]) # 将好友列表加入最终朋友列表,去除自己 for one in _friends_list[1:]: remark = 0 star = 0 # 备注 if one.RemarkName and one.RemarkName is not "": remark = 1 remarked_friends += 1 # 星标 if one.StarFriend and one.StarFriend == 1: star = 1 star_friends += 1 friend = Friend(one.UserName, one.Sex, one.Province, one.City, remark, star) all_friend_list.append(friend) # 获取当前所有群聊列表 chat_room_list = itchat.get_chatrooms(update=True) # 获取微信群聊中的所有成员 if chat_room_list is None: print("你连一个群聊都没有找到~") else: print u"共找到群聊:%d个\n" % len(chat_room_list) #for room in tqdm(chat_room_list): for index, room in enumerate(chat_room_list): room_updated = itchat.update_chatroom(room.UserName, detailedMember=True) # print "正在处理:%d/%d,请稍后" % ((index + 1), len(chat_room_list)), '\r', # 获取一个群聊中,所有群成员的公开信息 # print "memberlist = %d/%d" % (len(room_updated.MemberList),len(chat_room_list)), '\r', for member in room_updated.MemberList: friend = Friend(member.UserName, member.Sex, member.Province, member.City) if friend not in all_friend_list: all_friend_list.append(friend) friends_in_chatrooms += 1 else: duplicate += 1 # break # for test progress = int((index + 1) / float(len(chat_room_list)) * 100) # todo 更新进度条 if com_queue: com_queue.put({"mode": 4, "progress": progress}) print u"\n连接了%d人, 群聊人数%d, 好友人数%d." % (len(all_friend_list), friends_in_chatrooms, friends_num) # ------------------------------------------------------------------ # 绘制数据 # 初始化表格元组数据 data_json = json.dumps(all_friend_list, cls=FriendEncoder) print '1' df = pd.read_json(data_json, orient="records") # 获取性别数据 male_number = len(df[df['sex'] == 1]) female_number = len(df[df['sex'] == 2]) unknown_sex_number = len(df[df['sex'] == 0]) sex_data = [male_number, female_number, unknown_sex_number] # 统计省份数据 # 省份名称集合 provinces = [] # 各省份人数 provinces_people = [] # 饼图中哪个突出 provinces_explode = [0.1] # 获得省份数据副本,已按数量排序 province_df = df['province'].value_counts().copy() # 丢弃其中省份为空的好友数据 # 统计前6省份 for p in province_df.keys(): if len(provinces) >= 6: break if not p: continue # 转为拼音 provinces.append("".join(lazy_pinyin(p)).title()) provinces_people.append(province_df[p]) provinces_explode.append(0) # 删除多余的一个0 provinces_explode.pop() # 进行城市数据显示 # 城市 cities = [] # 各城市对应人数 city_people = [] city_df = df['city'].value_counts().copy() # 丢弃其中城市为空的好友数据城 for c in city_df.keys(): if len(cities) >= 5: break if not c: continue # 转为拼音 cities.append("".join(lazy_pinyin(c)).title()) city_people.append(city_df[c]) # todo 注意由于plt在子线程中使用会出现问题,此处将plt生成图片部分转到主线程中执行。 if com_queue: com_queue.put({ "mode": 10, "sex_data": sex_data, "provinces_data": { "provinces_people": provinces_people, "provinces": provinces, "provinces_explode": provinces_explode }, "city_data": { "cities": cities, "city_people": city_people } }) print threading.currentThread()
# 将图像上传至微信并删除临时图片 print "[UPLOAD] {}".format(ts) path = "{base_path}/{timestamp}.jpg".format( base_path=conf["dropbox_base_path"], timestamp=ts) itchat.send_image(path, 'filehelper') t.cleanup() # 更新最近一次上传的时间戳并且重置运动计数器 lastUploaded = timestamp motionCounter = 0 # 否则, 该房间没有“被占领” else: motionCounter = 0 # 判断安保视频是否需要显示在屏幕上 if 1 == 1: # 显示安视频 cv2.imshow("Security Feed", frame) key = cv2.waitKey(1) & 0xFF # 如果q被按下,跳出循环 if key == ord("q"): # 退出微信 itchat.logout() break # 清理数据流为下一帧做准备 rawCapture.truncate(0)
def after_logout(): itchat.logout()
def text_reply(msg): global set_friends global flag global admin global start #获取发送消息过来的用户UserName值 username = msg['FromUserName'] #判断用户是不是管理员 if username == admin: #判断管理员是否发出 #开启自动回复系统的信号 open #关闭自动回复系统的信号 close #重启自动回复系统的信号 restart #退出系统的信号 quit # #重启系统和开启系统的区别在于: #开启是保留上次用户关闭自动回复的状态以及是否已经发送提醒信息 #重启则是全部重新启动 if "restart" == msg['Text']: start = False elif "open" == msg['Text']: start = True return "" elif "close" == msg['Text']: start = False elif "quit" == msg['Text']: itchat.logout() #判别系统是开启还是关闭 if start: #第一次发送提醒信息 if username in flag: itchat.send('小黑: 可输入"关闭自动回复"来关闭自动回复功能[微笑]\n输入"开启自动回复"以开启自动回复功能[色]', username) flag.remove(username) #判断用户是否要开启或者关闭自动回复 if '开启自动回复' in msg['Text']: set_friends.add(username) return '小黑: 自动回复已开启' elif '关闭自动回复' in msg['Text']: set_friends.remove(username) return '小黑: 自动回复已关闭' #用户关闭自动回复 #返回空字符串 if username not in set_friends: return "" #用户自动回复状态处于开启状态 KEY = 'b74895fe92fe426ea5f4839212dcd995' #此处去图灵机器人官网注册个账号,然后创建个机器人,把机器人的key复制到这里 url = 'http://www.tuling123.com/openapi/api' info = msg['Text'] req_info = info.encode('utf-8') query = {'key': KEY, 'info': req_info} headers = {'Content-type': 'text/html', 'charset': 'utf-8'} r = requests.get(url, params=query, headers=headers) res = r.text response = '小黑: ' + json.loads(res).get('text').replace('<br>', '\n') return response #系统关闭状态 else: #判断是否要重启 if "restart" == msg['Text']: it = itchat.get_friends() set_friends = set() for i in it: set_friends.add(i['UserName']) flag = set_friends.copy() start = True #处于关闭状态 #返回空字符串 return ""
class MyWeChat_Analysis(object): def __init__(self, pic='wechat.jpg'): # 登陆 itchat.login() self.pic = pic # 获取好友列表 self.friends = itchat.get_friends(update=True)[0:] # 统计性别比例 def sexratio(self): male = female = other = 0 for i in self.friends[1:]: sex = i['Sex'] if sex == 1: male += 1 elif sex == 2: female += 1 else: other += 1 total = len(self.friends[1:]) male_ratio = float(male) / total * 100 female_ratio = float(female) / total * 100 other_ratio = float(other) / total * 100 print(u"男性好友:%.2f%%" % male_ratio) print(u"女性好友:%.2f%%" % female_ratio) print(u"其他:%.2f%%" % other_ratio) # 使用echarts from echarts import Echart, Legend, Pie chart = Echart(u'%s的微信好友性别比例' % (self.friends[0]['NickName']), 'from WeChat') chart.use( Pie('WeChat', [{ 'value': male, 'name': u'男性 %.2f%%' % male_ratio }, { 'value': female, 'name': u'女性 %.2f%%' % female_ratio }, { 'value': other, 'name': u'其他 %.2f%%' % other_ratio }], radius=["50%", "70%"])) chart.use(Legend(['male', 'female', 'other'])) del chart.json['xAxis'] del chart.json['yAxis'] chart.plot() # 保存图表 import os d = os.path.dirname(__file__) chart.save( os.path.dirname(__file__) + os.sep, '%s的好友性别比例' % (self.friends[0]['NickName'])) def signcloud(self): t_list = [] for i in self.friends: # 获取个性签名 signature = i['Signature'].strip().replace('span', '').replace( 'class', '').replace('emoji', '') # 正则匹配过滤掉emoji表情,例如enmoji1f3c3等 rep = re.compile('1f\d.+') signature = rep.sub('', signature) t_list.append(signature) # 拼接字符串 text = ''.join(t_list) # jieba分词 import jieba wordlist_jieba = jieba.cut(text, cut_all=True) wl_space_split = ' '.join(wordlist_jieba) # wordcloud词云 import matplotlib.pyplot as plt from wordcloud import WordCloud, ImageColorGenerator import os import numpy as np import PIL.Image as Image d = os.path.dirname(__file__) alice_coloring = np.array(Image.open(os.path.join(d, self.pic))) # 这里要选择字体存放路径,win字体在windows/Fonts中 my_wordcloud = WordCloud( background_color='black', max_words=2000, mask=alice_coloring, max_font_size=40, random_state=42, font_path=r'C:\Windows\Fonts\msyh.ttc').generate(wl_space_split) image_colors = ImageColorGenerator(alice_coloring) plt.imshow(my_wordcloud.recolor(color_func=image_colors)) plt.imshow(my_wordcloud) plt.axis('off') plt.show() # 保存图片,并发送手机 my_wordcloud.to_file( os.path.join(d, '%s好友的签名云.png') % (self.friends[0]['NickName'])) def nicknamecloud(self): t_list = [] for i in self.friends: # 获取个性签名 nickname = i['NickName'].strip().replace('span', '').replace( 'class', '').replace('emoji', '') # 正则匹配过滤掉emoji表情,例如enmoji1f3c3等 rep = re.compile('1f\d.+') nickname = rep.sub('', nickname) t_list.append(nickname) # 拼接字符串 text = ''.join(t_list) # jieba分词 import jieba wordlist_jieba = jieba.cut(text, cut_all=True) wl_space_split = ' '.join(wordlist_jieba) # wordcloud词云 import matplotlib.pyplot as plt from wordcloud import WordCloud, ImageColorGenerator import os import numpy as np import PIL.Image as Image d = os.path.dirname(__file__) alice_coloring = np.array(Image.open(os.path.join(d, self.pic))) # 这里要选择字体存放路径,win字体在windows/Fonts中 my_wordcloud = WordCloud( background_color='black', max_words=2000, mask=alice_coloring, max_font_size=40, random_state=42, font_path=r'C:\Windows\Fonts\msyh.ttc').generate(wl_space_split) image_colors = ImageColorGenerator(alice_coloring) plt.imshow(my_wordcloud.recolor(color_func=image_colors)) plt.imshow(my_wordcloud) plt.axis('off') plt.show() # 保存图片,并发送手机 my_wordcloud.to_file( os.path.join(d, '%s好友的名字云.png') % (self.friends[0]['NickName'])) def city_ratio(self): c_list = [] for i in self.friends: city = i['City'] if city != '': c_list.append(city) from collections import Counter c_dict = dict(Counter(c_list)) # 使用echarts from echarts import Echart, Legend, Pie chart = Echart(u'%s的微信各城市好友数量' % (self.friends[0]['NickName']), 'from WeChat') chart.use( Pie('WeChat', [{ 'value': value, 'name': u'{0}-{1}'.format(name, value) } for name, value in c_dict.items()], radius=["30%", "70%"])) chart.use(Legend(list(name for name, value in c_dict.items()))) del chart.json['xAxis'] del chart.json['yAxis'] chart.plot() # 保存图表 import os d = os.path.dirname(__file__) chart.save( os.path.dirname(__file__) + os.sep, '%s的好友城市人数' % (self.friends[0]['NickName'])) def showall(self): self.sexratio() self.city_ratio() self.signcloud() self.nicknamecloud() # 退出微信 itchat.logout()
def wechat_logout(self): itchat.logout()
def exitCallback(): itchat.logout() print("***已退出***")
def do_exit(args): """关闭程序,关闭后需手动开启""" itchat.send('关闭程序...', 'filehelper') sleep(2) itchat.logout()
def after_login(): #itchat.send_msg("Hello World", 'filehelper') #TEST #print(itchat.search_friends()) # Return account information. #print(itchat.send_msg('test.txt', '@56859a2cc5266ad423adb01f68d8e980aca8b23a04890a0fb60c7a42e1e4b415')) # TEST SENDING FILE TO FRIEND. print('Login successful as ' + itchat.search_friends()['NickName']) ''' The function that executes after auto reply is run, and handles operations apart from auto reply. The while loop ensures the run of program body. The process terminates when the while loop ends. ''' def after_run(): while isRunning: pass return None #PLACEHOLDER ''' Login and autoreply. @param hotReload = True: After first login by scanning QR code, @param loginCallback: the function that calls back after login completion. ''' print('Running WeChat.py') itchat.auto_login(loginCallback=after_login) itchat.run(blockThread=False) # Start auto reply without blocking thread. after_run() itchat.logout() # Log out the WeChat when program terminates.
def LogOut(): itchat.logout()
def end(self): itchat.logout() print("微信退出成功")
def _stop(self): itchat.logout()
def stop(self): itchat.logout() info('itchat logout')
def logout(): delete_all() itchat.logout() return redirect(url_for('weixin.login'))
def logout(self): itchat.logout()
#itchat.auto_login(loginCallback=lc, exitCallback=ec) itchat.auto_login() def findFriend(NickName): for firend in itchat.get_friends(): #print firend["NickName"]; if firend["NickName"] == NickName: return firend #定义用户的昵称 nickName = u'点点水' #查找用户的userid #user = itchat.search_friends(send_userid); user = findFriend(nickName) itcaht_user_name = "" if user is not None: print(user) itcaht_user_name = user['UserName'] if user is not None and itcaht_user_name != '': #利用send_msg发送消息 itchat.send_msg(u'这是一个测试', toUserName=itcaht_user_name) time.sleep(1000) itchat.logout() #强制退出登录 # 原文:https://blog.csdn.net/enweitech/article/details/79585043
def wechat_logout(): itchat.send('登出',toUserName = '******') itchat.logout() print("成功登出!")
def main(): itchat.send('рямкЁЖ╥ЧнЯё║', 'filehelper') itchat.logout()
def logout(): itchat.logout()
def Execution(self, message): """ 执行命令 :param message: 微信消息中提取的命令 :return: 无 """ # "%s%s%s%s%s关键词" % ("="*4, "Command Message", "="*4, "\n\n", action) command = message['Text'] msg_send = "{0}{1}{0}{2}".format("=" * 8, "助手消息", "\n\n") if re.match(r"^查看文件\[.*\]", command): filename = re.search(r"^查看文件\[(.*?)\]$", command).group(1) result = self.ShowFile(filename) if result == True: pass else: msg_send += result itchat.send(msg_send, toUserName='******') elif re.match(r"^删除文件\[.*\]", command): filename = re.search(r"^删除文件\[(.*?)\]$", command).group(1) msg_send += self.DeleteFile(filename) itchat.send(msg_send, toUserName='******') elif re.match(r"^添加关键词\[.*\]", command): keyword = re.search(r"^添加关键词\[(.*?)\]", command).group(1) msg_send += self.keyword.AddKeyword(keyword) itchat.send(msg_send, toUserName='******') elif re.match(r"^删除关键词\[.*\]", command): keyword = re.search(r"^删除关键词\[(.*?)\]", command).group(1) msg_send += self.keyword.DeleteKeyword(keyword) itchat.send(msg_send, toUserName='******') elif re.match(r"^撤回附件列表$", command): self.ReturnAttachmentList() elif re.match(r"^清空附件列表$", command): self.ClearAttachmentList() elif re.match("^查看关键词$", command): msg_send += self.keyword.ShowKeyword() itchat.send(msg_send, toUserName='******') elif re.match("^清空关键词$", command): msg_send += self.keyword.ClearKeyword() itchat.send(msg_send, toUserName='******') elif re.match("^查看签到口令$", command): msg_send += self.snin.ShowComd() itchat.send(msg_send, toUserName='******') elif re.match("^清空签到口令$", command): msg_send += self.snin.ClearComd() itchat.send(msg_send, toUserName='******') elif re.match("^添加签到口令\[.*?\]$", command): mps, cmd = re.search("^添加签到口令\[(.*?):(.*?)\]$", command).group(1, 2) self.snin.AddComd(mps, cmd) msg_send += "添加签到口令[{}:{}]成功".format(mps, cmd) itchat.send(msg_send, toUserName='******') elif re.match("^删除签到口令\[.*?\]$", command): mps = re.search("^删除签到口令\[(.*?)\]$", command).group(1) msg_send += self.snin.DeleteComd(mps) itchat.send(msg_send, toUserName='******') elif re.match("^截图$", command): screenshoot.SC() elif re.match("^添加自动回复\[.*?\]$", command): keyword, content = re.search("^添加自动回复\[(.*?):(.*?)\]$", command).group(1, 2) msg_send += self.reply.AddRule(keyword, content) itchat.send(msg_send, toUserName="******") elif re.match("^删除自动回复\[.*\]$", command): keyword = re.search("^删除自动回复\[(.*?)\]$", command).group(1) msg_send += self.reply.DeleteRule(keyword) itchat.send(msg_send, toUserName='******') elif re.match("^清空自动回复$", command): msg_send += self.reply.ClearRule() itchat.send(msg_send, toUserName='******') elif re.match("^查看自动回复$", command): msg_send += self.reply.ShowRule() itchat.send(msg_send, toUserName='******') elif re.match("^关闭自动回复$", command): msg_send += self.reply.CloseAutoReply() itchat.send(msg_send, toUserName='******') elif re.match("^打开自动回复$", command): msg_send += self.reply.OpenAutoReply() itchat.send(msg_send, toUserName='******') elif re.match("^拍照$", command): msg_send += "功能未开发,敬请期待" itchat.send(msg_send, toUserName='******') """ img_name = TakePhoto() if img_name: itchat.send("@img@{}".format(img_name), toUserName='******') else: msg_send += "拍照失败,请重试" itchat.send(msg_send, toUserName='******') """ elif re.match("^拍动图\d{0,2}$", command): msg_send += "功能未开发,敬请期待" itchat.send(msg_send, toUserName='******') """ seconds = re.findall("^拍动图(\d+)", command) if seconds: seconds = int(seconds[0]) if seconds not in range(1, 61): msg_send += "时间输入错误,请重试" itchat.send(msg_send, toUserName='******') return else: seconds = 5 img_name = TakeGIF(seconds) if img_name: itchat.send("@img@{}".format(img_name), toUserName='******') else: msg_send += "拍照失败,请重试" itchat.send(msg_send, toUserName='******') """ elif re.match("^今天吃什么$", command): today_choice = random.choice(config.today_menu) emotion = random.choice(config.emoticons) msg_send += "今天就吃 {} 吧{}{}".format(today_choice, '\n', emotion) itchat.send(msg_send, toUserName='******') elif re.match("^退出程序$", command): itchat.send("退出程序成功", toUserName='******') itchat.logout() os._exit(0) else: itchat.send( r"暂时支持以下指令:{1}" r"查看/删除文件[文件名]{0}e.g.查看[123345234.mp3]{1}" r"撤回附件列表(查看都有哪些保存在电脑中的已撤回附件){1}" r"清空附件列表(清空已经保存在电脑中的附件){1}" r"添加关键词[关键词]{0}e.g.设置关键词[在不在]{1}" r"删除关键词[关键词]{0}e.g.删除关键词[在不在]{1}" r"清空关键词 清空已经设置的所有关键词{1}" r"查看关键词 查看目前设置的关键词{1}" r"添加签到口令[公众号:签到口令]{0}e.g.添加签到口令[招商银行信用卡:签到]{1}" r"删除签到口令[公众号]{0}e.g.删除签到口令[招商银行信用卡]{1}" r"查看签到口令 查看已经存在的公众和和对应的签到口令{1}" r"清空签到口令 清空所有签到口令{1}" r"截图 截取运行本程序的机器当前界面{1}" r"添加自动回复[针对的关键词:回复内容]{0}e.g.添加自动回复[在不在:我现在有事情,待会儿回复你]{1}" r"删除自动回复[针对的关键词]{0}e.g.删除自动回复[在不在]{1}" r"清空自动回复{1}" r"关闭自动回复{1}" r"打开自动回复{1}" r"今天吃什么{1}" r"退出程序{1}" r"其他指令暂不支持,请期待最新版本。".format("\n", "\n\n"), toUserName="******")
def logout(): """退出登录""" itchat.logout()
def logout(self): itchat.logout() time.sleep(1) quitApp()
def exit_wechat(): write_log("微信辅助系统关闭成功", True) itchat.logout() sys.exit()
def main(): itchat.login() get_signature() cloud_pic() itchat.logout()
def jiance(gpdm, pb, ps, vb, vs): if datetime.now().hour < 9: print( f"sleep{(datetime.now().replace(hour=9,minute=25) - datetime.now()).seconds}seconds,{(datetime.now().replace(hour=9,minute=25) - datetime.now()).seconds / 60} minutes" ) time.sleep((datetime.now().replace(hour=9, minute=25) - datetime.now()).seconds) if datetime.now().hour > 11 and datetime.now().hour < 13: print( f"sleep{(datetime.now().replace(hour=13,minute=0) - datetime.now()).seconds}seconds,{(datetime.now().replace(hour=13,minute=0) - datetime.now()).seconds / 60} minutes" ) time.sleep((datetime.now().replace(hour=13, minute=0) - datetime.now()).seconds) gpdms = gpdm[2:] # datadf = ts.get_k_data(gpdms, autype="qfq") # if type(datadf) == type(None): print(gpdm, "NoneType") return if len(datadf) < 100: print(gpdm, "duan") return # now = datetime.now() # x = datetime.strptime(datadf.date[datadf.index[0] +len(datadf) - 1], "%Y-%m-%d") # # print(gpdm,datadf.index[0]) # if (now - x).days > 15: # print(gpdm,"tingpan") # return # qnow = datadf.volume[datadf.index[datadf.index[0] + len(datadf) - 1]] # pnow = datadf.close[datadf.index[datadf.index[0] + len(datadf) - 1]] #minmean = datadf.volume[datadf.index[datadf.index[0] + len(datadf) - 45]:datadf.index[datadf.index[0] + len(datadf) - 1]].min() minmean = vb # maxmean = sum(sorted(datadf.volume[datadf.index[datadf.index[0] + len(datadf) - 45]:datadf.index[datadf.index[0] + len(datadf) - 1]])[42:]) / 3 maxmean = vs n = 0 result = [] while True: now = datetime.now() r = requests.get(f'http://hq.sinajs.cn/list={gpdm}') k = float(r.text.split(',')[1]) s = float(r.text.split(',')[2]) v = int(float(r.text.split(',')[8])) / 100 p = float(r.text.split(',')[3]) name = r.text.split(",")[0].split("=")[1].strip("\"") rate = str(round((p / s - 1) * 100, 3)) + "%" print_daxie(datetime.now(), v, gpdm, name, p, rate) if now.hour == 9 and now.minute == 45: predq = v * 16 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if now.hour == 10 and now.minute == 0: predq = v * 16 / 2 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if now.hour == 10 and now.minute == 15: predq = v * 16 / 3 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if now.hour == 10 and now.minute == 30: predq = v * 16 / 4 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if now.hour == 10 and now.minute == 45: predq = v * 16 / 5 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if now.hour == 11 and now.minute == 0: predq = v * 16 / 6 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if now.hour == 11 and now.minute == 15: predq = v * 16 / 7 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if now.hour == 11 and now.minute == 25: predq = v * 16 / 8 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if now.hour == 13 and now.minute == 15: predq = v * 16 / 9 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if now.hour == 13 and now.minute == 30: predq = v * 16 / 10 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if now.hour == 13 and now.minute == 45: predq = v * 16 / 11 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if now.hour == 14 and now.minute == 0: predq = v * 16 / 12 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if now.hour == 14 and now.minute == 15: predq = v * 16 / 13 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if now.hour == 14 and now.minute == 30: predq = v * 16 / 14 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if now.hour == 14 and now.minute == 45: predq = v * 16 / 15 if predq > maxmean or p > ps: send_email( _user, _pwd, _to, "成交量提醒", f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"卖出 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if predq < minmean or p < pb: send_email( _user, _pwd, _to, "成交量提醒", f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") # itchat.search_friends(name="禅语")[0].send(f"卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"买入 {name}{gpdms}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}") if v > maxmean and n < 1: send_email( _user, _pwd, _to, "成交量提醒", f"现在卖出 {name}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}, 量比{round(v / minmean,2)}" ) show(f"sell for predicted quantity is high at {v}") # itchat.search_friends(name="禅语")[0].send(f"现在卖出 {name}{gpdm}: 现成交量 {daxie(q)}, 现价{p}, 涨幅{rate}, 量比{round(q / minmean,2)}") itchat.search_chatrooms(name="triple_group")[0].send( f"现在卖出 {name}{gpdm}: 现成交量 {daxie(v)}, 现价{p}, 涨幅{rate}, 量比{round(v / minmean,2)}(之后不再提醒)" ) result.append([v, p, now, "sell"]) n += 1 time.sleep(59) if now.hour >= 15: os.chdir(r'C:\Users\qeaw\Desktop\test') with open( gpdm + "m" + str(datetime.now().month) + "d" + str(datetime.now().day) + ".txt", 'w') as f: f.write(str(result)) break print('end loop for', gpdm) itchat.logout()
def handle_receive_msg(msg): global face_bug msg_time_rec = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # 接受消息的时间 msg_from = itchat.search_friends( userName=msg['FromUserName'])['nickName'] # 在好友列表中查询发送信息的好友昵称 msg_time = msg['CreateTime'] # 信息发送的时间 msg_id = msg['MsgId'] # 每条信息的id msg_content = None # 储存信息的内容 msg_share_url = None # 储存分享的链接,比如分享的文章和音乐 print(msg['Type']) print(msg_from) if msg['Type'] == 'Text' or msg['Type'] == 'Friends': # 如果发送的消息是文本或者好友推荐 msg_content = msg['Text'] if msg_from == "Mr.Crab" and msg_content == "exit!!!": itchat.send_msg("20秒后退出微信服务器监控端...", toUserName="******") time.sleep(20) itchat.logout() print(msg_content) # 如果发送的消息是附件、视屏、图片、语音 elif msg['Type'] == "Attachment" or msg['Type'] == "Video" \ or msg['Type'] == 'Picture' \ or msg['Type'] == 'Recording': msg_content = msg['FileName'] # 内容就是他们的文件名 msg['Text']('/home/wechat/pic/' + str(msg_content)) # 下载文件 # print msg_content elif msg['Type'] == 'Card': # 如果消息是推荐的名片 msg_content = msg['RecommendInfo']['nickName'] + '的名片' # 内容就是推荐人的昵称和性别 if msg['RecommendInfo']['Sex'] == 1: msg_content += '性别为男' else: msg_content += '性别为女' print(msg_content) elif msg['Type'] == 'Map': # 如果消息为分享的位置信息 x, y, location = re.search( "<location x=\"(.*?)\" y=\"(.*?)\".*label=\"(.*?)\".*", msg['OriContent']).group(1, 2, 3) if location is None: msg_content = r"纬度->" + x.__str__() + " 经度->" + y.__str__( ) # 内容为详细的地址 else: msg_content = r"" + location elif msg['Type'] == 'Sharing': # 如果消息为分享的音乐或者文章,详细的内容为文章的标题或者是分享的名字 msg_content = msg['Text'] msg_share_url = msg['Url'] # 记录分享的url print(msg_share_url) face_bug = msg_content ##将信息存储在字典中,每一个msg_id对应一条信息 msg_information.update({ msg_id: { "msg_from": msg_from, "msg_time": msg_time, "msg_time_rec": msg_time_rec, "msg_type": msg["Type"], "msg_content": msg_content, "msg_share_url": msg_share_url } })
def Choose_MainMenu(): global g_isDone, g_autoAddFriend, g_autoReplyFriend, g_autoReplyGroup, g_checkIfCallback global g_autoReplyFriendBytuling, g_autoReplygroupBytuling, g_isTulingReady, g_tulingAPIKey print("请选择:", end="") c = input() #print(c) if c == '1.1': print("正在分析,请稍等", end="") Thread(target=getSexRate).start() while (True): if g_isDone == False: print(".", end="", flush=True) sleep(0.2) else: break return if c == '1.2': print("正在分析,请稍等", end="") Thread(target=getAreaRate).start() while (True): if g_isDone == False: print(".", end="", flush=True) sleep(0.2) else: break return if c == '1.3': print("正在分析,请稍等", end="") Thread(target=getFriends).start() while (True): if g_isDone == False: print(".", end="", flush=True) sleep(0.2) else: break return if c == '1.4': while (True): if g_autoAddFriend == True: print("自动添加好友当前已开启,是否关闭?(y/n): ", end="") c = input() if c == 'Y' or c == 'y': g_autoAddFriend = False print("自动添加好友已关闭!") break elif c == 'N' or c == 'n': break else: print("输入错误请重新输入!") else: print("自动添加好友当前已关闭,是否开启?(y/n): ", end="") c = input() if c == 'Y' or c == 'y': g_autoAddFriend = True print("自动添加好友已开启!") break elif c == 'N' or c == 'n': break else: print("输入错误请重新输入!") return if c == '2.1': print("正在分析,请稍等", end="") Thread(target=getChatrooms).start() while (True): if g_isDone == False: print(".", end="", flush=True) sleep(0.2) else: break return if c == '2.2': while (True): if g_autoReplyGroup == True: print("自动回复群@消息当前已开启,是否关闭?(y/n): ", end="") c = input() if c == 'Y' or c == 'y': g_autoReplyGroup = False print("自动回复群@消息已关闭!") break elif c == 'N' or c == 'n': break else: print("输入错误请重新输入!") else: print("自动回复群@消息当前已关闭,是否开启?(y/n): ", end="") c = input() if c == 'Y' or c == 'y': g_autoReplyGroup = True print("自动回复群@消息已开启!") break elif c == 'N' or c == 'n': break else: print("输入错误请重新输入!") return if c == '3.1': while (True): if g_autoReplyFriend == True: print("自动回复私聊消息当前已开启,是否关闭?(y/n): ", end="") c = input() if c == 'Y' or c == 'y': g_autoReplyFriend = False print("自动回复私聊消息已关闭!") break elif c == 'N' or c == 'n': break else: print("输入错误请重新输入!") else: print("自动回复私聊消息当前已关闭,是否开启?(y/n): ", end="") c = input() if c == 'Y' or c == 'y': g_autoReplyFriend = True print("自动回复私聊消息已开启!") break elif c == 'N' or c == 'n': break else: print("输入错误请重新输入!") return if c == '3.2': print("请注意:自动监控撤回消息开启后,会自动下载语音和图片附件。") while (True): if g_checkIfCallback == True: print("自动监控撤回消息当前已开启,是否关闭?(y/n): ", end="") c = input() if c == 'Y' or c == 'y': g_checkIfCallback = False print("自动监控撤回消息已关闭!") break elif c == 'N' or c == 'n': break else: print("输入错误请重新输入!") else: print("自动监控撤回消息当前已关闭,是否开启?(y/n): ", end="") c = input() if c == 'Y' or c == 'y': g_checkIfCallback = True print("自动监控撤回消息已开启!") break elif c == 'N' or c == 'n': break else: print("输入错误请重新输入!") return if c == '4.1': while (True): print("请输入您申请到的图灵机器人APIKey:", end="") g_tulingAPIKey = input() print("正在测试连接,请稍等", end="") Thread(target=tuling_checkReady).start() while (True): if g_isDone == False: print(".", end="", flush=True) sleep(0.2) else: break return return if c == '4.2': if g_isTulingReady == False: print("图灵机器人连接失败,请先检查配置!") return while (True): if g_autoReplyFriendBytuling == True: print("图灵机器人代答私聊消息当前已开启,是否关闭?(y/n): ", end="") c = input() if c == 'Y' or c == 'y': g_autoReplyFriendBytuling = False print("图灵机器人代答私聊消息已关闭!") break elif c == 'N' or c == 'n': break else: print("输入错误请重新输入!") else: print("图灵机器人代答私聊消息已关闭,是否开启?(y/n): ", end="") c = input() if c == 'Y' or c == 'y': g_autoReplyFriendBytuling = True print("图灵机器人代答私聊消息已开启!") break elif c == 'N' or c == 'n': break else: print("输入错误请重新输入!") return if c == '4.3': if g_isTulingReady == False: print("图灵机器人连接失败,请先检查配置!") return while (True): if g_autoReplygroupBytuling == True: print("图灵机器人代答群聊@消息当前已开启,是否关闭?(y/n): ", end="") c = input() if c == 'Y' or c == 'y': g_autoReplygroupBytuling = False print("图灵机器人代答群聊@消息已关闭!") break elif c == 'N' or c == 'n': break else: print("输入错误请重新输入!") else: print("图灵机器人代答群聊@消息已关闭,是否开启?(y/n): ", end="") c = input() if c == 'Y' or c == 'y': g_autoReplygroupBytuling = True print("图灵机器人代答群聊@消息已开启!") break elif c == 'N' or c == 'n': break else: print("输入错误请重新输入!") return if c == '7.1': print("正在保存,请稍等", end="") Thread(target=save_config).start() while (True): if g_isDone == False: print(".", end="", flush=True) sleep(0.2) else: break return if c == '7.2': print("正在读取,请稍等", end="") Thread(target=read_config).start() while (True): if g_isDone == False: print(".", end="", flush=True) sleep(0.2) else: break return if c == '7.3': print("-------------------------------") print("当前配置如下:") print("-------------------------------") print("自动加好友: %s" % (str(g_autoAddFriend))) print("自动回复好友:%s" % (str(g_autoReplyFriend))) print("自动监控消息撤回:%s" % (str(g_checkIfCallback))) print("自动回复群@消息:%s" % (str(g_autoReplyGroup))) print("图灵机器人APIKey:%s" % (str(g_tulingAPIKey))) print("图灵机器人代答私聊消息:%s" % (str(g_autoReplyFriendBytuling))) print("图灵机器人代答群聊@消息:%s" % (str(g_autoReplygroupBytuling))) print("-------------------------------") return if c == '8': Screen_Clear() return if c == '9': print("已退出登陆!") itchat.logout() global g_isLogin g_isLogin = False main() return else: print("输入错误请重新输入") Choose_MainMenu()
def logout(sigrecv, frame): itchat.logout() exit(0)
def post(self, request): itchat.logout() return HttpResponse("success")
import winsound # import os # import pygame def alarm(): # Windows嗡鸣声 winsound.Beep(1000, 3000) # # Mac语音 # os.system('say "有人发红包了,赶紧去抢啊!红红火火恍恍惚惚哈哈哈哈"') # # 播放MP3 # pygame.mixer.init() # track = pygame.mixer.music.load('alarm.mp3') # pygame.mixer.music.play() tkinter.messagebox.showinfo('重要提醒','有人发红包了!') @itchat.msg_register('Note', isGroupChat=True) def get_note(msg): if '红包' in msg['Text']: print('note:',msg['Text']) alarm() @itchat.msg_register(itchat.content.TEXT, isGroupChat=True) def _(msg): print('text:',msg['Text']) itchat.auto_login(hotReload=True) itchat.run() itchat.logout()
def __del__(self): itchat.logout()