mirror of
https://github.com/d0zingcat/MoviePilot-Plugins.git
synced 2026-05-13 23:16:47 +00:00
Merge pull request #658 from RamenRa/master
This commit is contained in:
@@ -892,12 +892,13 @@
|
||||
"name": "动态企微可信IP",
|
||||
"description": "修改企微应用可信IP,支持Srever酱等第三方通知。验证码以?结尾发送到企业微信应用",
|
||||
"labels": "消息通知",
|
||||
"version": "1.7.1",
|
||||
"version": "1.7.2",
|
||||
"icon": "Wecom_A.png",
|
||||
"author": "RamenRa",
|
||||
"level": 2,
|
||||
"v2": true,
|
||||
"history": {
|
||||
"v1.7.2": "||wan参数细分,修复使用||wan时立即检测一次实际不生效,修复v1第三方备用通知可能无效,调整验证码获取",
|
||||
"v1.7.1": "允许使用'||wan2'选项及无法使用'立即检测一次'",
|
||||
"v1.7.0": "使用第三方通知时可IP变动后通知,拟支持多网络出口检查。",
|
||||
"v1.6.0": "忽略因网络波动导致获取ip错误。自定义的类合并为helper.py。后续核心功能没问题将不再更新",
|
||||
|
||||
@@ -31,7 +31,7 @@ class DynamicWeChat(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "Wecom_A.png"
|
||||
# 插件版本
|
||||
plugin_version = "1.7.1"
|
||||
plugin_version = "1.7.2"
|
||||
# 插件作者
|
||||
plugin_author = "RamenRa"
|
||||
# 作者主页
|
||||
@@ -43,7 +43,7 @@ class DynamicWeChat(_PluginBase):
|
||||
# 可使用的用户级别
|
||||
auth_level = 2
|
||||
# 检测间隔时间,默认10分钟
|
||||
_refresh_cron = '*/20 * * * *'
|
||||
_refresh_cron = '*/10 * * * *'
|
||||
|
||||
# ------------------------------------------私有属性------------------------------------------
|
||||
_enabled = False # 开关
|
||||
@@ -149,8 +149,13 @@ class DynamicWeChat(_PluginBase):
|
||||
self._my_send = None
|
||||
if self._my_send and not self._my_send.other_channel: # 确保跟随通知配置,一定要配置了第三方才可以使用
|
||||
self._await_ip = False
|
||||
if "||wan2" in self._input_id_list: # 多wan口
|
||||
self.wan2 = IpLocationParser(self._settings_file_path)
|
||||
if "||wan" in self._input_id_list: # 多wan口
|
||||
last_char = self._input_id_list[-1] if self._input_id_list else None
|
||||
if isinstance(last_char, str) and last_char.isdigit():
|
||||
max_ips = int(last_char)
|
||||
else:
|
||||
max_ips = 3 # 默认为 3
|
||||
self.wan2 = IpLocationParser(self._settings_file_path, max_ips=max_ips)
|
||||
self._current_ip_address = self.wan2.read_ips("ips") # 从文件中读取
|
||||
else:
|
||||
self.wan2 = None
|
||||
@@ -311,7 +316,7 @@ class DynamicWeChat(_PluginBase):
|
||||
logger.error(f"本地扫码任务: 本地扫码失败: {e}")
|
||||
|
||||
@eventmanager.register(EventType.PluginAction)
|
||||
def write_wan2_ip(self):
|
||||
def write_wan2_ip(self, event: Event = None):
|
||||
if not self._enabled:
|
||||
logger.error("插件未开启")
|
||||
return
|
||||
@@ -710,7 +715,7 @@ class DynamicWeChat(_PluginBase):
|
||||
if self._cookie_valid:
|
||||
if self._my_send:
|
||||
self._my_send.reset_limit()
|
||||
PyCookieCloud.increase_cookie_lifetime(self._settings_file_path, 1200)
|
||||
PyCookieCloud.increase_cookie_lifetime(self._settings_file_path, 600)
|
||||
self._cookie_lifetime = PyCookieCloud.load_cookie_lifetime(self._settings_file_path)
|
||||
browser.close()
|
||||
except Exception as e:
|
||||
@@ -1106,7 +1111,7 @@ class DynamicWeChat(_PluginBase):
|
||||
# 判断二维码是否过期
|
||||
if current_time > self._future_timestamp:
|
||||
vaild_text = "二维码已过期或没有扫码任务"
|
||||
color = "#ff0000" if self._enabled else "#bbbbbb"
|
||||
color = "#9B50FF" if self._enabled else "#bbbbbb"
|
||||
self._qr_code_image = None
|
||||
else:
|
||||
# 二维码有效,格式化过期时间为 年-月-日 时:分:秒
|
||||
@@ -1122,7 +1127,7 @@ class DynamicWeChat(_PluginBase):
|
||||
"props": {
|
||||
"style": {
|
||||
"fontSize": "22px",
|
||||
"color": "#ff0000",
|
||||
"color": "#FFB90F",
|
||||
"textAlign": "center",
|
||||
"margin": "20px"
|
||||
}
|
||||
@@ -1306,9 +1311,11 @@ class DynamicWeChat(_PluginBase):
|
||||
if not self._enabled:
|
||||
return
|
||||
self.text = event.event_data.get("text")
|
||||
if self.text[:6].isdigit() and len(self.text) == 7:
|
||||
self._verification_code = self.text[:6]
|
||||
logger.info(f"收到验证码:{self._verification_code}")
|
||||
if len(self.text) == 7 and re.fullmatch(r".*\d{6}.*", self.text):
|
||||
match = re.search(r"\d{6}", self.text)
|
||||
if match:
|
||||
self._verification_code = match.group(0)
|
||||
logger.info(f"收到验证码:{self._verification_code}")
|
||||
|
||||
def get_service(self) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
|
||||
@@ -143,12 +143,12 @@ class MySender:
|
||||
返回非 WeChat 通道及其对应 token 的列表
|
||||
:return: [(channel, token), ...]
|
||||
"""
|
||||
return [(channel, token) for channel, token in zip(self.channels, self.tokens) if channel != "WeChat"]
|
||||
return [(channel, token) for channel, token in zip(self.channels, self.tokens) if channel.lower() != "wechat"]
|
||||
|
||||
@staticmethod
|
||||
def _detect_channel(token):
|
||||
"""根据 token 确定通知渠道"""
|
||||
if "WeChat" in token:
|
||||
if "WeChat" in token or "wechat" in token:
|
||||
return "WeChat"
|
||||
|
||||
letters_only = ''.join(re.findall(r'[A-Za-z]', token))
|
||||
@@ -214,7 +214,7 @@ class MySender:
|
||||
else:
|
||||
send_status = wechat.send_msg(title=title, text=content, userid=actual_userid)
|
||||
|
||||
if send_status is None:
|
||||
if not send_status:
|
||||
return "微信通知发送错误"
|
||||
return None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user