mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-08-02 17:59:52 +00:00
✨ 添加开发文档和 API 文档的初始结构;更新 .gitignore 以排除生成的文档目录
This commit is contained in:
50
docs/zh/dev/api/tools/marshoai_bangumi/index.md
Normal file
50
docs/zh/dev/api/tools/marshoai_bangumi/index.md
Normal file
@ -0,0 +1,50 @@
|
||||
---
|
||||
title: index
|
||||
collapsed: true
|
||||
---
|
||||
# **模块** `nonebot_plugin_marshoai.tools.marshoai_bangumi`
|
||||
|
||||
---
|
||||
### ***async func*** `fetch_calendar()`
|
||||
|
||||
|
||||
<details>
|
||||
<summary> <b>源代码</b> 或 <a href='https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/tools/marshoai_bangumi/__init__.py#L6' target='_blank'>在GitHub上查看</a></summary>
|
||||
|
||||
```python
|
||||
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)
|
||||
return response.json()
|
||||
```
|
||||
</details>
|
||||
|
||||
---
|
||||
### ***async func*** `get_bangumi_news()`
|
||||
|
||||
|
||||
<details>
|
||||
<summary> <b>源代码</b> 或 <a href='https://github.com/LiteyukiStudio/nonebot-plugin-marshoai/tree/main/nonebot_plugin_marshoai/tools/marshoai_bangumi/__init__.py#L17' target='_blank'>在GitHub上查看</a></summary>
|
||||
|
||||
```python
|
||||
async def get_bangumi_news():
|
||||
result = await fetch_calendar()
|
||||
info = ''
|
||||
try:
|
||||
for i in result:
|
||||
weekday = i['weekday']['cn']
|
||||
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 ''
|
||||
```
|
||||
</details>
|
||||
|
Reference in New Issue
Block a user