From da888ff020805a38a17e5f83705aeb42ffa992ba Mon Sep 17 00:00:00 2001 From: Kyomotoi <1172294279@qq.com> Date: Sun, 7 Mar 2021 15:24:17 +0800 Subject: =?UTF-8?q?=E2=99=BB=EF=B8=8F=E2=9A=A1=EF=B8=8F=20=E9=87=8D?= =?UTF-8?q?=E6=9E=84=20Service=EF=BC=8C=E4=BC=98=E5=8C=96=E9=83=A8?= =?UTF-8?q?=E5=88=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ATRI/plugins/code-runner.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'ATRI/plugins/code-runner.py') diff --git a/ATRI/plugins/code-runner.py b/ATRI/plugins/code-runner.py index f31f049..0761384 100644 --- a/ATRI/plugins/code-runner.py +++ b/ATRI/plugins/code-runner.py @@ -1,3 +1,19 @@ +#!/usr/bin/env python3 +# -*- coding:utf-8 -*- +''' +File: code-runner.py +Created Date: 2021-02-20 07:43:44 +Author: Kyomotoi +Email: Kyomotoiowo@gmail.com +License: GPLv3 +Project: https://github.com/Kyomotoi/ATRI +-------- +Last Modified: Sunday, 7th March 2021 3:13:28 pm +Modified By: Kyomotoi (kyomotoiowo@gmail.com) +-------- +Copyright (c) 2021 Kyomotoi +''' + """ Idea from: https://github.com/cczu-osa/aki """ @@ -45,6 +61,15 @@ code_runner = on_command("/code", rule=is_in_banlist() & is_in_dormant()) @code_runner.handle() async def _code_runner(bot: Bot, event: MessageEvent) -> None: msg = str(event.message).split("\n") + + if msg[0] == "list": + msg0 = "咱现在支持的语言如下:\n" + msg0 += ", ".join(map(str, SUPPORTED_LANGUAGES.keys())) + + await code_runner.finish(msg0) + elif not msg[0]: + await code_runner.finish("请键入/help以获取更多支持...") + laug = msg[0].replace("\r", "") if laug not in SUPPORTED_LANGUAGES: await code_runner.finish("该语言暂不支持...") @@ -77,11 +102,11 @@ async def _code_runner(bot: Bot, event: MessageEvent) -> None: out, remained_out = out[:60 * 10], out[60 * 10:] if remained_lines or remained_out: - out += f"\n(输出过多,已忽略剩余内容)" + out += f"\n(太多了太多了...)" if out: await bot.send(event, f"{k}:\n\n{out}") sent = True if not sent: - await code_runner.finish("运行完成,没有任何输出") + await code_runner.finish("Running success! Nothing print.") -- cgit v1.2.3