version 0.0.7

This commit is contained in:
张明明 2024-05-06 20:03:31 +08:00
parent 5251487872
commit f0a9340a51
4 changed files with 8 additions and 7 deletions

View File

@ -18,7 +18,7 @@ URL = 'https://github.com/miloira/wxhook'
EMAIL = '690126048@qq.com'
AUTHOR = 'Msky'
REQUIRES_PYTHON = '>=3.8.0'
VERSION = '0.0.6'
VERSION = '0.0.7'
# What packages are required for this module to be executed?
REQUIRED = [

View File

@ -1,3 +1,3 @@
from .core import Bot
version = "0.0.6"
version = "0.0.7"

View File

@ -70,10 +70,11 @@ class Bot:
try:
code, output = start_wechat_with_inject(self.remote_port)
if code == 1:
raise Exception(output)
except Exception:
output = get_pid(self.remote_port)
code, output = get_pid(self.remote_port)
if code == 1:
raise Exception(output)
self.process = psutil.Process(int(output))

View File

@ -33,9 +33,9 @@ def get_processes(process_name: str) -> typing.List[psutil.Process]:
return processes
def get_pid(port: int) -> int:
def get_pid(port: int) -> typing.Tuple[int, int]:
output = subprocess.run(f"netstat -ano | findStr \"{port}\"", capture_output=True, text=True, shell=True).stdout
return int(output.split("\n")[0].split("LISTENING")[-1])
return 0, int(output.split("\n")[0].split("LISTENING")[-1])
def parse_xml(xml: str) -> dict: