2020-11-18 16:17:18 +00:00
|
|
|
from pagermaid.listener import listener
|
2021-06-16 07:09:40 +00:00
|
|
|
from pagermaid.utils import attach_log, execute, alias_command
|
|
|
|
|
|
|
|
|
|
|
|
@listener(is_plugin=False, outgoing=True, command=alias_command("cal"),
|
2020-11-18 16:17:18 +00:00
|
|
|
description="计算",
|
|
|
|
parameters="<加减乘除>")
|
|
|
|
async def cal(context):
|
|
|
|
command = context.arguments
|
|
|
|
if context.is_channel and not context.is_group:
|
|
|
|
await context.edit("`出错了呜呜呜 ~ 当前 PagerMaid-Modify 的配置禁止在频道中执行此命令。`")
|
|
|
|
return
|
2021-06-16 07:09:40 +00:00
|
|
|
|
2020-11-18 16:17:18 +00:00
|
|
|
if not command:
|
|
|
|
await context.edit("`出错了呜呜呜 ~ 无效的参数。`")
|
|
|
|
return
|
|
|
|
|
2021-06-16 07:09:40 +00:00
|
|
|
await context.edit(f"{command}")
|
2020-11-25 18:37:11 +00:00
|
|
|
cmd = f'echo "scale=4;{command}" | bc'
|
2020-11-18 16:17:18 +00:00
|
|
|
result = await execute(cmd)
|
|
|
|
|
|
|
|
if result:
|
|
|
|
if len(result) > 4096:
|
|
|
|
await attach_log(result, context.chat_id, "output.log", context.id)
|
|
|
|
return
|
|
|
|
|
|
|
|
await context.edit(f"{command}=\n`{result}`")
|
|
|
|
else:
|
|
|
|
return
|