mirror of
https://github.com/TeamPGM/PagerMaid_Plugins_Pyro.git
synced 2024-11-16 07:05:24 +00:00
idna morse 支持回复消息
This commit is contained in:
parent
d2399e10a0
commit
693b45ea60
@ -1,5 +1,5 @@
|
|||||||
国际化域名 (IDNA) 编码转换工具
|
国际化域名 (IDNA) 编码转换工具
|
||||||
|
|
||||||
指令:
|
指令:
|
||||||
- `,punyencode <待编码内容>` (编码至 Punycode)
|
- `,punyencode <待编码内容> (支持回复消息)` (编码至 Punycode)
|
||||||
- `,punydecode <待解码内容>` (从 Punycode 解码)
|
- `,punydecode <待解码内容> (支持回复消息)` (从 Punycode 解码)
|
||||||
|
30
idna/main.py
30
idna/main.py
@ -5,25 +5,23 @@ from pagermaid.enums import Message
|
|||||||
from pagermaid.listener import listener
|
from pagermaid.listener import listener
|
||||||
|
|
||||||
|
|
||||||
@listener(command="punyencode", description="编码至 Punycode", parameters="[待编码内容]")
|
@listener(command="punyencode", description="编码至 Punycode", parameters="[待编码内容] (支持回复消息)")
|
||||||
async def punyencode(message: Message) -> None:
|
async def punyencode(message: Message):
|
||||||
if message.arguments:
|
if not (text := message.obtain_message()):
|
||||||
|
return await message.edit("请输入参数")
|
||||||
try:
|
try:
|
||||||
result = message.arguments.encode("idna").decode()
|
encoded = text.encode("idna").decode()
|
||||||
except Exception:
|
except Exception:
|
||||||
result = "呜呜呜 ~ 转换失败了,可能含有非法字符。"
|
return await message.edit("呜呜呜 ~ 转换失败了,可能含有非法字符。")
|
||||||
else:
|
await message.edit(f"`{encoded}`")
|
||||||
result = "请输入参数"
|
|
||||||
await message.edit(f"`{result}`")
|
|
||||||
|
|
||||||
|
|
||||||
@listener(command="punydecode", description="从 Punycode 解码", parameters="[待解码内容]")
|
@listener(command="punydecode", description="从 Punycode 解码", parameters="[待解码内容] (支持回复消息)")
|
||||||
async def punydecode(message: Message) -> None:
|
async def punydecode(message: Message):
|
||||||
if message.arguments:
|
if not (text := message.obtain_message()):
|
||||||
|
return await message.edit("请输入参数")
|
||||||
try:
|
try:
|
||||||
result = message.arguments.encode().decode("idna")
|
decoded = text.encode().decode("idna")
|
||||||
except Exception:
|
except Exception:
|
||||||
result = "呜呜呜 ~ 转换失败了,可能含有非法字符。"
|
return await message.edit("呜呜呜 ~ 转换失败了,可能含有非法字符。")
|
||||||
else:
|
await message.edit(f"`{decoded}`")
|
||||||
result = "请输入参数"
|
|
||||||
await message.edit(f"`{result}`")
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
摩斯密码转换 (支持非英文)
|
摩斯密码转换 (支持非英文)
|
||||||
|
|
||||||
指令:
|
指令:
|
||||||
- `,enmorse <待转换文本>` (转换指定文本到摩斯密码)
|
- `,enmorse <待转换文本> (支持回复消息)` (转换指定文本到摩斯密码)
|
||||||
- `,demorse <摩斯密码>` (转换摩斯密码到明文)
|
- `,demorse <摩斯密码> (支持回复消息)` (转换摩斯密码到明文)
|
||||||
|
@ -91,25 +91,23 @@ def decode(morse: str) -> str:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@listener(command="enmorse", description="转换指定文本到摩斯密码", parameters="[待转换文本]")
|
@listener(command="enmorse", description="转换指定文本到摩斯密码", parameters="[待转换文本] (支持回复消息)")
|
||||||
async def enmorse(message: Message):
|
async def enmorse(message: Message):
|
||||||
if message.arguments:
|
if not (text := message.obtain_message()):
|
||||||
|
return await message.edit("请输入参数")
|
||||||
try:
|
try:
|
||||||
result = encode(message.arguments)
|
morse = encode(text)
|
||||||
except Exception:
|
except Exception:
|
||||||
result = "呜呜呜 ~ 转换失败了,可能含有非法字符。"
|
return await message.edit("呜呜呜 ~ 转换失败了,可能含有非法字符。")
|
||||||
else:
|
await message.edit(f"`{morse}`")
|
||||||
result = "请输入参数"
|
|
||||||
await message.edit(f"`{result}`")
|
|
||||||
|
|
||||||
|
|
||||||
@listener(command="demorse", description="转换摩斯密码到明文", parameters="[摩斯密码]")
|
@listener(command="demorse", description="转换摩斯密码到明文", parameters="[摩斯密码] (支持回复消息)")
|
||||||
async def demorse(message: Message):
|
async def demorse(message: Message):
|
||||||
if message.arguments:
|
if not (morse := message.obtain_message()):
|
||||||
|
return await message.edit("请输入参数")
|
||||||
try:
|
try:
|
||||||
result = decode(message.arguments)
|
text = decode(morse)
|
||||||
except Exception:
|
except Exception:
|
||||||
result = "呜呜呜 ~ 转换失败了,可能含有非法字符。"
|
return await message.edit("呜呜呜 ~ 转换失败了,可能含有非法字符。")
|
||||||
else:
|
await message.edit(f"`{text}`")
|
||||||
result = "请输入参数"
|
|
||||||
await message.edit(f"`{result}`")
|
|
||||||
|
Loading…
Reference in New Issue
Block a user