mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-05-12 06:55:49 +08:00
✨ Plugins
新增force_prefix
和disable_force_prefix
, 可在网页控制台功能服务配置
修改prefix
(#76)
This commit is contained in:
parent
980fe9d677
commit
5f322393c8
@ -37,7 +37,9 @@ plugins_sample = {
|
|||||||
'black_list': [],
|
'black_list': [],
|
||||||
'white_list': [],
|
'white_list': [],
|
||||||
'prefix': [],
|
'prefix': [],
|
||||||
'allow_empty_prefix': True,
|
'force_prefix': [],
|
||||||
|
'disable_force_prefix': False,
|
||||||
|
'allow_empty_prefix': None,
|
||||||
'sv': {},
|
'sv': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,16 @@ class Plugins:
|
|||||||
return _plugin
|
return _plugin
|
||||||
|
|
||||||
def __hash__(self) -> int:
|
def __hash__(self) -> int:
|
||||||
return hash(f'{self.name}{self.pm}{self.area}')
|
return hash(f'{self.name}{self.priority}{self.pm}{self.area}')
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
if isinstance(other, Plugins):
|
||||||
|
return (self.name, self.pm, self.priority) == (
|
||||||
|
other.name,
|
||||||
|
other.pm,
|
||||||
|
other.priority,
|
||||||
|
)
|
||||||
|
return False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -83,6 +92,8 @@ class Plugins:
|
|||||||
white_list: List = [],
|
white_list: List = [],
|
||||||
sv: Dict = {},
|
sv: Dict = {},
|
||||||
prefix: Union[List[str], str] = [],
|
prefix: Union[List[str], str] = [],
|
||||||
|
force_prefix: List[str] = [],
|
||||||
|
disable_force_prefix: bool = False,
|
||||||
allow_empty_prefix: Optional[bool] = None,
|
allow_empty_prefix: Optional[bool] = None,
|
||||||
force: bool = False,
|
force: bool = False,
|
||||||
):
|
):
|
||||||
@ -107,6 +118,8 @@ class Plugins:
|
|||||||
self.sv = {}
|
self.sv = {}
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
self.allow_empty_prefix = allow_empty_prefix
|
self.allow_empty_prefix = allow_empty_prefix
|
||||||
|
self.force_prefix = force_prefix
|
||||||
|
self.disable_force_prefix = disable_force_prefix
|
||||||
self.is_initialized = True
|
self.is_initialized = True
|
||||||
|
|
||||||
def set(self, **kwargs):
|
def set(self, **kwargs):
|
||||||
@ -206,6 +219,16 @@ class SV:
|
|||||||
'allow_empty_prefix'
|
'allow_empty_prefix'
|
||||||
] = None
|
] = None
|
||||||
|
|
||||||
|
if 'disable_force_prefix' not in config_plugins[plugins_name]:
|
||||||
|
config_plugins[plugins_name][
|
||||||
|
'disable_force_prefix'
|
||||||
|
] = False
|
||||||
|
|
||||||
|
if plugins_name in SL.plugins:
|
||||||
|
config_plugins[plugins_name]['force_prefix'] = SL.plugins[
|
||||||
|
plugins_name
|
||||||
|
].force_prefix
|
||||||
|
|
||||||
plugins = Plugins(
|
plugins = Plugins(
|
||||||
**config_plugins[plugins_name],
|
**config_plugins[plugins_name],
|
||||||
force=True,
|
force=True,
|
||||||
@ -317,6 +340,10 @@ class SV:
|
|||||||
if self.plugins.allow_empty_prefix:
|
if self.plugins.allow_empty_prefix:
|
||||||
_pp.append("")
|
_pp.append("")
|
||||||
|
|
||||||
|
if not self.plugins.disable_force_prefix:
|
||||||
|
for _i in self.plugins.force_prefix:
|
||||||
|
_pp.append(_i)
|
||||||
|
|
||||||
for _k in keyword_list:
|
for _k in keyword_list:
|
||||||
if prefix and _pp:
|
if prefix and _pp:
|
||||||
for _p in _pp:
|
for _p in _pp:
|
||||||
|
@ -89,6 +89,8 @@ def _set_Plugins(request: Request, data: Dict, name: str):
|
|||||||
plguin = SL.plugins[name]
|
plguin = SL.plugins[name]
|
||||||
data['pm'] = int(data['pm'])
|
data['pm'] = int(data['pm'])
|
||||||
data['priority'] = int(data['priority'])
|
data['priority'] = int(data['priority'])
|
||||||
|
if 'prefix' in data:
|
||||||
|
data['prefix'] = data['prefix'].split(',')
|
||||||
|
|
||||||
data['black_list'] = data['black_list'].split(',')
|
data['black_list'] = data['black_list'].split(',')
|
||||||
data['white_list'] = data['white_list'].split(',')
|
data['white_list'] = data['white_list'].split(',')
|
||||||
|
@ -21,6 +21,9 @@ def get_sv_panel(
|
|||||||
area: Literal['GROUP', 'DIRECT', 'ALL'] = 'ALL',
|
area: Literal['GROUP', 'DIRECT', 'ALL'] = 'ALL',
|
||||||
black_list: List = [],
|
black_list: List = [],
|
||||||
white_list: List = [],
|
white_list: List = [],
|
||||||
|
prefix: List = [],
|
||||||
|
disable_force_prefix: bool = False,
|
||||||
|
allow_empty_prefix: bool = False,
|
||||||
):
|
):
|
||||||
api = f'{API}/{name}'
|
api = f'{API}/{name}'
|
||||||
|
|
||||||
@ -32,13 +35,92 @@ def get_sv_panel(
|
|||||||
if API == '/genshinuid/setPlugins':
|
if API == '/genshinuid/setPlugins':
|
||||||
area_options.append({'label': '按照服务设定', 'value': 'SV'})
|
area_options.append({'label': '按照服务设定', 'value': 'SV'})
|
||||||
|
|
||||||
card = {
|
extra = {
|
||||||
"type": "service",
|
'type': 'flex',
|
||||||
"body": {
|
'className': 'p-1',
|
||||||
'type': 'card',
|
'items': [
|
||||||
'header': {'title': '', 'subTitle': ''},
|
{
|
||||||
|
'type': 'container',
|
||||||
|
'body': [
|
||||||
|
get_input_tag('自定义插件前缀', 'prefix', prefix, []),
|
||||||
|
],
|
||||||
|
'size': 'xs',
|
||||||
|
'style': {
|
||||||
|
'position': 'static',
|
||||||
|
'display': 'block',
|
||||||
|
'flex': '1 1 auto',
|
||||||
|
'flexGrow': 1,
|
||||||
|
'flexBasis': 'auto',
|
||||||
|
},
|
||||||
|
'wrapperBody': False,
|
||||||
|
'isFixedHeight': False,
|
||||||
|
'isFixedWidth': False,
|
||||||
|
'id': 'u:bafbdfce89c3',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'container',
|
||||||
'body': [
|
'body': [
|
||||||
{
|
{
|
||||||
|
'type': 'switch',
|
||||||
|
'label': '是否禁用插件自带前缀',
|
||||||
|
'option': '开启/关闭功能',
|
||||||
|
'name': 'allow_empty_prefix',
|
||||||
|
'falseValue': False,
|
||||||
|
'trueValue': True,
|
||||||
|
'id': 'u:d739bc85f366',
|
||||||
|
'value': disable_force_prefix,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'size': 'xs',
|
||||||
|
'style': {
|
||||||
|
'position': 'static',
|
||||||
|
'display': 'block',
|
||||||
|
'flex': '1 1 auto',
|
||||||
|
'flexGrow': 1,
|
||||||
|
'flexBasis': 'auto',
|
||||||
|
},
|
||||||
|
'wrapperBody': False,
|
||||||
|
'isFixedHeight': False,
|
||||||
|
'isFixedWidth': False,
|
||||||
|
'id': 'u:80670a4807f5',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'container',
|
||||||
|
'body': [
|
||||||
|
{
|
||||||
|
'type': 'switch',
|
||||||
|
'label': '是否允许空前缀',
|
||||||
|
'option': '开启/关闭功能',
|
||||||
|
'name': 'allow_empty_prefix',
|
||||||
|
'falseValue': False,
|
||||||
|
'trueValue': True,
|
||||||
|
'id': 'u:d739bc85f359',
|
||||||
|
'value': allow_empty_prefix,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'size': 'xs',
|
||||||
|
'style': {
|
||||||
|
'position': 'static',
|
||||||
|
'display': 'block',
|
||||||
|
'flex': '1 1 auto',
|
||||||
|
'flexGrow': 1,
|
||||||
|
'flexBasis': 'auto',
|
||||||
|
},
|
||||||
|
'wrapperBody': False,
|
||||||
|
'isFixedHeight': False,
|
||||||
|
'isFixedWidth': False,
|
||||||
|
'id': 'u:80670a4807f2',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'style': {'position': 'static'},
|
||||||
|
'direction': 'row',
|
||||||
|
'justify': 'flex-start',
|
||||||
|
'alignItems': 'stretch',
|
||||||
|
'id': 'u:2a2b198f141b',
|
||||||
|
'label': '',
|
||||||
|
}
|
||||||
|
|
||||||
|
switch = {
|
||||||
'type': 'flex',
|
'type': 'flex',
|
||||||
'className': 'p-1',
|
'className': 'p-1',
|
||||||
'items': [
|
'items': [
|
||||||
@ -118,8 +200,9 @@ def get_sv_panel(
|
|||||||
'alignItems': 'stretch',
|
'alignItems': 'stretch',
|
||||||
'id': 'u:2a2b198f141b',
|
'id': 'u:2a2b198f141b',
|
||||||
'label': '',
|
'label': '',
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
ol = {
|
||||||
'type': 'flex',
|
'type': 'flex',
|
||||||
'className': 'p-1',
|
'className': 'p-1',
|
||||||
'items': [
|
'items': [
|
||||||
@ -221,8 +304,9 @@ def get_sv_panel(
|
|||||||
'alignItems': 'stretch',
|
'alignItems': 'stretch',
|
||||||
'id': 'u:2a2b198f141b',
|
'id': 'u:2a2b198f141b',
|
||||||
'label': '',
|
'label': '',
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
black = {
|
||||||
'type': 'flex',
|
'type': 'flex',
|
||||||
'className': 'p-1',
|
'className': 'p-1',
|
||||||
'items': [
|
'items': [
|
||||||
@ -230,9 +314,7 @@ def get_sv_panel(
|
|||||||
'type': 'container',
|
'type': 'container',
|
||||||
'size': 'xs',
|
'size': 'xs',
|
||||||
'body': [
|
'body': [
|
||||||
get_input_tag(
|
get_input_tag('黑名单', 'black_list', black_list, [])
|
||||||
'黑名单', 'black_list', black_list, []
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
'wrapperBody': False,
|
'wrapperBody': False,
|
||||||
'style': {'flex': '0 0 auto', 'display': 'block'},
|
'style': {'flex': '0 0 auto', 'display': 'block'},
|
||||||
@ -244,8 +326,9 @@ def get_sv_panel(
|
|||||||
'alignItems': 'stretch',
|
'alignItems': 'stretch',
|
||||||
'id': 'u:a7b2f1bbc0a8',
|
'id': 'u:a7b2f1bbc0a8',
|
||||||
'label': '',
|
'label': '',
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
white = {
|
||||||
'type': 'flex',
|
'type': 'flex',
|
||||||
'className': 'p-1',
|
'className': 'p-1',
|
||||||
'items': [
|
'items': [
|
||||||
@ -253,9 +336,7 @@ def get_sv_panel(
|
|||||||
'type': 'container',
|
'type': 'container',
|
||||||
'size': 'xs',
|
'size': 'xs',
|
||||||
'body': [
|
'body': [
|
||||||
get_input_tag(
|
get_input_tag('白名单', 'white_list', white_list, [])
|
||||||
'白名单', 'white_list', white_list, []
|
|
||||||
)
|
|
||||||
],
|
],
|
||||||
'wrapperBody': False,
|
'wrapperBody': False,
|
||||||
'style': {'flex': '0 0 auto', 'display': 'block'},
|
'style': {'flex': '0 0 auto', 'display': 'block'},
|
||||||
@ -267,8 +348,13 @@ def get_sv_panel(
|
|||||||
'alignItems': 'stretch',
|
'alignItems': 'stretch',
|
||||||
'id': 'u:a7b2f1bbc0a8',
|
'id': 'u:a7b2f1bbc0a8',
|
||||||
'label': '',
|
'label': '',
|
||||||
},
|
}
|
||||||
],
|
card = {
|
||||||
|
"type": "service",
|
||||||
|
"body": {
|
||||||
|
'type': 'card',
|
||||||
|
'header': {'title': '', 'subTitle': ''},
|
||||||
|
'body': [],
|
||||||
'actions': [
|
'actions': [
|
||||||
{
|
{
|
||||||
'type': 'button',
|
'type': 'button',
|
||||||
@ -301,6 +387,11 @@ def get_sv_panel(
|
|||||||
"id": "u:4c2981f6a055",
|
"id": "u:4c2981f6a055",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if API == '/genshinuid/setPlugins':
|
||||||
|
card['body']['body'].extend([switch, ol, extra, black, white])
|
||||||
|
else:
|
||||||
|
card['body']['body'].extend([switch, ol, black, white])
|
||||||
|
|
||||||
return card
|
return card
|
||||||
|
|
||||||
|
|
||||||
@ -329,6 +420,9 @@ def get_sv_page():
|
|||||||
plugins.area, # type:ignore
|
plugins.area, # type:ignore
|
||||||
plugins.black_list,
|
plugins.black_list,
|
||||||
plugins.white_list,
|
plugins.white_list,
|
||||||
|
plugins.prefix,
|
||||||
|
plugins.disable_force_prefix,
|
||||||
|
plugins.allow_empty_prefix,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
grids.append(get_divider())
|
grids.append(get_divider())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user