import{_ as i,c as a,ae as n,o as h}from"./chunks/framework.BzDBnRMZ.js";const g=JSON.parse('{"title":"index","description":"","frontmatter":{"title":"index","order":100,"collapsed":true},"headers":[],"relativePath":"dev/api/plugins/marshoai_bangumi/index.md","filePath":"zh/dev/api/plugins/marshoai_bangumi/index.md","lastUpdated":1734175019000}'),k={name:"dev/api/plugins/marshoai_bangumi/index.md"};function t(l,s,p,e,E,r){return h(),a("div",null,s[0]||(s[0]=[n(`

模块 nonebot_plugin_marshoai.plugins.marshoai_bangumi


@on_function_call(description='获取Bangumi日历信息')

async func get_bangumi_news() -> str

源代码在GitHub上查看
python
@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)
            return response.json()
    try:
        result = await fetch_calendar()
        info = ''
        current_weekday = DateTime.now().weekday()
        weekdays = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日']
        current_weekday_name = weekdays[current_weekday]
        info += f'今天{current_weekday_name}\\n'
        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 ''
`,5)]))}const y=i(k,[["render",t]]);export{g as __pageData,y as default};