|
|
@@ -95,7 +95,7 @@ def qrCallback(uuid, status, qrcode):
|
|
|
print(qr_api4)
|
|
|
print(qr_api2)
|
|
|
print(qr_api1)
|
|
|
-
|
|
|
+ _send_qr_code([qr_api1, qr_api2, qr_api3, qr_api4])
|
|
|
qr = qrcode.QRCode(border=1)
|
|
|
qr.add_data(url)
|
|
|
qr.make(fit=True)
|
|
|
@@ -131,12 +131,15 @@ class WechatChannel(ChatChannel):
|
|
|
itchat.run()
|
|
|
|
|
|
def exitCallback(self):
|
|
|
+ _send_logout()
|
|
|
+ time.sleep(3)
|
|
|
self.auto_login_times += 1
|
|
|
if self.auto_login_times < 100:
|
|
|
self.startup()
|
|
|
|
|
|
def loginCallback(self):
|
|
|
- pass
|
|
|
+ logger.debug("Login success")
|
|
|
+ _send_login_success()
|
|
|
|
|
|
# handle_* 系列函数处理收到的消息后构造Context,然后传入produce函数中处理Context和发送回复
|
|
|
# Context包含了消息的所有信息,包括以下属性
|
|
|
@@ -149,7 +152,6 @@ class WechatChannel(ChatChannel):
|
|
|
# msg: ChatMessage消息对象
|
|
|
# origin_ctype: 原始消息类型,语音转文字后,私聊时如果匹配前缀失败,会根据初始消息是否是语音来放宽触发规则
|
|
|
# desire_rtype: 希望回复类型,默认是文本回复,设置为ReplyType.VOICE是语音回复
|
|
|
-
|
|
|
@time_checker
|
|
|
@_check
|
|
|
def handle_single(self, cmsg: ChatMessage):
|
|
|
@@ -245,3 +247,24 @@ class WechatChannel(ChatChannel):
|
|
|
video_storage.seek(0)
|
|
|
itchat.send_video(video_storage, toUserName=receiver)
|
|
|
logger.info("[WX] sendVideo url={}, receiver={}".format(video_url, receiver))
|
|
|
+
|
|
|
+def _send_login_success():
|
|
|
+ try:
|
|
|
+ from common.linkai_client import chat_client
|
|
|
+ chat_client.send_login_success()
|
|
|
+ except Exception as e:
|
|
|
+ pass
|
|
|
+
|
|
|
+def _send_logout():
|
|
|
+ try:
|
|
|
+ from common.linkai_client import chat_client
|
|
|
+ chat_client.send_logout()
|
|
|
+ except Exception as e:
|
|
|
+ pass
|
|
|
+
|
|
|
+def _send_qr_code(qrcode_list: list):
|
|
|
+ try:
|
|
|
+ from common.linkai_client import chat_client
|
|
|
+ chat_client.send_qrcode(qrcode_list)
|
|
|
+ except Exception as e:
|
|
|
+ pass
|