Skip to content

Comwechat适配器wx.emoji type的file id获取流程是否缺失? #60

@RoyZ-iwnl

Description

@RoyZ-iwnl

在使用微博推送插件和Comwechat适配器时我注意到,GIF不能正常动起来,根据Comwechat Client文档显示,gif应使用wx.emoji type,Comwechat适配器相关代码如下

async def build_message_send(api: BotInstanceAPIProtocol, chain: Chain):
    async def handle_item(item: CHAIN_ITEM):
        # Face
        if isinstance(item, Face):
            return {'type': 'wx.emoji', 'data': {'file_id': item.face_id}}

    return await build_ob12(api, chain, handle_item)

但是在OnebotV12的代码中有着正确的文件上传代码,但是它仅仅是处理图片append_image

# 1. 读取文件数据
if isinstance(img_data, bytes):
    data = {'type': 'data', 'data': base64.b64encode(img_data).decode()}

# 2. 上传文件
res = await api.post('/', {
    'action': 'upload_file',
    'params': {
        'name': f'{random_code(20)}.{extension}',
        **data,
    },
})

# 3. 获取真正的file_id
if res:
    return {'type': 'image', 'data': {'file_id': res.json['data']['file_id']}}

我的问题是:是否face这里也应该有一个文件上传获取File ID的过程?微博插件那里因为把GIF当作图片上传,所以导致动图发出来不会动,也应该对gif做相应单独处理以face发送而不是image吧?

本人学术不精,如有错误敬请谅解。

RoyZ-iwnl/Amiya-Bot-core@b8bb007
RoyZ-iwnl@acf3581

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions