2023-03-26 08:25:59 +00:00
|
|
|
# pyright: basic
|
|
|
|
|
|
|
|
|
|
|
|
from pagermaid.enums import Message
|
|
|
|
from pagermaid.listener import listener
|
|
|
|
|
|
|
|
|
2023-07-01 12:18:58 +00:00
|
|
|
@listener(
|
|
|
|
command="punyencode", description="编码至 Punycode", parameters="[待编码内容] (支持回复消息)"
|
|
|
|
)
|
2023-03-29 08:55:29 +00:00
|
|
|
async def punyencode(message: Message):
|
|
|
|
if not (text := message.obtain_message()):
|
|
|
|
return await message.edit("请输入参数")
|
|
|
|
try:
|
|
|
|
encoded = text.encode("idna").decode()
|
|
|
|
except Exception:
|
|
|
|
return await message.edit("呜呜呜 ~ 转换失败了,可能含有非法字符。")
|
|
|
|
await message.edit(f"`{encoded}`")
|
2023-03-26 08:25:59 +00:00
|
|
|
|
|
|
|
|
2023-07-01 12:18:58 +00:00
|
|
|
@listener(
|
|
|
|
command="punydecode", description="从 Punycode 解码", parameters="[待解码内容] (支持回复消息)"
|
|
|
|
)
|
2023-03-29 08:55:29 +00:00
|
|
|
async def punydecode(message: Message):
|
|
|
|
if not (text := message.obtain_message()):
|
|
|
|
return await message.edit("请输入参数")
|
|
|
|
try:
|
|
|
|
decoded = text.encode().decode("idna")
|
|
|
|
except Exception:
|
|
|
|
return await message.edit("呜呜呜 ~ 转换失败了,可能含有非法字符。")
|
|
|
|
await message.edit(f"`{decoded}`")
|