mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-28 03:27:31 +08:00
fix ide warnings
This commit is contained in:
@@ -104,6 +104,9 @@ def send_proactive_c2c_message(
|
|||||||
"""
|
"""
|
||||||
主动发送 C2C 单聊消息(不需要 msg_id)
|
主动发送 C2C 单聊消息(不需要 msg_id)
|
||||||
注意:每月限 4 条/用户,且用户必须曾与机器人交互过
|
注意:每月限 4 条/用户,且用户必须曾与机器人交互过
|
||||||
|
:param access_token: 访问令牌
|
||||||
|
:param openid: 用户 openid
|
||||||
|
:param content: 消息内容
|
||||||
:param use_markdown: 是否使用 Markdown 格式(需机器人开通 Markdown 能力)
|
:param use_markdown: 是否使用 Markdown 格式(需机器人开通 Markdown 能力)
|
||||||
"""
|
"""
|
||||||
if not content or not content.strip():
|
if not content or not content.strip():
|
||||||
@@ -124,6 +127,9 @@ def send_proactive_group_message(
|
|||||||
"""
|
"""
|
||||||
主动发送群聊消息(不需要 msg_id)
|
主动发送群聊消息(不需要 msg_id)
|
||||||
注意:每月限 4 条/群,且群必须曾与机器人交互过
|
注意:每月限 4 条/群,且群必须曾与机器人交互过
|
||||||
|
:param access_token: 访问令牌
|
||||||
|
:param group_openid: 群聊 openid
|
||||||
|
:param content: 消息内容
|
||||||
:param use_markdown: 是否使用 Markdown 格式(需机器人开通 Markdown 能力)
|
:param use_markdown: 是否使用 Markdown 格式(需机器人开通 Markdown 能力)
|
||||||
"""
|
"""
|
||||||
if not content or not content.strip():
|
if not content or not content.strip():
|
||||||
@@ -185,6 +191,7 @@ def send_message(
|
|||||||
) -> dict:
|
) -> dict:
|
||||||
"""
|
"""
|
||||||
统一发送接口
|
统一发送接口
|
||||||
|
:param access_token: 访问令牌
|
||||||
:param target: openid(c2c)或 group_openid(group)
|
:param target: openid(c2c)或 group_openid(group)
|
||||||
:param content: 消息内容
|
:param content: 消息内容
|
||||||
:param msg_type: c2c 单聊 / group 群聊
|
:param msg_type: c2c 单聊 / group 群聊
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ def run_gateway(
|
|||||||
payload = {"op": 1, "d": last_seq}
|
payload = {"op": 1, "d": last_seq}
|
||||||
ws_ref[0].send(json.dumps(payload))
|
ws_ref[0].send(json.dumps(payload))
|
||||||
logger.debug(f"[QQ Gateway:{config_name}] Heartbeat sent, seq={last_seq}")
|
logger.debug(f"[QQ Gateway:{config_name}] Heartbeat sent, seq={last_seq}")
|
||||||
except Exception as e:
|
except Exception as err:
|
||||||
logger.debug(f"[QQ Gateway:{config_name}] Heartbeat error: {e}")
|
logger.debug(f"[QQ Gateway:{config_name}] Heartbeat error: {err}")
|
||||||
if heartbeat_interval_ms and not stop_event.is_set():
|
if heartbeat_interval_ms and not stop_event.is_set():
|
||||||
heartbeat_timer = threading.Timer(heartbeat_interval_ms / 1000.0, send_heartbeat)
|
heartbeat_timer = threading.Timer(heartbeat_interval_ms / 1000.0, send_heartbeat)
|
||||||
heartbeat_timer.daemon = True
|
heartbeat_timer.daemon = True
|
||||||
@@ -60,8 +60,8 @@ def run_gateway(
|
|||||||
nonlocal last_seq, heartbeat_interval_ms, heartbeat_timer
|
nonlocal last_seq, heartbeat_interval_ms, heartbeat_timer
|
||||||
try:
|
try:
|
||||||
payload = json.loads(message)
|
payload = json.loads(message)
|
||||||
except json.JSONDecodeError as e:
|
except json.JSONDecodeError as err:
|
||||||
logger.error(f"[QQ Gateway:{config_name}] Invalid JSON: {e}")
|
logger.error(f"[QQ Gateway:{config_name}] Invalid JSON: {err}")
|
||||||
return
|
return
|
||||||
|
|
||||||
op = payload.get("op")
|
op = payload.get("op")
|
||||||
@@ -78,9 +78,6 @@ def run_gateway(
|
|||||||
heartbeat_interval_ms = d.get("heartbeat_interval", 30000)
|
heartbeat_interval_ms = d.get("heartbeat_interval", 30000)
|
||||||
logger.info(f"[QQ Gateway:{config_name}] Hello received, heartbeat_interval={heartbeat_interval_ms}")
|
logger.info(f"[QQ Gateway:{config_name}] Hello received, heartbeat_interval={heartbeat_interval_ms}")
|
||||||
|
|
||||||
token = get_token_fn(app_id, app_secret)
|
|
||||||
gateway_url = get_gateway_url_fn(token)
|
|
||||||
|
|
||||||
# Identify
|
# Identify
|
||||||
identify = {
|
identify = {
|
||||||
"op": 2,
|
"op": 2,
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ class QQBot:
|
|||||||
return None
|
return None
|
||||||
data = resp.content[:65536] if len(resp.content) > 65536 else resp.content
|
data = resp.content[:65536] if len(resp.content) > 65536 else resp.content
|
||||||
with Image.open(io.BytesIO(data)) as img:
|
with Image.open(io.BytesIO(data)) as img:
|
||||||
return (img.width, img.height)
|
return img.width, img.height
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(f"QQ Bot 获取图片尺寸失败 ({url[:60]}...): {e}")
|
logger.debug(f"QQ Bot 获取图片尺寸失败 ({url[:60]}...): {e}")
|
||||||
return None
|
return None
|
||||||
@@ -318,8 +318,8 @@ class QQBot:
|
|||||||
try:
|
try:
|
||||||
token = get_access_token(self._app_id, self._app_secret)
|
token = get_access_token(self._app_id, self._app_secret)
|
||||||
for tgt, tgt_is_group in targets_to_send:
|
for tgt, tgt_is_group in targets_to_send:
|
||||||
|
send_fn = send_proactive_group_message if tgt_is_group else send_proactive_c2c_message
|
||||||
try:
|
try:
|
||||||
send_fn = send_proactive_group_message if tgt_is_group else send_proactive_c2c_message
|
|
||||||
send_fn(token, tgt, content, use_markdown=use_markdown)
|
send_fn(token, tgt, content, use_markdown=use_markdown)
|
||||||
success_count += 1
|
success_count += 1
|
||||||
logger.debug(f"QQ Bot: 消息已发送到 {'群' if tgt_is_group else '用户'} {tgt}")
|
logger.debug(f"QQ Bot: 消息已发送到 {'群' if tgt_is_group else '用户'} {tgt}")
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ class Rtorrent:
|
|||||||
url = self._host
|
url = self._host
|
||||||
if url.startswith("scgi://"):
|
if url.startswith("scgi://"):
|
||||||
# SCGI直连模式
|
# SCGI直连模式
|
||||||
parsed = urlparse(url)
|
|
||||||
logger.info(f"正在通过SCGI连接 rTorrent:{url}")
|
logger.info(f"正在通过SCGI连接 rTorrent:{url}")
|
||||||
proxy = xmlrpc.client.ServerProxy(url, transport=SCGITransport())
|
proxy = xmlrpc.client.ServerProxy(url, transport=SCGITransport())
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -395,7 +395,8 @@ class Ugreen:
|
|||||||
use_cookies=False,
|
use_cookies=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
def __infer_library_type(self, name: str, path: Optional[str]) -> str:
|
@staticmethod
|
||||||
|
def __infer_library_type(name: str, path: Optional[str]) -> str:
|
||||||
name = name or ""
|
name = name or ""
|
||||||
path = path or ""
|
path = path or ""
|
||||||
if "电视剧" in path or any(key in name for key in ["剧", "综艺", "动漫", "纪录片"]):
|
if "电视剧" in path or any(key in name for key in ["剧", "综艺", "动漫", "纪录片"]):
|
||||||
@@ -497,7 +498,7 @@ class Ugreen:
|
|||||||
if lib_id is not None and lib_path:
|
if lib_id is not None and lib_path:
|
||||||
paths[str(lib_id)] = str(lib_path)
|
paths[str(lib_id)] = str(lib_path)
|
||||||
|
|
||||||
if data.get("is_last_page") is True:
|
if data.get("is_last_page"):
|
||||||
break
|
break
|
||||||
page += 1
|
page += 1
|
||||||
|
|
||||||
@@ -585,7 +586,8 @@ class Ugreen:
|
|||||||
api.logout()
|
api.logout()
|
||||||
api.close()
|
api.close()
|
||||||
|
|
||||||
def __extract_video_info_list(self, bucket: Any) -> list[dict]:
|
@staticmethod
|
||||||
|
def __extract_video_info_list(bucket: Any) -> list[dict]:
|
||||||
if not isinstance(bucket, Mapping):
|
if not isinstance(bucket, Mapping):
|
||||||
return []
|
return []
|
||||||
video_arr = bucket.get("video_arr")
|
video_arr = bucket.get("video_arr")
|
||||||
@@ -764,7 +766,8 @@ class Ugreen:
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_webhook_message(self, body: Any) -> Optional[schemas.WebhookEventInfo]:
|
@staticmethod
|
||||||
|
def get_webhook_message(body: Any) -> Optional[schemas.WebhookEventInfo]:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_iteminfo(self, itemid: str) -> Optional[schemas.MediaServerItem]:
|
def get_iteminfo(self, itemid: str) -> Optional[schemas.MediaServerItem]:
|
||||||
@@ -818,7 +821,7 @@ class Ugreen:
|
|||||||
if sub_path and sub_path not in visited:
|
if sub_path and sub_path not in visited:
|
||||||
queue.append(str(sub_path))
|
queue.append(str(sub_path))
|
||||||
|
|
||||||
if data.get("is_last_page") is True:
|
if data.get("is_last_page"):
|
||||||
break
|
break
|
||||||
page += 1
|
page += 1
|
||||||
|
|
||||||
@@ -957,6 +960,7 @@ class Ugreen:
|
|||||||
|
|
||||||
return images
|
return images
|
||||||
|
|
||||||
def get_image_cookies(self, image_url: str):
|
@staticmethod
|
||||||
|
def get_image_cookies(image_url: str):
|
||||||
# 绿联图片流接口依赖加密鉴权头,当前图片代理仅支持Cookie注入。
|
# 绿联图片流接口依赖加密鉴权头,当前图片代理仅支持Cookie注入。
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user