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