mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-25 10:02:23 +00:00
jd_cmd 解析 JD 口令
This commit is contained in:
parent
1bdc58b4e2
commit
bbdc3ee077
25
jd_cmd.py
Normal file
25
jd_cmd.py
Normal 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] 数据错误!")
|
10
list.json
10
list.json
@ -799,6 +799,16 @@
|
||||
"supported": true,
|
||||
"des-short": "获取假期剩余时间信息。",
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user