Skip to content

应当如何发送图片? #864

Answered by StageGuard
AdorableParker asked this question in Q&A
Discussion options

You must be logged in to vote

参考:

eventChannel.subscribeAlways<GroupMessageEvent> {
    //① 将文件转为 ExternalResource,指定格式或不指定
    group.sendImage(File("jpg_image_path").toExternalResource("jpg"))
    //② 先上传图片,获得 Image
    group.uploadImage(File("png_image_path").toExternalResource("png")).also {
        // ② 和其他类型消息一起发送
        group.sendMessage(buildMessageChain {
            add(PlainText("plain"))
            add(it)
        })
        // ② 直接发送
        group.sendMessage(it)
    }
    //直接传入 File 和 图片格式
    group.sendImage(File("img_path"), "bmp")
    //直接传入 InputStream 和 图片格式
    group.sendImage(File("file").inputStream(), "gif")
}

Replies: 3 comments 15 replies

Comment options

You must be logged in to vote
6 replies
@AdorableParker
Comment options

@Karlatemp
Comment options

@AdorableParker
Comment options

@Him188
Comment options

@Him188
Comment options

Comment options

You must be logged in to vote
4 replies
@yujumpjump
Comment options

@AdorableParker
Comment options

@yujumpjump
Comment options

@AdorableParker
Comment options

Answer selected by AdorableParker
Comment options

You must be logged in to vote
5 replies
@StageGuard
Comment options

@CHACCA165
Comment options

@StageGuard
Comment options

@CHACCA165
Comment options

@CHACCA165
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants