Sending a voice message from an OGG file using the InsanusMokrassar/TelegramBotAPI.

huangapple go评论55阅读模式
英文:

Sending a voice message from an OGG file using the InsanusMokrassar/TelegramBotAPI

问题

我正在使用InsanusMokrassar/TelegramBotAPI(又名@ktgbotapi)来制作一个向一群朋友发送随机消息的简单机器人。我想知道,我如何从我已经在我的包里有的.ogg文件开始发送语音消息。现在我正在尝试使用bot.sendVoice(),但它需要一个我不知道如何创建的VoiceFile

英文:

I am using the InsanusMokrassar/TelegramBotAPI (AKA @ktgbotapi) to make a simple bot that sends random messages to a group of friends. I was wondering, how can I send a voice message starting from an .ogg file I already have that sound inside my package. Now I am trying to use bot.sendVoice() but it asks for a VoiceFile that I don't know how to create.

答案1

得分: 1

你可以使用 sendVoice,并从 MPPFile(在JVM上通常是File)创建的 InputFile,使用 asMultipartFile 扩展。

英文:

you may use sendVoice with InputFile created from MPPFile (common File on JVM) with asMultipartFile extension

huangapple
  • 本文由 发表于 2023年5月7日 11:08:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76192032.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定