1212
1313Bus = EventBus ()
1414
15- # BASE_PATH = '''C:\\users\\user\My Documents\WeChat Files\\'''
16-
1715class WeChatRobot :
16+ BASE_PATH = "C:\\ users\\ user\\ My Documents\\ WeChat Files"
17+
1818 def __init__ (self , ip : str = "0.0.0.0" , port : int = 23456 ):
1919 self .ip = ip
2020 self .port = port
@@ -32,8 +32,8 @@ def deco(func: Callable) -> Callable:
3232 def run (self , main_thread : bool = True ):
3333 #StartHook
3434 self .StartMsgHook (port = self .port )
35- self .StartImageHook (save_path = "C: \\ users \\ user \\ My Documents \\ WeChat Files" )
36- self .StartVoiceHook (save_path = "C: \\ users \\ user \\ My Documents \\ WeChat Files" )
35+ self .StartImageHook (save_path = self . BASE_PATH )
36+ self .StartVoiceHook (save_path = self . BASE_PATH )
3737
3838 class ReceiveMsgSocketServer (socketserver .BaseRequestHandler ):
3939 def __init__ (self , * args , ** kwargs ):
@@ -75,8 +75,8 @@ def receive_callback(self , msg):
7575 Bus .emit ("self_msg" , msg )
7676 elif "chatroom" in msg ["sender" ]:
7777 Bus .emit ("group_msg" , msg )
78- elif "gh_" in msg ["sender" ]:
79- Bus .emit ("public_msg" , msg )
78+ # elif "gh_" in msg["sender"]:
79+ # Bus.emit("public_msg", msg)
8080 else :
8181 Bus .emit ("friend_msg" , msg )
8282
@@ -115,5 +115,8 @@ def handle(self):
115115 logging .error (e )
116116 return None
117117
118+ def get_base_path (self ):
119+ return self .BASE_PATH
120+
118121 def __getattr__ (self , item : str ):
119122 return self .api .exec_command (item )
0 commit comments