2022-01-04 09:03:15 +00:00
|
|
|
""" PagerMaid module to handle jd command. """
|
|
|
|
|
2022-01-18 08:47:20 +00:00
|
|
|
from pagermaid import version
|
2022-01-04 09:03:15 +00:00
|
|
|
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"]
|
2022-01-04 09:07:38 +00:00
|
|
|
await context.edit(f"【jd_cmd】 [【{data['title']}】 - {data['userName']}]({data['jumpUrl']})")
|
2022-01-04 09:03:15 +00:00
|
|
|
except KeyError:
|
|
|
|
return await context.edit("[jd_cmd] 数据错误!")
|