We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我用 mirai core 的 jar 包基于 java 开发,我应该怎么使用来解决格式转换问题呢
The text was updated successfully, but these errors were encountered:
在 build.gradle.kts 文件中添加依赖:
build.gradle.kts
dependencies { implementation("net.mamoe:mirai-silk-converter:0.0.5") }
然后在代码中导入相应的包:
import net.mamoe.mirai.silkconverter.SilkConverter
在实际业务中编写代码,例如我们需要从本地加载一个音频文件 file,并将其作为语音消息发送给某个好友 friend,具体实现代码样例如下:
file
friend
file?.toExternalResource()?.use { resource -> // 安全地使用资源 var convertedRes: ExternalResource? = null try { convertedRes = SilkConverter().convert(resource) // 调用 Silk 转换器进行资源转换 val audio = friend.uploadAudio(convertedRes) // 上传语音资源 friend.sendMessage(audio) // 给某个朋友发送语音消息 } catch (e: Exception) { logger.error(e) } finally { resource.close() convertedRes?.close() } }
Sorry, something went wrong.
No branches or pull requests
我用 mirai core 的 jar 包基于 java 开发,我应该怎么使用来解决格式转换问题呢
The text was updated successfully, but these errors were encountered: