summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ATRI/plugins/broadcast.py2
-rw-r--r--ATRI/plugins/code_runner/__init__.py28
-rw-r--r--ATRI/plugins/help/__init__.py7
3 files changed, 25 insertions, 12 deletions
diff --git a/ATRI/plugins/broadcast.py b/ATRI/plugins/broadcast.py
index b12c050..07315f2 100644
--- a/ATRI/plugins/broadcast.py
+++ b/ATRI/plugins/broadcast.py
@@ -55,7 +55,7 @@ class BroadCast(Service):
caster = BroadCast().on_command(
- "广播", "向bot所在的所有群发送信息,有防寄延迟", aliases={"/bc", "bc"}, permission=SUPERUSER
+ "广播", "向bot所在的所有群发送信息,有防寄延迟", aliases={"bc"}, permission=SUPERUSER
)
diff --git a/ATRI/plugins/code_runner/__init__.py b/ATRI/plugins/code_runner/__init__.py
index 334c09a..90d4942 100644
--- a/ATRI/plugins/code_runner/__init__.py
+++ b/ATRI/plugins/code_runner/__init__.py
@@ -1,5 +1,7 @@
from random import choice
+from nonebot.matcher import Matcher
+from nonebot.params import CommandArg, ArgPlainText
from nonebot.adapters.onebot.v11 import MessageEvent, Message, MessageSegment, unescape
from ATRI.utils.limit import FreqLimiter
@@ -14,22 +16,32 @@ code_runner = CodeRunner().on_command("/code", "在线运行一段代码,帮�
@code_runner.handle()
-async def _code_runner(event: MessageEvent):
+async def _code_runner(matcher: Matcher, event: MessageEvent, args: Message = CommandArg()):
user_id = event.get_user_id()
if not _flmt.check(user_id):
await code_runner.finish(_flmt_notice)
+
+ msg = args.extract_plain_text()
+ print(msg, args, type(msg), type(args))
+ if msg:
+ matcher.set_arg("opt", args)
+ else:
+ content = f"> {MessageSegment.at(user_id)}\n" + "请键入 /code help 以获取帮助~!"
+ await code_runner.finish(Message(content))
- msg = str(event.get_message())
- args = msg.split("\n")
- if not args[0]:
+@code_runner.got("opt")
+async def _(event: MessageEvent, opt: str = ArgPlainText("opt")):
+ user_id = event.get_user_id()
+ msg = opt.split("\n")
+
+
+ if msg[0] == "help":
content = f"> {MessageSegment.at(user_id)}\n" + "请键入 /code help 以获取帮助~!"
- elif args[0] == "help":
- content = f"> {MessageSegment.at(user_id)}\n" + CodeRunner().help()
- elif args[0] == "list":
+ elif msg[0] == "list":
content = f"> {MessageSegment.at(user_id)}\n" + CodeRunner().list_supp_lang()
else:
- content = MessageSegment.at(user_id) + await CodeRunner().runner(unescape(msg))
+ content = MessageSegment.at(user_id) + await CodeRunner().runner(unescape(opt))
_flmt.start_cd(user_id)
await code_runner.finish(Message(content))
diff --git a/ATRI/plugins/help/__init__.py b/ATRI/plugins/help/__init__.py
index a8465bc..c50d7f2 100644
--- a/ATRI/plugins/help/__init__.py
+++ b/ATRI/plugins/help/__init__.py
@@ -36,10 +36,11 @@ service_info = Helper().on_command("帮助", "获取服务详细帮助", aliases
@service_info.handle()
async def _ready_service_info(event: MessageEvent):
- msg = str(event.message).split(" ")
- service = msg[0]
+ msg = str(event.get_message()).split(" ")
+
+ service = msg[1]
try:
- cmd = msg[1]
+ cmd = msg[2]
except BaseException:
cmd = str()