def reply_fn(): try: while True: itchat.configured_reply() except KeyboardInterrupt: # itchat.dump_login_status() pass
def main(): itchat.logout() #Reset the status itchat.auto_login(hotReload=True) #, enableCmdQR=True) print("Running....") #itchat.run() #失控,不好,用configured_reply() # 使用configured_reply方法 global stop while not stop: itchat.configured_reply()
def dynamic_msg(): '''Dynamic acquisition of anyone's message Once acquired, the program releases''' while 1: msg = get_msg() if msg == None: time.sleep(.6) itchat.configured_reply() continue else: return msg
def dynamic_specified_msg(userName=None): ''' Dynamic acquisition of specified user's message Once acquired, the program releases ''' while 1: msg = get_msg() try: msg_userName = msg.user.userName except: msg_userName = None if msg_userName == None or msg_userName != userName: time.sleep(.6) itchat.configured_reply() continue else: return msg
# itchat.send(msg['Text'], msg['FromUserName']) # itchat.send('注意以下发言为自动回复', msg['FromUserName']) global online if online: if msg['isAt']: print(msg['Text']) temp_name['name'] = msg['FromUserName'] itchat.send(msg['Content'], 'ms-xiaoice') else: pass # txt = auto_msg(msg['Text']) # print(txt) # itchat.send(txt, msg['FromUserName']) # 在注册时增加isGroupChat=True将判定为群聊回复 # @itchat.msg_register(itchat.content.TEXT, isGroupChat = True) # def groupchat_reply(msg): # # if msg['isAt']: # txt = auto_msg(msg['Text']) # # itchat.send(u'@%s\u2005I received: %s' % (msg['ActualNickName'], txt), msg['FromUserName']) # itchat.send(txt, msg['FromUserName']) # # msg['Content'] itchat.auto_login(True) _thread.start_new_thread(itchat.run()) while 1: itchat.configured_reply() time.sleep(0.1)