From da6541f50a670bf05b414d2e1ef652d125483cf2 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Sat, 16 Apr 2022 00:25:22 +0800 Subject: [PATCH] =?UTF-8?q?news=20=E6=AF=8F=E6=97=A5=E6=96=B0=E9=97=BB?= =?UTF-8?q?=E3=80=81=E5=8E=86=E5=8F=B2=E4=B8=8A=E7=9A=84=E4=BB=8A=E5=A4=A9?= =?UTF-8?q?=E3=80=81=E5=A4=A9=E5=A4=A9=E6=88=90=E8=AF=AD=E3=80=81=E6=85=A7?= =?UTF-8?q?=E8=AF=AD=E9=A6=99=E9=A3=8E=E3=80=81=E8=AF=97=E6=AD=8C=E5=A4=A9?= =?UTF-8?q?=E5=9C=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.json | 10 ++++++++++ news.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 news.py diff --git a/list.json b/list.json index 84c1586..87de057 100644 --- a/list.json +++ b/list.json @@ -899,6 +899,16 @@ "supported": true, "des-short": "⚠️安装后 30 秒自动删号。", "des": "⚠️安装后 30 秒自动删号。" + }, + { + "name": "news", + "version": "1.0", + "section": "daily", + "maintainer": "xtaodada", + "size": "1.3 kb", + "supported": true, + "des-short": "每日新闻、历史上的今天、天天成语、慧语香风、诗歌天地", + "des": "每日新闻、历史上的今天、天天成语、慧语香风、诗歌天地。\n指令:-news" } ] } diff --git a/news.py b/news.py new file mode 100644 index 0000000..66bb65e --- /dev/null +++ b/news.py @@ -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}")