Replies: 1 comment
-
图片可以使用 // Kotlin
val imageFile = File("...")
val image = bot.uploadImage(Resource.of(imageFile))
bot.friend(...)!!.send(image) // Java
final File imageFile = new File(...);
final Image<?> image = event.getBot().uploadImageBlocking(Resource.of(imageFile));
event.getSource().sendBlocking(image); 至于文件等其他形式,simbot标准api没有相关内容,这需要参考使用的组件。以mirai组件为例,如果要使用“群文件上传”相关功能,你需要使用原生的mirai对象来完成: // Kotlin
@Listener
suspend fun MiraiGroupMessageEvent.listen() {
// 得到mirai原始的 Group 对象:net.mamoe.mirai.contact.Group
// 在 5.0 之前(不包含5.0),获取方法名是 nativeContact. 详情参考 https://github.com/simple-robot/simbot-component-mirai/pull/8
val originalGroup = group.originalContact
// 直接操作 mirai api. 相关内容需要参考mirai api
originalGroup.files.uploadNewFile(...)
} // Java
@Listener
public void listener(MiraiGroupMessageEvent event) {
// 得到mirai原始的 Group 对象:net.mamoe.mirai.contact.Group
// 在 5.0 之前(不包含5.0),获取方法名是 getNativeContact()
final Group originalGroup = event.getGroup().getOriginalContact();
// 直接操作 mirai api. 相关内容需要参考mirai api
originalGroup.getFiles().uploadNewFile(...);
}
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
环境:
love.forte.simbot.boot
simboot-core-spring-boot-starter
${simbot.version}
Beta Was this translation helpful? Give feedback.
All reactions