添加了一些插件 (#3)

* Add some plugins

* Update main.py

* Update main.py

Co-authored-by: omg-xtao <100690902+omg-xtao@users.noreply.github.com>
This commit is contained in:
zhxy-CN 2022-05-29 12:00:08 +08:00 committed by GitHub
parent 39403e318b
commit 8bcc781ce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 96 additions and 0 deletions

34
base64/main.py Normal file
View File

@ -0,0 +1,34 @@
from pyrogram import Client
from pagermaid.listener import listener
from pagermaid.utils import Message
from base64 import b64decode, b64encode
@listener(command="b64e",
description="将文本转为Base64",
parameters="<text>")
async def b64e(_: Client, message: Message):
msg = message.arguments
if not msg:
return await message.edit("`出错了呜呜呜 ~ 无效的参数。`")
result = b64encode(msg.encode("utf-8")).decode("utf-8")
if result:
await message.edit(f"`{result}`")
@listener(command="b64d",
description="将Base64转为文本",
parameters="<text>")
async def b64d(_: Client, message: Message):
msg = message.arguments
if not msg:
return await message.edit("`出错了呜呜呜 ~ 无效的参数。`")
try:
result = b64decode(msg).decode("utf-8")
except:
return await message.edit("`出错了呜呜呜 ~ 无效的参数。`")
if result:
await message.edit(f"`{result}`")

42
calculator/main.py Normal file
View File

@ -0,0 +1,42 @@
from pyrogram import Client
from pagermaid.listener import listener
from pagermaid.utils import Message, execute
@listener(command="cal",
description="计算\n示例:\n`-cal 1+1`加法\n`-cal 2-1`减法\n`-cal 1*2`乘法\n`-cal 4/2`除法\n`-cal 4^2`幂运算\n`-cal sqrt(4)`开方",
parameters="<基本运算>")
async def cal(_: Client, message: Message):
command = message.arguments
if not command:
await message.edit("`出错了呜呜呜 ~ 无效的参数。`")
return
await message.edit(f"{command}")
cmd = f'echo "scale=4;{command}" | bc'
result = await execute(cmd)
if result:
await message.edit(f"{command}=\n`{result}`")
else:
return
@listener(command="con",
description="换算\n示例:\n`-con 2 99`将99转换为2进制",
parameters="<进制(数字)> <数值>")
async def con(_: Client, message: Message):
command = message.arguments.split()
if not command:
await message.edit("`出错了呜呜呜 ~ 无效的参数。`")
return
obase = command[0].upper().strip()
num = command[1].upper().strip()
await message.edit(f"{num}")
cmd = f'echo "obase={obase};{num}" | bc'
result = await execute(cmd)
if result:
await message.edit(f"{num}=\n`{result}`\n{obase}进制")
else:
return

View File

@ -49,6 +49,26 @@
"supported": true,
"des-short": "每日英语",
"des": "支持群订阅"
},
{
"name": "calculator",
"version": "1.1",
"section": "chat",
"maintainer": "Pentacene,zhxycn",
"size": "1.48 kb",
"supported": true,
"des-short": "小型计算器",
"des": "支持基本运算(加减乘除乘方开方)及进制转换。\n命令,cal [表达式] ,con [进制] [数字]\n例如`,cal 1+2` `,con 16 10`"
},
{
"name": "base64",
"version": "1.00",
"section": "chat",
"maintainer": "zhxycn,xtaodada",
"size": "1.14 kb",
"supported": true,
"des-short": "Base64编码/解码。",
"des": "Base64编码/解码。\n命令,b64e ,b64d"
}
]
}