Skip to content

Commit 9c77f81

Browse files
committed
修复在电脑端发送再次转发的问题
1 parent c5dbace commit 9c77f81

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

1.jpg

3.59 KB
Loading

wechatrobot/Api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ def ForwardMessage(self , **params) -> Dict:
133133
return self.post(WECHAT_MSG_FORWARD_MESSAGE , ForwardMessageBody(**params))
134134

135135
def GetQrcodeImage(self , **params):
136-
return self.post(WECHAT_GET_QRCODE_IMAGE , GetQrcodeImageBody(**params))
136+
r = requests.post( f"http://127.0.0.1:{self.port}/api/?type={WECHAT_GET_QRCODE_IMAGE}", data = GetQrcodeImageBody(**params).json())
137+
return r.content
137138

138139
#[自定义
139140
def GetDBHandle(self) -> Union[None, int]:

wechatrobot/WeChatRobot.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
Bus = EventBus()
1414

15-
BASE_PATH = '''C:\\users\\user\My Documents\WeChat Files\\'''
15+
# BASE_PATH = '''C:\\users\\user\My Documents\WeChat Files\\'''
1616

1717
class WeChatRobot:
1818
def __init__(self , ip : str = "0.0.0.0" , port : int = 23456):
@@ -70,8 +70,9 @@ def receive_callback(self , msg):
7070

7171
msg['type'] = type_dict.get(msg['type'] , 'unhandled')
7272

73-
if 1 == msg["isSendMsg"] and 1 == msg["isSendByPhone"]:
74-
Bus.emit("self_msg", msg)
73+
if (1 == msg["isSendMsg"]):
74+
if 1 == msg["isSendByPhone"]:
75+
Bus.emit("self_msg", msg)
7576
elif "chatroom" in msg["sender"]:
7677
Bus.emit("group_msg", msg)
7778
elif "gh_" in msg["sender"]:
@@ -115,9 +116,4 @@ def handle(self):
115116
return None
116117

117118
def __getattr__(self , item : str):
118-
return self.api.exec_command(item)
119-
120-
if __name__ == "__main__":
121-
robot = WeChatRobot()
122-
123-
robot.run(main_thread = True)
119+
return self.api.exec_command(item)

0 commit comments

Comments
 (0)