1
0
forked from bot/app

添加对lyfunction的支持

This commit is contained in:
2024-05-31 22:59:02 +08:00
parent c2b3018908
commit 074882f092
4 changed files with 19 additions and 9 deletions

View File

@ -216,7 +216,12 @@ async def _(result: Arparma, bot: T_Bot, event: T_MessageEvent, matcher: Matcher
arg = arg.replace("\\=", "EQUAL_SIGN")
if "=" in arg:
key, value = arg.split("=", 1)
_kwargs[key] = value.replace("EQUAL_SIGN", "=")
value = unescape(value.replace("EQUAL_SIGN", "="))
try:
value = eval(value)
except:
value = value
_kwargs[key] = value
else:
_args.append(arg.replace("EQUAL_SIGN", "="))
@ -226,6 +231,7 @@ async def _(result: Arparma, bot: T_Bot, event: T_MessageEvent, matcher: Matcher
await ly_func(*tuple(_args), **_kwargs)
@on_alconna(
command=Alconna(
"/api",
@ -269,6 +275,7 @@ async def _(result: Arparma, bot: T_Bot, event: T_MessageEvent, matcher: Matcher
print(f"API: {api_name}\n\nArgs: \n{args_show}\n\nResult: {result}")
await matcher.finish(f"API: {api_name}\n\nArgs: \n{args_show}\n\nResult: {result}")
# system hook
@Bot.on_calling_api # 图片模式检测
async def test_for_md_image(bot: T_Bot, api: str, data: dict):
@ -300,6 +307,7 @@ async def test_for_md_image(bot: T_Bot, api: str, data: dict):
return
raise MockApiException(result=result)
@driver.on_startup
async def on_startup():
temp_data = common_db.where_one(TempConfig(), default=TempConfig())
@ -309,10 +317,12 @@ async def on_startup():
temp_data.data["delta_time"] = delta_time
common_db.save(temp_data) # 更新数据
@driver.on_shutdown
async def on_shutdown():
pass
@driver.on_bot_connect
async def _(bot: T_Bot):
temp_data = common_db.where_one(TempConfig(), default=TempConfig())
@ -342,6 +352,7 @@ async def _(bot: T_Bot):
message="Liteyuki reloaded in %.2f s" % delta_time
)
# 每天4点更新
@scheduler.scheduled_job("cron", hour=4)
async def every_day_update():
@ -355,6 +366,7 @@ async def every_day_update():
else:
nonebot.logger.info(logs)
# 需要用户id的api
need_user_id = (
"send_private_msg",