mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-05-12 06:55:49 +08:00
✨ 新增可配置的command_start
(KimigaiiWuyi/GenshinUID#492)
This commit is contained in:
parent
eba183ac7c
commit
574cec609a
@ -9,14 +9,15 @@ CONFIG_DEFAULT = {
|
|||||||
'PORT': '8765',
|
'PORT': '8765',
|
||||||
'masters': [],
|
'masters': [],
|
||||||
'superusers': [],
|
'superusers': [],
|
||||||
'sv': {},
|
|
||||||
'log': {
|
'log': {
|
||||||
'level': 'INFO',
|
'level': 'INFO',
|
||||||
# ...
|
# ...
|
||||||
},
|
},
|
||||||
|
'command_start': [],
|
||||||
|
'sv': {},
|
||||||
}
|
}
|
||||||
STR_CONFIG = Literal['HOST', 'PORT']
|
STR_CONFIG = Literal['HOST', 'PORT']
|
||||||
LIST_CONFIG = Literal['superusers', 'masters']
|
LIST_CONFIG = Literal['superusers', 'masters', 'command_start']
|
||||||
DICT_CONFIG = Literal['sv', 'log']
|
DICT_CONFIG = Literal['sv', 'log']
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ from gsuid_core.trigger import Trigger
|
|||||||
from gsuid_core.config import core_config
|
from gsuid_core.config import core_config
|
||||||
from gsuid_core.models import Event, Message, MessageReceive
|
from gsuid_core.models import Event, Message, MessageReceive
|
||||||
|
|
||||||
|
command_start = core_config.get_config('command_start')
|
||||||
config_masters = core_config.get_config('masters')
|
config_masters = core_config.get_config('masters')
|
||||||
config_superusers = core_config.get_config('superusers')
|
config_superusers = core_config.get_config('superusers')
|
||||||
|
|
||||||
@ -66,6 +67,15 @@ async def handle_event(ws: _Bot, msg: MessageReceive):
|
|||||||
user_pm = await get_user_pml(msg)
|
user_pm = await get_user_pml(msg)
|
||||||
event = await msg_process(msg)
|
event = await msg_process(msg)
|
||||||
logger.info('[收到事件]', event=event)
|
logger.info('[收到事件]', event=event)
|
||||||
|
|
||||||
|
if command_start and event.raw_text:
|
||||||
|
for start in command_start:
|
||||||
|
if event.raw_text.strip().startswith(start):
|
||||||
|
event.raw_text = event.raw_text.replace(start, '')
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
valid_event: Dict[Trigger, int] = {}
|
valid_event: Dict[Trigger, int] = {}
|
||||||
pending = [
|
pending = [
|
||||||
_check_command(
|
_check_command(
|
||||||
@ -79,10 +89,8 @@ async def handle_event(ws: _Bot, msg: MessageReceive):
|
|||||||
if (
|
if (
|
||||||
SL.lst[sv].enabled
|
SL.lst[sv].enabled
|
||||||
and user_pm <= SL.lst[sv].pm
|
and user_pm <= SL.lst[sv].pm
|
||||||
and (
|
and msg.group_id not in SL.lst[sv].black_list
|
||||||
msg.group_id not in SL.lst[sv].black_list
|
and msg.user_id not in SL.lst[sv].black_list
|
||||||
or msg.user_id not in SL.lst[sv].black_list
|
|
||||||
)
|
|
||||||
and True
|
and True
|
||||||
if SL.lst[sv].area == 'ALL'
|
if SL.lst[sv].area == 'ALL'
|
||||||
or (msg.group_id and SL.lst[sv].area == 'GROUP')
|
or (msg.group_id and SL.lst[sv].area == 'GROUP')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user