mirror of
https://github.com/TeamPGM/PagerMaid_Plugins_Pyro.git
synced 2024-11-22 03:19:18 +00:00
idna 国际化域名 (IDNA) 编码转换工具
Co-authored-by: xtaodada <xtao@xtaolink.cn>
This commit is contained in:
parent
226c10f9aa
commit
68a60776f0
5
idna/DES.md
Normal file
5
idna/DES.md
Normal file
@ -0,0 +1,5 @@
|
||||
国际化域名 (IDNA) 编码转换工具
|
||||
|
||||
指令:
|
||||
- `,punyencode <待编码内容>` (编码至 Punycode)
|
||||
- `,punydecode <待解码内容>` (从 Punycode 解码)
|
29
idna/main.py
Normal file
29
idna/main.py
Normal file
@ -0,0 +1,29 @@
|
||||
# pyright: basic
|
||||
|
||||
|
||||
from pagermaid.enums import Message
|
||||
from pagermaid.listener import listener
|
||||
|
||||
|
||||
@listener(command="punyencode", description="编码至 Punycode", parameters="[待编码内容]")
|
||||
async def punyencode(message: Message) -> None:
|
||||
if message.arguments:
|
||||
try:
|
||||
result = message.arguments.encode("idna").decode()
|
||||
except Exception:
|
||||
result = "呜呜呜 ~ 转换失败了,可能含有非法字符。"
|
||||
else:
|
||||
result = "请输入参数"
|
||||
await message.edit(f"`{result}`")
|
||||
|
||||
|
||||
@listener(command="punydecode", description="从 Punycode 解码", parameters="[待解码内容]")
|
||||
async def punydecode(message: Message) -> None:
|
||||
if message.arguments:
|
||||
try:
|
||||
result = message.arguments.encode().decode("idna")
|
||||
except Exception:
|
||||
result = "呜呜呜 ~ 转换失败了,可能含有非法字符。"
|
||||
else:
|
||||
result = "请输入参数"
|
||||
await message.edit(f"`{result}`")
|
Loading…
Reference in New Issue
Block a user