fix 签到失败过多自动触发cf优选
This commit is contained in:
@ -72,6 +72,7 @@ class AutoSignIn(_PluginBase):
|
|||||||
_clean: bool = False
|
_clean: bool = False
|
||||||
_start_time: int = None
|
_start_time: int = None
|
||||||
_end_time: int = None
|
_end_time: int = None
|
||||||
|
_auto_cf: int = 0
|
||||||
|
|
||||||
def init_plugin(self, config: dict = None):
|
def init_plugin(self, config: dict = None):
|
||||||
self.sites = SitesHelper()
|
self.sites = SitesHelper()
|
||||||
@ -91,6 +92,7 @@ class AutoSignIn(_PluginBase):
|
|||||||
self._sign_sites = config.get("sign_sites") or []
|
self._sign_sites = config.get("sign_sites") or []
|
||||||
self._login_sites = config.get("login_sites") or []
|
self._login_sites = config.get("login_sites") or []
|
||||||
self._retry_keyword = config.get("retry_keyword")
|
self._retry_keyword = config.get("retry_keyword")
|
||||||
|
self._auto_cf = config.get("auto_cf")
|
||||||
self._clean = config.get("clean")
|
self._clean = config.get("clean")
|
||||||
|
|
||||||
# 过滤掉已删除的站点
|
# 过滤掉已删除的站点
|
||||||
@ -206,6 +208,7 @@ class AutoSignIn(_PluginBase):
|
|||||||
"sign_sites": self._sign_sites,
|
"sign_sites": self._sign_sites,
|
||||||
"login_sites": self._login_sites,
|
"login_sites": self._login_sites,
|
||||||
"retry_keyword": self._retry_keyword,
|
"retry_keyword": self._retry_keyword,
|
||||||
|
"auto_cf": self._auto_cf,
|
||||||
"clean": self._clean,
|
"clean": self._clean,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -333,7 +336,7 @@ class AutoSignIn(_PluginBase):
|
|||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
'md': 4
|
'md': 3
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
@ -350,7 +353,7 @@ class AutoSignIn(_PluginBase):
|
|||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
'md': 4
|
'md': 3
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
@ -366,7 +369,7 @@ class AutoSignIn(_PluginBase):
|
|||||||
'component': 'VCol',
|
'component': 'VCol',
|
||||||
'props': {
|
'props': {
|
||||||
'cols': 12,
|
'cols': 12,
|
||||||
'md': 4
|
'md': 3
|
||||||
},
|
},
|
||||||
'content': [
|
'content': [
|
||||||
{
|
{
|
||||||
@ -378,6 +381,23 @@ class AutoSignIn(_PluginBase):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'component': 'VCol',
|
||||||
|
'props': {
|
||||||
|
'cols': 12,
|
||||||
|
'md': 3
|
||||||
|
},
|
||||||
|
'content': [
|
||||||
|
{
|
||||||
|
'component': 'VTextField',
|
||||||
|
'props': {
|
||||||
|
'model': 'auto_cf',
|
||||||
|
'label': '自动优选',
|
||||||
|
'placeholder': '0为不开启,命中重试关键词达到数量自动进行Cloudflare IP优选'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -443,6 +463,25 @@ class AutoSignIn(_PluginBase):
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'component': 'VRow',
|
||||||
|
'content': [
|
||||||
|
{
|
||||||
|
'component': 'VCol',
|
||||||
|
'props': {
|
||||||
|
'cols': 12,
|
||||||
|
},
|
||||||
|
'content': [
|
||||||
|
{
|
||||||
|
'component': 'VAlert',
|
||||||
|
'props': {
|
||||||
|
'text': '自动Cloudflare IP优选,0=不开启,命中重试关键词数量大于该数量时自动执行Cloudflare IP优选。(需要开启且则正确配置Cloudflare IP优选插件和自定义Hosts插件)'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -450,6 +489,7 @@ class AutoSignIn(_PluginBase):
|
|||||||
"enabled": False,
|
"enabled": False,
|
||||||
"notify": True,
|
"notify": True,
|
||||||
"cron": "",
|
"cron": "",
|
||||||
|
"auto_cf": 0,
|
||||||
"onlyonce": False,
|
"onlyonce": False,
|
||||||
"clean": False,
|
"clean": False,
|
||||||
"queue_cnt": 5,
|
"queue_cnt": 5,
|
||||||
@ -724,6 +764,10 @@ class AutoSignIn(_PluginBase):
|
|||||||
"retry": retry_sites
|
"retry": retry_sites
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# 自动Cloudflare IP优选
|
||||||
|
if self._auto_cf and self._auto_cf > 0 and retry_msg and len(retry_msg) > self._auto_cf:
|
||||||
|
EventManager().send_event(EventType.CloudFlareSpeedTest, {})
|
||||||
|
|
||||||
# 发送通知
|
# 发送通知
|
||||||
if self._notify:
|
if self._notify:
|
||||||
# 签到详细信息 登录成功、签到成功、已签到、仿真签到成功、失败--命中重试
|
# 签到详细信息 登录成功、签到成功、已签到、仿真签到成功、失败--命中重试
|
||||||
|
@ -14,6 +14,7 @@ from python_hosts import Hosts, HostsEntry
|
|||||||
from requests import Response
|
from requests import Response
|
||||||
|
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
|
from app.core.event import eventmanager
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.plugins import _PluginBase
|
from app.plugins import _PluginBase
|
||||||
from app.schemas.types import EventType, NotificationType
|
from app.schemas.types import EventType, NotificationType
|
||||||
@ -154,7 +155,8 @@ class CloudflareSpeedTest(_PluginBase):
|
|||||||
# 执行优选命令,-dd不测速
|
# 执行优选命令,-dd不测速
|
||||||
if SystemUtils.is_windows():
|
if SystemUtils.is_windows():
|
||||||
cf_command = f'cd \"{self._cf_path}\" && CloudflareST {self._additional_args} -o \"{self._result_file}\"' + (
|
cf_command = f'cd \"{self._cf_path}\" && CloudflareST {self._additional_args} -o \"{self._result_file}\"' + (
|
||||||
f' -f \"{self._cf_ipv4}\"' if self._ipv4 else '') + (f' -f \"{self._cf_ipv6}\"' if self._ipv6 else '')
|
f' -f \"{self._cf_ipv4}\"' if self._ipv4 else '') + (
|
||||||
|
f' -f \"{self._cf_ipv6}\"' if self._ipv6 else '')
|
||||||
else:
|
else:
|
||||||
cf_command = f'cd {self._cf_path} && chmod a+x {self._binary_name} && ./{self._binary_name} {self._additional_args} -o {self._result_file}' + (
|
cf_command = f'cd {self._cf_path} && chmod a+x {self._binary_name} && ./{self._binary_name} {self._additional_args} -o {self._result_file}' + (
|
||||||
f' -f {self._cf_ipv4}' if self._ipv4 else '') + (f' -f {self._cf_ipv6}' if self._ipv6 else '')
|
f' -f {self._cf_ipv4}' if self._ipv4 else '') + (f' -f {self._cf_ipv6}' if self._ipv6 else '')
|
||||||
@ -313,7 +315,7 @@ class CloudflareSpeedTest(_PluginBase):
|
|||||||
# 重装后数据库有版本数据,但是本地没有则重装
|
# 重装后数据库有版本数据,但是本地没有则重装
|
||||||
if not install_flag and release_version == self._version and not Path(
|
if not install_flag and release_version == self._version and not Path(
|
||||||
f'{self._cf_path}/{self._binary_name}').exists() and not Path(
|
f'{self._cf_path}/{self._binary_name}').exists() and not Path(
|
||||||
f'{self._cf_path}/CloudflareST.exe').exists():
|
f'{self._cf_path}/CloudflareST.exe').exists():
|
||||||
logger.warn(f"未检测到CloudflareSpeedTest本地版本,重新安装")
|
logger.warn(f"未检测到CloudflareSpeedTest本地版本,重新安装")
|
||||||
install_flag = True
|
install_flag = True
|
||||||
|
|
||||||
@ -757,3 +759,10 @@ class CloudflareSpeedTest(_PluginBase):
|
|||||||
self._scheduler = None
|
self._scheduler = None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("退出插件失败:%s" % str(e))
|
logger.error("退出插件失败:%s" % str(e))
|
||||||
|
|
||||||
|
@eventmanager.register(EventType.CloudFlareSpeedTest)
|
||||||
|
def auto_cloudflare_speedtest(self, event):
|
||||||
|
"""
|
||||||
|
触发Cloudflare IP优选
|
||||||
|
"""
|
||||||
|
self.__cloudflareSpeedTest()
|
||||||
|
@ -46,6 +46,8 @@ class EventType(Enum):
|
|||||||
NameRecognizeResult = "name.recognize.result"
|
NameRecognizeResult = "name.recognize.result"
|
||||||
# 目录监控同步
|
# 目录监控同步
|
||||||
DirectorySync = "directory.sync"
|
DirectorySync = "directory.sync"
|
||||||
|
# Cloudflare IP优选
|
||||||
|
CloudFlareSpeedTest = "cloudflare.speedtest"
|
||||||
|
|
||||||
|
|
||||||
# 系统配置Key字典
|
# 系统配置Key字典
|
||||||
|
Reference in New Issue
Block a user