我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用itchat.run()。
def __init__(self, game_controller): super().__init__(game_controller) self.username_to_user = {} # Map Wechat user name to WechatUser object self.send_msg_queue = queue.Queue() # Avoid sending messages too fast by buffering # Start listening Wechat messages itchat.auto_login() threading.Thread(target = itchat.run).start() # Send messages in another thread threading.Thread(target = self.send_messages_in_queue).start() # Accept new messages from players @itchat.msg_register(itchat.content.TEXT) def listen_wechat_message(message_info): username = message_info['User']['UserName'] # User name of the Wechat user text = message_info['Text'] # Content of the message self.got_message(username, text)
def run(self): """???Bot""" logger.info("Bot Server start running...") try: itchat.auto_login(hotReload=True, enableCmdQR=2) self.after_login() itchat.run() except KeyboardInterrupt: logger.info("KeyboardInterrupt occurred ... Quitting, Bye.") self.before_destory()
def main(): itchat.auto_login(enableCmdQR=True + (platform.system() == 'Linux')) itchat.run()
def run(): @itchat.msg_register(TEXT) def open(msg): if u'??' in msg['Text']: open_txt()
def run(self): itchat.auto_login() itchat.run()
def run(self): sysstr = platform.system() if (sysstr == "Linux") or (sysstr == "Darwin"): itchat.auto_login(enableCmdQR=2, hotReload=True) else: itchat.auto_login(hotReload=True) itchat.run(True)