首页 新闻 会员 周边

请问如何使用 nonebot_plugin_gocqhttp 发送图片

0
悬赏园豆:10 [待解决问题]

我使用的是nonebot中的nonebot_plugin_gocqhttp插件

先看代码

import nonebot
from nonebot import on_command,logger
from nonebot.rule import to_me
from nonebot.adapters.cqhttp import Bot, Event, MessageSegment
from QQBot.test import askjson

sixty=on_command("风景",aliases={"封禁","奋进"},priority=2,block=True)
@sixty.handle()
async def _(bot:Bot,event:Event,state:dict):
    img_url=(await askjson.get_url())
    if img_url:
        await sixty.send(message=MessageSegment.image(img_url[img_url]))
    else:
        logger.info('获取时出现错误')

askjson.py内容

import httpx
from typing import Optional


async def get_url() -> Optional[str]:
    """
    :return: 风景图片
    """
    url="https://t7.baidu.com/it/u=2604797219,1573897854&fm=193&f=GIF"
    async with httpx.AsyncClient() as client:
        r = (await client.get(url=url)).json()
        return r

错误提示如下

正常运行的文字接收与发送情况如下

所以我猜测是程序接收到了消息 但是没有找到对应的发送模块 请问因该如何解决
还有就是想请教一下如何发送本地图片

木三136的主页 木三136 | 初学一级 | 园豆:159
提问于:2022-07-03 23:22
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册