Solved 如何发送本地图片?
-
新人,仿照非官方帮助文档的图片部分写法,文字发送成功了,图片没有发送,但是日志上面显示发送了。问题和这类似,按照大佬的解答没能解决,希望得到帮助。
代码:this.globalEventChannel().subscribeAlways<GroupMessageEvent> { event -> if (message.contentToString() == "#tx") { var contact = event.group var ex = File("D:\\tx.jpg").toExternalResource("jpg") var img = contact.uploadImage(ex) ex.close() contact.sendMessage(img) contact.sendMessage("tx") } }
日志:
2022-01-04 V/Bot.xxxx: [开发测试(xxxx)] yuhanzero(xxxx) -> #tx 2022-01-04 V/Bot.xxxx: Event: BeforeImageUploadEvent(target=Group(xxxx), source=net.mamoe.mirai.internal.utils.ExternalResourceImplByFile@165ad5e7) 2022-01-04 V/Bot.xxxx: Event: Succeed(target=Group(xxxx), source=net.mamoe.mirai.internal.utils.ExternalResourceImplByFile@165ad5e7, image=[mirai:image:{DC3BA8C8-0E76-6F68-349F-919A0E78147B}.jpg]) 2022-01-04 V/Bot.xxxx: Event: GroupMessagePreSendEvent(target=Group(xxxx), message=[mirai:image:{DC3BA8C8-0E76-6F68-349F-919A0E78147B}.jpg]) 2022-01-04 V/Bot.xxxx: Group(xxxx) <- [mirai:image:{DC3BA8C8-0E76-6F68-349F-919A0E78147B}.jpg] 2022-01-04 V/Bot.xxxx: Event: GroupMessagePostSendEvent(target=Group(xxxx), message=[mirai:image:{DC3BA8C8-0E76-6F68-349F-919A0E78147B}.jpg], exception=null, receipt=net.mamoe.mirai.message.MessageReceipt@1363a1e1) 2022-01-04 V/Bot.xxxx: Event: GroupMessagePreSendEvent(target=Group(xxxx), message=tx) 2022-01-04 V/Bot.xxxx: Group(xxxx) <- tx 2022-01-04 V/Bot.xxxx: Event: GroupMessagePostSendEvent(target=Group(xxxx), message=tx, exception=null, receipt=net.mamoe.mirai.message.MessageReceipt@46da27a8)
-
-
您的版本号?
-
val kotlinVersion = "1.5.30" kotlin("jvm") version kotlinVersion kotlin("plugin.serialization") version kotlinVersion id("net.mamoe.mirai-console") version "2.7.0"
-
use 2.9.1
-
@karlatemp
您好,我使用官方的插件创建版本2.9.1的mirai项目,但是似乎外部库中没有相应的模块:
请问有什么解决办法吗 -
使用
2.9.0-M1
-
-
@tsudzuki
感谢,解决了! -
@nambers
感谢! -