Java telegram bot send audio

Содержание
  1. Java telegram bot send audio
  2. Class SendAudio
  3. Field Summary
  4. Fields inherited from class org.telegram.telegrambots.api.methods.PartialBotApiMethod
  5. Constructor Summary
  6. Method Summary
  7. Methods inherited from class java.lang.Object
  8. Field Detail
  9. PATH
  10. DURATION_FIELD
  11. CHATID_FIELD
  12. AUDIO_FIELD
  13. REPLYTOMESSAGEID_FIELD
  14. DISABLENOTIFICATION_FIELD
  15. REPLYMARKUP_FIELD
  16. PERFOMER_FIELD
  17. TITLE_FIELD
  18. CAPTION_FIELD
  19. PARSEMODE_FIELD
  20. Constructor Detail
  21. SendAudio
  22. Method Detail
  23. getDuration
  24. setDuration
  25. getChatId
  26. setChatId
  27. setChatId
  28. getAudio
  29. setAudio
  30. setNewAudio
  31. setNewAudio
  32. getReplyToMessageId
  33. setReplyToMessageId
  34. getReplyMarkup
  35. setReplyMarkup
  36. getPerformer
  37. setPerformer
  38. getTitle
  39. setTitle
  40. getDisableNotification
  41. enableNotification
  42. disableNotification
  43. isNewAudio
  44. getAudioName
  45. getNewAudioFile
  46. getNewAudioStream
  47. getCaption
  48. setCaption
  49. getParseMode
  50. setParseMode
  51. deserializeResponse
  52. validate
  53. Java telegram bot send audio
  54. Class SendAudio
  55. Field Summary
  56. Fields inherited from class org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod
  57. Constructor Summary
  58. Method Summary
  59. Methods inherited from class java.lang.Object
  60. Field Detail
  61. PATH
  62. DURATION_FIELD
  63. CHATID_FIELD
  64. AUDIO_FIELD
  65. REPLYTOMESSAGEID_FIELD
  66. DISABLENOTIFICATION_FIELD
  67. REPLYMARKUP_FIELD
  68. PERFOMER_FIELD
  69. TITLE_FIELD
  70. CAPTION_FIELD
  71. PARSEMODE_FIELD
  72. THUMB_FIELD
  73. Constructor Detail
  74. SendAudio
  75. Method Detail
  76. getDuration
  77. setDuration
  78. getChatId
  79. setChatId
  80. setChatId
  81. getAudio
  82. setAudio
  83. setAudio
  84. setAudio
  85. setAudio
  86. getReplyToMessageId
  87. setReplyToMessageId
  88. getReplyMarkup
  89. setReplyMarkup
  90. getPerformer
  91. setPerformer
  92. getTitle
  93. setTitle
  94. getDisableNotification
  95. enableNotification
  96. disableNotification
  97. getCaption
  98. setCaption
  99. getParseMode
  100. setParseMode
  101. getThumb
  102. setThumb
  103. deserializeResponse
  104. validate
  105. toString
  106. Audio and Voice Messages
  107. Audio
  108. Voice
  109. Java telegram bot send audio
  110. Class SendAudio
  111. Field Summary
  112. Fields inherited from class org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod
  113. Constructor Summary
  114. Method Summary
  115. Methods inherited from class java.lang.Object
  116. Field Detail
  117. PATH
  118. DURATION_FIELD
  119. CHATID_FIELD
  120. AUDIO_FIELD
  121. REPLYTOMESSAGEID_FIELD
  122. DISABLENOTIFICATION_FIELD
  123. REPLYMARKUP_FIELD
  124. PERFOMER_FIELD
  125. TITLE_FIELD
  126. CAPTION_FIELD
  127. PARSEMODE_FIELD
  128. THUMB_FIELD
  129. Constructor Detail
  130. SendAudio
  131. Method Detail
  132. getDuration
  133. setDuration
  134. getChatId
  135. setChatId
  136. setChatId
  137. getAudio
  138. setAudio
  139. setAudio
  140. setAudio
  141. setAudio
  142. getReplyToMessageId
  143. setReplyToMessageId
  144. getReplyMarkup
  145. setReplyMarkup
  146. getPerformer
  147. setPerformer
  148. getTitle
  149. setTitle
  150. getDisableNotification
  151. enableNotification
  152. disableNotification
  153. getCaption
  154. setCaption
  155. getParseMode
  156. setParseMode
  157. getThumb
  158. setThumb
  159. deserializeResponse
  160. validate
  161. toString
  162. Java telegram bot send audio
  163. Class SendAudio
  164. Field Summary
  165. Fields inherited from class org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod
  166. Constructor Summary
  167. Method Summary
  168. Methods inherited from class java.lang.Object
  169. Field Detail
  170. PATH
  171. DURATION_FIELD
  172. CHATID_FIELD
  173. AUDIO_FIELD
  174. REPLYTOMESSAGEID_FIELD
  175. DISABLENOTIFICATION_FIELD
  176. REPLYMARKUP_FIELD
  177. PERFOMER_FIELD
  178. TITLE_FIELD
  179. CAPTION_FIELD
  180. PARSEMODE_FIELD
  181. THUMB_FIELD
  182. Constructor Detail
  183. SendAudio
  184. Method Detail
  185. getDuration
  186. setDuration
  187. getChatId
  188. setChatId
  189. setChatId
  190. getAudio
  191. setAudio
  192. setAudio
  193. setAudio
  194. setAudio
  195. getReplyToMessageId
  196. setReplyToMessageId
  197. getReplyMarkup
  198. setReplyMarkup
  199. getPerformer
  200. setPerformer
  201. getTitle
  202. setTitle
  203. getDisableNotification
  204. enableNotification
  205. disableNotification
  206. getCaption
  207. setCaption
  208. getParseMode
  209. setParseMode
  210. getThumb
  211. setThumb
  212. deserializeResponse
  213. validate
  214. toString
