mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-12-16 13:40:53 +08:00
绑定支持私聊&fix bug
This commit is contained in:
parent
257bac7edc
commit
0efe65ce7a
@ -87,7 +87,11 @@ async def my_characters(bot,ev):
|
|||||||
uid = ''
|
uid = ''
|
||||||
if len(msg[0]) == 9 and msg[0].isdigit():
|
if len(msg[0]) == 9 and msg[0].isdigit():
|
||||||
uid = msg[0]
|
uid = msg[0]
|
||||||
chara = msg[1]
|
if len(msg) >= 2:
|
||||||
|
chara = msg[1]
|
||||||
|
else:
|
||||||
|
await bot.send(ev,'要把想查询的角色名告诉我哦!',at_sender=True)
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
chara = msg[0]
|
chara = msg[0]
|
||||||
chara_name = get_id_by_alias(chara)
|
chara_name = get_id_by_alias(chara)
|
||||||
|
@ -1,9 +1,37 @@
|
|||||||
from hoshino import MessageSegment, Service
|
from hoshino import MessageSegment, Service, trigger, priv, CanceledException
|
||||||
from hoshino.typing import CQEvent, Message
|
from hoshino.typing import CQEvent, Message
|
||||||
from ..util import update_last_query_to_qq, bind_cookie
|
from ..util import update_last_query_to_qq, bind_cookie
|
||||||
|
from nonebot import message_preprocessor
|
||||||
|
|
||||||
sv = Service('原神绑定',visible=False,enable_on_default=True)
|
sv = Service('原神绑定',visible=False,enable_on_default=True)
|
||||||
|
|
||||||
|
private_prefix = []
|
||||||
|
|
||||||
|
# support private message
|
||||||
|
@message_preprocessor
|
||||||
|
async def private_handler(bot, ev, _):
|
||||||
|
if ev.detail_type != 'private':
|
||||||
|
return
|
||||||
|
for t in trigger.chain:
|
||||||
|
for service in t.find_handler(ev):
|
||||||
|
sv = service.sv
|
||||||
|
if sv in private_prefix:
|
||||||
|
if priv.get_user_priv(ev) >= priv.NORMAL:
|
||||||
|
try:
|
||||||
|
await service.func(bot, ev)
|
||||||
|
except CanceledException:
|
||||||
|
raise
|
||||||
|
sv.logger.info(
|
||||||
|
f'Private Message {ev.message_id} triggered {service.func.__name__}.'
|
||||||
|
)
|
||||||
|
|
||||||
|
def support_private(sv):
|
||||||
|
def wrap(func):
|
||||||
|
private_prefix.append(sv)
|
||||||
|
return func
|
||||||
|
return wrap
|
||||||
|
|
||||||
|
@support_private(sv)
|
||||||
@sv.on_prefix(('原神绑定','ysb'))
|
@sv.on_prefix(('原神绑定','ysb'))
|
||||||
async def bind(bot,ev):
|
async def bind(bot,ev):
|
||||||
msg = ev.message.extract_plain_text().strip().split('#')
|
msg = ev.message.extract_plain_text().strip().split('#')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user