mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-01-26 18:12:47 +08:00
重命名MarshoAI编写的bangumi代码
This commit is contained in:
parent
e9a26e46f7
commit
2472a8826b
41
nonebot_plugin_marshoai/plugins/marshoai_bangumi/__init__.py
Executable file → Normal file
41
nonebot_plugin_marshoai/plugins/marshoai_bangumi/__init__.py
Executable file → Normal file
@ -2,12 +2,41 @@ import traceback
|
||||
|
||||
import httpx
|
||||
|
||||
from nonebot_plugin_marshoai.plugin import PluginMetadata
|
||||
from nonebot_plugin_marshoai.plugin import PluginMetadata, on_function_call
|
||||
|
||||
# 定义插件元数据
|
||||
__marsho_meta__ = PluginMetadata(
|
||||
name="Bangumi 番剧信息",
|
||||
description="Bangumi 番剧信息",
|
||||
usage="Bangumi 番剧信息",
|
||||
author="Liteyuki",
|
||||
homepage="",
|
||||
name="Bangumi日历",
|
||||
author="MarshoAI",
|
||||
description="这个插件可以帮助你获取Bangumi的日历信息~",
|
||||
)
|
||||
|
||||
|
||||
@on_function_call(description="获取Bangumi日历信息")
|
||||
async def get_bangumi_news() -> str:
|
||||
async def fetch_calendar():
|
||||
url = "https://api.bgm.tv/calendar"
|
||||
headers = {
|
||||
"User-Agent": "LiteyukiStudio/nonebot-plugin-marshoai (https://github.com/LiteyukiStudio/nonebot-plugin-marshoai)"
|
||||
}
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.get(url, headers=headers)
|
||||
# print(response.text)
|
||||
return response.json()
|
||||
|
||||
try:
|
||||
result = await fetch_calendar()
|
||||
info = ""
|
||||
for i in result:
|
||||
weekday = i["weekday"]["cn"]
|
||||
# print(weekday)
|
||||
info += f"{weekday}:"
|
||||
items = i["items"]
|
||||
for item in items:
|
||||
name = item["name_cn"]
|
||||
info += f"《{name}》"
|
||||
info += ""
|
||||
return info
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return ""
|
||||
|
@ -1,42 +0,0 @@
|
||||
import traceback
|
||||
|
||||
import httpx
|
||||
|
||||
from nonebot_plugin_marshoai.plugin import PluginMetadata, on_function_call
|
||||
|
||||
# 定义插件元数据
|
||||
__marsho_meta__ = PluginMetadata(
|
||||
name="Bangumi日历",
|
||||
author="MarshoAI",
|
||||
description="这个插件可以帮助你获取Bangumi的日历信息~",
|
||||
)
|
||||
|
||||
|
||||
@on_function_call(description="获取Bangumi日历信息")
|
||||
async def get_bangumi_news() -> str:
|
||||
async def fetch_calendar():
|
||||
url = "https://api.bgm.tv/calendar"
|
||||
headers = {
|
||||
"User-Agent": "LiteyukiStudio/nonebot-plugin-marshoai (https://github.com/LiteyukiStudio/nonebot-plugin-marshoai)"
|
||||
}
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.get(url, headers=headers)
|
||||
# print(response.text)
|
||||
return response.json()
|
||||
|
||||
try:
|
||||
result = await fetch_calendar()
|
||||
info = ""
|
||||
for i in result:
|
||||
weekday = i["weekday"]["cn"]
|
||||
# print(weekday)
|
||||
info += f"{weekday}:"
|
||||
items = i["items"]
|
||||
for item in items:
|
||||
name = item["name_cn"]
|
||||
info += f"《{name}》"
|
||||
info += ""
|
||||
return info
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return ""
|
Loading…
x
Reference in New Issue
Block a user