Читайте также:  Python socket send error

Java telegram bot send audio

Class SendAudio

Field Summary

Fields inherited from class org.telegram.telegrambots.api.methods.PartialBotApiMethod

Constructor Summary

Method Summary

Methods inherited from class java.lang.Object

Field Detail

PATH

DURATION_FIELD

CHATID_FIELD

AUDIO_FIELD

REPLYTOMESSAGEID_FIELD

DISABLENOTIFICATION_FIELD

public static final String DISABLENOTIFICATION_FIELD

REPLYMARKUP_FIELD

PERFOMER_FIELD

TITLE_FIELD

CAPTION_FIELD

PARSEMODE_FIELD

Constructor Detail

SendAudio

Method Detail

getDuration

setDuration

public SendAudio setDuration(Integer duration)

getChatId

setChatId

setChatId

getAudio

setAudio

setNewAudio

setNewAudio

public SendAudio setNewAudio(String audioName, InputStream inputStream)

getReplyToMessageId

setReplyToMessageId

public SendAudio setReplyToMessageId(Integer replyToMessageId)

getReplyMarkup

setReplyMarkup

public SendAudio setReplyMarkup(ReplyKeyboard replyMarkup)

getPerformer

setPerformer

public SendAudio setPerformer(String performer)

getTitle

setTitle

getDisableNotification

enableNotification

disableNotification

isNewAudio

public boolean isNewAudio()

getAudioName

getNewAudioFile

getNewAudioStream

getCaption

setCaption

getParseMode

setParseMode

public SendAudio setParseMode(String parseMode)

deserializeResponse

public Message deserializeResponse(String answer) throws TelegramApiRequestException

validate

Источник

Java telegram bot send audio

Class SendAudio

Field Summary

Fields inherited from class org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod

Constructor Summary

Method Summary

Methods inherited from class java.lang.Object

Field Detail

PATH

DURATION_FIELD

CHATID_FIELD

AUDIO_FIELD

REPLYTOMESSAGEID_FIELD

DISABLENOTIFICATION_FIELD

public static final String DISABLENOTIFICATION_FIELD

REPLYMARKUP_FIELD

PERFOMER_FIELD

TITLE_FIELD

CAPTION_FIELD

PARSEMODE_FIELD

THUMB_FIELD

Constructor Detail

SendAudio

Method Detail

getDuration

setDuration

public SendAudio setDuration​(Integer duration)

getChatId

setChatId

setChatId

getAudio

setAudio

setAudio

setAudio

public SendAudio setAudio​(String audioName, InputStream inputStream)

setAudio

getReplyToMessageId

setReplyToMessageId

public SendAudio setReplyToMessageId​(Integer replyToMessageId)

getReplyMarkup

setReplyMarkup

public SendAudio setReplyMarkup​(ReplyKeyboard replyMarkup)

getPerformer

setPerformer

public SendAudio setPerformer​(String performer)

getTitle

setTitle

getDisableNotification

enableNotification

disableNotification

getCaption

setCaption

getParseMode

setParseMode

public SendAudio setParseMode​(String parseMode)

getThumb

setThumb

deserializeResponse

public Message deserializeResponse​(String answer) throws TelegramApiRequestException

validate

toString

Copyright © 2020. All rights reserved.

Источник

Audio and Voice Messages

These two types of messages are pretty similar. Audio is MP3-encoded file that can be played in music player. A voice file has OGG format and is not shown in music player.

