Merge pull request #73 from Pentacene/master

小型计算器1.0
This commit is contained in:
Pentacene 2020-11-19 00:21:49 +08:00 committed by GitHub
commit ee8e52fb39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

28
calculator.py Normal file
View File

@ -0,0 +1,28 @@
from pagermaid import log, bot
from pagermaid.listener import listener
from pagermaid.utils import attach_log, execute
@listener(is_plugin=False, outgoing=True, command="cal",
description="计算",
parameters="<加减乘除>")
async def cal(context):
command = context.arguments
if context.is_channel and not context.is_group:
await context.edit("`出错了呜呜呜 ~ 当前 PagerMaid-Modify 的配置禁止在频道中执行此命令。`")
return
if not command:
await context.edit("`出错了呜呜呜 ~ 无效的参数。`")
return
await context.edit(f"{command}" )
cmd = f'echo {command} | bc'
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

View File

@ -339,6 +339,16 @@
"supported": true,
"des-short": "vip 捐赠用户功能",
"des": "命令天气weather 。"
},
{
"name": "calculator",
"version": "1.0",
"section": "chat",
"maintainer": "Pentacene",
"size": "1.0 kb",
"supported": true,
"des-short": "小型计算器",
"des": "/cal 6+4。"
}
]
}