2022-05-29 04:00:08 +00:00
|
|
|
from pyrogram import Client
|
2024-09-28 14:35:08 +00:00
|
|
|
|
|
|
|
from pagermaid.enums import Message
|
2022-05-29 04:00:08 +00:00
|
|
|
from pagermaid.listener import listener
|
|
|
|
from base64 import b64decode, b64encode
|
|
|
|
|
|
|
|
|
2023-07-01 12:18:58 +00:00
|
|
|
@listener(command="b64e", description="将文本转为Base64", parameters="[text]")
|
2022-05-29 04:00:08 +00:00
|
|
|
async def b64e(_: Client, message: Message):
|
|
|
|
msg = message.arguments
|
|
|
|
if not msg:
|
|
|
|
return await message.edit("`出错了呜呜呜 ~ 无效的参数。`")
|
|
|
|
|
2022-06-14 07:54:55 +00:00
|
|
|
if result := b64encode(msg.encode("utf-8")).decode("utf-8"):
|
2022-05-29 04:00:08 +00:00
|
|
|
await message.edit(f"`{result}`")
|
|
|
|
|
|
|
|
|
2023-07-01 12:18:58 +00:00
|
|
|
@listener(command="b64d", description="将Base64转为文本", parameters="[text]")
|
2022-05-29 04:00:08 +00:00
|
|
|
async def b64d(_: Client, message: Message):
|
|
|
|
msg = message.arguments
|
|
|
|
if not msg:
|
|
|
|
return await message.edit("`出错了呜呜呜 ~ 无效的参数。`")
|
2023-07-01 12:18:58 +00:00
|
|
|
|
2022-05-29 04:00:08 +00:00
|
|
|
try:
|
|
|
|
result = b64decode(msg).decode("utf-8")
|
|
|
|
except:
|
|
|
|
return await message.edit("`出错了呜呜呜 ~ 无效的参数。`")
|
|
|
|
if result:
|
|
|
|
await message.edit(f"`{result}`")
|