Читайте также:  Скрипт вывода файла php

Audio

This is the code to send an MP3 soundtrack. You might be wondering why some parameters are commented out? That’s because this MP3 file has metadata on it and Telegram does a good job at reading it.

Message message = await botClient.SendAudioAsync( chatId: chatId, audio: InputFile.FromUri("https://github.com/TelegramBots/book/raw/master/src/docs/audio-guitar.mp3"), /* performer: "Joel Thomas Hunger", title: "Fun Guitar and Ukulele", duration: 91, // in seconds */ cancellationToken: cancellationToken); 

audio message

And a user can see the audio in Music Player:

music player

Method returns an audio message. Let’s take a look at the value of message.Audio property in JSON format:

Voice

A voice message is an OGG audio file. Let’s send it differently this time by uploading the file from disk alongside with an HTTP request.

To run this example, download the NFL Commentary voice file to your disk.

A value is passed for duration because Telegram can’t figure that out from a file’s metadata.

⚠️ Replace /path/to/voice-nfl_commentary.ogg with an actual file path.

await using Stream stream = System.IO.File.OpenRead("/path/to/voice-nfl_commentary.ogg"); Message message = await botClient.SendVoiceAsync( chatId: chatId, voice: InputFile.FromStream(stream), duration: 36, cancellationToken: cancellationToken); 

voice message

A voice message is returned from the method. Inspect the message.Voice property to learn more.

Источник

Java telegram bot send audio

Class SendAudio

Field Summary

Fields inherited from class org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod

Constructor Summary

Method Summary

Methods inherited from class java.lang.Object

Field Detail

PATH

DURATION_FIELD

CHATID_FIELD

AUDIO_FIELD

REPLYTOMESSAGEID_FIELD

DISABLENOTIFICATION_FIELD

public static final String DISABLENOTIFICATION_FIELD

REPLYMARKUP_FIELD

PERFOMER_FIELD

TITLE_FIELD

CAPTION_FIELD

PARSEMODE_FIELD

THUMB_FIELD

Constructor Detail

SendAudio

Method Detail

getDuration

setDuration

public SendAudio setDuration​(Integer duration)

getChatId

setChatId

setChatId

getAudio

setAudio

setAudio

setAudio

public SendAudio setAudio​(String audioName, InputStream inputStream)

setAudio

getReplyToMessageId

setReplyToMessageId

public SendAudio setReplyToMessageId​(Integer replyToMessageId)

getReplyMarkup

setReplyMarkup

public SendAudio setReplyMarkup​(ReplyKeyboard replyMarkup)

getPerformer

setPerformer

public SendAudio setPerformer​(String performer)

getTitle

setTitle

getDisableNotification

enableNotification

disableNotification

getCaption

setCaption

getParseMode

setParseMode

public SendAudio setParseMode​(String parseMode)

getThumb

setThumb

deserializeResponse

public Message deserializeResponse​(String answer) throws TelegramApiRequestException

validate

toString

Copyright © 2020. All rights reserved.

Источник

Java telegram bot send audio

Class SendAudio

Field Summary

Fields inherited from class org.telegram.telegrambots.meta.api.methods.PartialBotApiMethod

Constructor Summary

Method Summary

Methods inherited from class java.lang.Object

Field Detail

PATH

DURATION_FIELD

CHATID_FIELD

AUDIO_FIELD

REPLYTOMESSAGEID_FIELD

DISABLENOTIFICATION_FIELD

public static final String DISABLENOTIFICATION_FIELD

REPLYMARKUP_FIELD

PERFOMER_FIELD

TITLE_FIELD

CAPTION_FIELD

PARSEMODE_FIELD

THUMB_FIELD

Constructor Detail

SendAudio

Method Detail

getDuration

setDuration

public SendAudio setDuration​(Integer duration)

getChatId

setChatId

setChatId

getAudio

setAudio

setAudio

setAudio

public SendAudio setAudio​(String audioName, InputStream inputStream)

setAudio

getReplyToMessageId

setReplyToMessageId

public SendAudio setReplyToMessageId​(Integer replyToMessageId)

getReplyMarkup

setReplyMarkup

public SendAudio setReplyMarkup​(ReplyKeyboard replyMarkup)

getPerformer

setPerformer

public SendAudio setPerformer​(String performer)

getTitle

setTitle

getDisableNotification

enableNotification

disableNotification

getCaption

setCaption

getParseMode

setParseMode

public SendAudio setParseMode​(String parseMode)

getThumb

setThumb

deserializeResponse

public Message deserializeResponse​(String answer) throws TelegramApiRequestException

validate

toString

Copyright © 2020. All rights reserved.

Источник

Оцените статью