summaryrefslogtreecommitdiff
path: root/ATRI/plugins/code-runner.py
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2021-03-07 15:24:17 +0800
committerKyomotoi <[email protected]>2021-03-07 15:24:17 +0800
commitda888ff020805a38a17e5f83705aeb42ffa992ba (patch)
tree28fa5cc06c3b77970ced9136f12ed2bd94436926 /ATRI/plugins/code-runner.py
parent51624483cb23e8922cbdf5f529e1dcb2342333a7 (diff)
downloadATRI-da888ff020805a38a17e5f83705aeb42ffa992ba.tar.gz
ATRI-da888ff020805a38a17e5f83705aeb42ffa992ba.tar.bz2
ATRI-da888ff020805a38a17e5f83705aeb42ffa992ba.zip
♻️⚡️ 重构 Service,优化部分代码
Diffstat (limited to 'ATRI/plugins/code-runner.py')
-rw-r--r--ATRI/plugins/code-runner.py29
1 files changed, 27 insertions, 2 deletions
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
+License: GPLv3
+Project: https://github.com/Kyomotoi/ATRI
+--------
+Last Modified: Sunday, 7th March 2021 3:13:28 pm
+Modified By: Kyomotoi ([email protected])
+--------
+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.")