-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,4 +167,5 @@ cython_debug/ | |
bot.py | ||
pdm.lock | ||
praises.json | ||
*.bak | ||
*.bak | ||
config/ |
29 changes: 29 additions & 0 deletions
29
nonebot_plugin_marshoai/tools/marshoai-bangumi/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import httpx | ||
import traceback | ||
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() | ||
|
||
async def get_bangumi_news(): | ||
result = await fetch_calendar() | ||
info = "" | ||
try: | ||
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 += "\n" | ||
return info | ||
except Exception as e: | ||
traceback.print_exc() | ||
return "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
{ | ||
"type": "function", | ||
"function": { | ||
"name": "marshoai-bangumi__get_bangumi_news", | ||
"description": "获取今天的新番(动漫)列表,在调用之前,你需要知道今天星期几。" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters