jd_cmd 解析 JD 口令

This commit is contained in:
xtaodada 2022-01-04 17:03:15 +08:00
parent 1bdc58b4e2
commit bbdc3ee077
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736
2 changed files with 35 additions and 0 deletions

25
jd_cmd.py Normal file
View File

@ -0,0 +1,25 @@
""" PagerMaid module to handle jd command. """
from pagermaid.listener import listener
from pagermaid.utils import lang, alias_command, obtain_message, post
@listener(is_plugin=False, outgoing=True, command=alias_command("jd_cmd"),
description="解析 JD 口令",
parameters="<JD 口令>")
async def jd_cmd(context):
try:
text = await obtain_message(context)
except ValueError:
return await context.edit("[jd_cmd] " + lang("msg_ValueError"))
try:
data = (await post("https://api.jds.codes/jCommand", data={"code": text}, json_body=True)).json()
except:
return await context.edit("[jd_cmd] 网络错误!")
if data["code"] != 200:
return await context.edit("[jd_cmd] 未找到 JD 口令!")
try:
data = data["data"]
await context.edit(f"[jd_cmd] [【{data['title']}】 - {data['userName']}]({data['jumpUrl']})")
except KeyError:
return await context.edit("[jd_cmd] 数据错误!")

View File

@ -799,6 +799,16 @@
"supported": true, "supported": true,
"des-short": "获取假期剩余时间信息。", "des-short": "获取假期剩余时间信息。",
"des": "获取假期剩余时间信息。\n指令-moyu" "des": "获取假期剩余时间信息。\n指令-moyu"
},
{
"name": "jd_cmd",
"version": "1.00",
"section": "chat",
"maintainer": "xtaodada",
"size": "1.00 kb",
"supported": true,
"des-short": "解析 JD 口令。",
"des": "解析 JD 口令。\n指令-jd_cmd"
} }
] ]
} }