NumberSir / nonebot_plugin_arktools

基于 OneBot 适配器的 NoneBot2 明日方舟小工具箱插件
MIT License
69 stars 15 forks source link

RSS推送存在bug #46

Open Ra1n-qwq opened 1 year ago

Ra1n-qwq commented 1 year ago

”方舟最新公告“功能实现方式有误,使用了升序排序,不能输出最新公告。 建议对.src/tool_announce_push/__init__.py文件中25-54行进行如下修改:

@latest_news.handle()
async def _():
    await latest_news.send("获取最新公告中 ...")
    news_list=[]  
    try:
        news_list = await get_news()
    except:
        logger.error("获取最新公告出错")
    if news_list:  #最新公告未收录数据库中,值不为空。如果配置了自动检测,可能在执行该功能时返回为空。
        news = news_list[0]
    else:  #最新公告已收录数据库中,值为空。采用降序排序,输出单个最近日期公告。
        news = await RSSNewsModel.all().order_by("-time").first() 

    image = await html_to_pic(
        html=news.content
    )
    try:
        await latest_news.finish(
            Message(
                MessageSegment.image(image)
                + "舟舟发布了一条新公告"
                  f"\n发布时间: {news.time.__str__()[:10]}"
                  f"\n{news.link}"
            )
        )
    except ActionFailed as e:
        await latest_news.finish(
            "公告截图失败..."
            f"\n发布时间: {news.time.__str__()[:10]}"
            f"\n{news.link}"
        )
Longxuanyue commented 1 year ago

报错提示:AttributeError: type object 'RSSNewsModel' has no attribute 'content',init.py里的代码和你的一致

Ra1n-qwq commented 1 year ago

报错提示:AttributeError: type object 'RSSNewsModel' has no attribute 'content',init.py里的代码和你的一致

应该是你缩进有问题,最好用IDE编辑代码。

Longxuanyue commented 1 year ago

报错提示:AttributeError: type object 'RSSNewsModel' 没有属性 'content',init.py里的代码和你的一致

应该是你缩进有问题,最好用IDE编辑代码。

请问是指nonebot_plugin_arktools\src\tool_announce_push__init__.py文件的缩进吗? 还有想问一下大佬,您的插件能否正常提供公告?我做了一点小修改,它就只能在操作台界面返回“获取最新公告出错”,QQ返回“未找到最新公告” 做出的更改如下:在image = await html_to_pic前加了if news and news.content: # 添加空值检查,函数结尾处加了:else: await latest_news.finish("未找到最新公告")

Ra1n-qwq commented 1 year ago

报错提示:AttributeError: type object 'RSSNewsModel' 没有属性 'content',init.py里的代码和你的一致

应该是你缩进有问题,最好用IDE编辑代码。

请问是指nonebot_plugin_arktools\src\tool_announce_pushinit.py文件的缩进吗? 还有想问一下大佬,您的插件能否正常提供公告?我做了一点小修改,它就只能在操作台界面返回“获取最新公告出错”,QQ返回“未找到最新公告” 做出的更改如下:在image = await html_to_pic前加了if news and news.content: # 添加空值检查,函数结尾处加了:else: await latest_news.finish("未找到最新公告")

1、我不是插件作者,我只是提出了这么个bug。 2、我改过的代码,我能正常用。也别问我相关问题了,等作者维护。