news 每日新闻、历史上的今天、天天成语、慧语香风、诗歌天地

This commit is contained in:
xtaodada 2022-04-16 00:25:22 +08:00
parent ac0c7c524c
commit da6541f50a
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 43 additions and 0 deletions

View File

@ -899,6 +899,16 @@
"supported": true, "supported": true,
"des-short": "⚠️安装后 30 秒自动删号。", "des-short": "⚠️安装后 30 秒自动删号。",
"des": "⚠️安装后 30 秒自动删号。" "des": "⚠️安装后 30 秒自动删号。"
},
{
"name": "news",
"version": "1.0",
"section": "daily",
"maintainer": "xtaodada",
"size": "1.3 kb",
"supported": true,
"des-short": "每日新闻、历史上的今天、天天成语、慧语香风、诗歌天地",
"des": "每日新闻、历史上的今天、天天成语、慧语香风、诗歌天地。\n指令-news"
} }
] ]
} }

33
news.py Normal file
View File

@ -0,0 +1,33 @@
from pagermaid import version, silent
from pagermaid.listener import listener
from pagermaid.utils import alias_command, client
@listener(is_plugin=True, outgoing=True, command=alias_command("news"),
description="每日新闻、历史上的今天、天天成语、慧语香风、诗歌天地")
async def news(context):
if not silent:
await context.edit("获取中 . . .")
try:
data = await client.get("https://news.topurl.cn/api")
data = data.json()["data"]
text = "📮 每日新闻 📮\n"
for i in range(12):
text += f"{i + 1}. [{data['newsList'][i]['title']}]({data['newsList'][i]['url']})\n"
text += "\n🎬 历史上的今天 🎬\n"
for i in data["historyList"]:
text += f"{i['event']}\n"
text += "\n🧩 天天成语 🧩\n"
text += f"{data['phrase']['phrase']} ----{data['phrase']['explain']}\n"
text += "\n🎻 慧语香风 🎻\n"
text += f"{data['sentence']['sentence']} ----{data['sentence']['author']}\n"
text += "\n🎑 诗歌天地 🎑\n"
text += f"{''.join(data['poem']['content'])} " \
f"----《{data['poem']['title']}{data['poem']['author']}"
await context.edit(text)
except Exception as e:
await context.edit(f"获取失败\n{e}")