You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using SendMediaGroup, I'm getting TelegramApiException: Bad Request: can't parse InputMedia: media not found (whether I use a file_id string or an InputFile with attach://).
Here is an example bot:
importcats.instances.future._importcats.syntax.functor._importcom.bot4s.telegram.api.RequestHandlerimportcom.bot4s.telegram.api.declarative.Commandsimportcom.bot4s.telegram.clients.FutureSttpClientimportcom.bot4s.telegram.future.{Polling, TelegramBot}
importcom.bot4s.telegram.methods.{SendMediaGroup, SendPhoto}
importcom.bot4s.telegram.models.{InputFile, InputMedia, InputMediaPhoto}
importcom.softwaremill.sttp._importcom.softwaremill.sttp.okhttp.OkHttpFutureBackendimportslogging.{LogLevel, LoggerConfig, PrintLoggerFactory}
importscala.concurrent.duration.Durationimportscala.concurrent.{Await, Future}
objectTestextendsApp {
valbot=newTelegramBotwithPollingwithCommands[Future] {
LoggerConfig.factory =PrintLoggerFactory()
LoggerConfig.level =LogLevel.TRACEimplicitvalbackend:SttpBackend[Future, Nothing] =OkHttpFutureBackend()
overridevalclient:RequestHandler[Future] =newFutureSttpClient("709304299:AAGLZB_awq8eWa1J06V862yGKQF5seAs5Lk")
onCommand("single") { implicit msg =>
request(SendPhoto(msg.source, InputFile("AgACAgIAAxkBAAIBmF5NlVQVb6iPrSZWAonh4PnZm_GMAALtrjEbORhoSkLApyEUFBhoPA1xkS4AAwEAAwIAA3gAA5wVAAIYBA"))).void
}
onCommand("fileid") { implicit msg =>valarray:Array[InputMedia] =Array(
InputMediaPhoto("AgACAgIAAxkBAAIBmF5NlVQVb6iPrSZWAonh4PnZm_GMAALtrjEbORhoSkLApyEUFBhoPA1xkS4AAwEAAwIAA3gAA5wVAAIYBA", None),
InputMediaPhoto("AgACAgIAAxkBAAIBmF5NlVQVb6iPrSZWAonh4PnZm_GMAALtrjEbORhoSkLApyEUFBhoPA1xkS4AAwEAAwIAA3gAA5wVAAIYBA", None)
)
request(SendMediaGroup(msg.source, array)).void
}
onCommand("attach") { implicit msg =>valfile:Future[Array[Byte]] = sttp.get(uri"https://raw.githubusercontent.com/bot4s/telegram/master/logo.png").response(ResponseAsByteArray).send().map(_.unsafeBody)
valmedia:Future[Array[InputMedia]] = file.map(content =>Array(
InputMediaPhoto("attach://file_attach", Some(InputFile("name1", content))),
InputMediaPhoto("attach://file_attach_name", Some(InputFile("name2", content)))
)
)
media.flatMap(array => request(SendMediaGroup(msg.source, array))).void
}
onCommand("attach2") { implicit msg =>// this example (attach AND fileid) isnt correct according to the bot api, I tried it anyway:// or pass “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> namevalarray:Array[InputMedia] =Array(
InputMediaPhoto("attach://file_attach", Some(InputFile("AgACAgIAAxkBAAIBmF5NlVQVb6iPrSZWAonh4PnZm_GMAALtrjEbORhoSkLApyEUFBhoPA1xkS4AAwEAAwIAA3gAA5wVAAIYBA"))),
InputMediaPhoto("attach://file_attach_name", Some(InputFile("AgACAgIAAxkBAAIBmF5NlVQVb6iPrSZWAonh4PnZm_GMAALtrjEbORhoSkLApyEUFBhoPA1xkS4AAwEAAwIAA3gAA5wVAAIYBA")))
)
request(SendMediaGroup(msg.source, array)).void
}
}
valeol= bot.run()
println("Press [ENTER] to shutdown the bot, it may take a few seconds...")
scala.io.StdIn.readLine()
bot.shutdown() // initiate shutdown// Wait for the bot end-of-lifeAwait.result(eol, Duration.Inf)
}
With the OkHttpFutureBackend the fileid example did not log a response.
With the AsyncHttpClientFutureBackend all examples had a TelegramApiException: Bad Request: can't parse InputMedia: media not found as response.
The text was updated successfully, but these errors were encountered:
When using SendMediaGroup, I'm getting
TelegramApiException: Bad Request: can't parse InputMedia: media not found
(whether I use a file_id string or an InputFile with attach://).Here is an example bot:
With the OkHttpFutureBackend the fileid example did not log a response.
With the AsyncHttpClientFutureBackend all examples had a
TelegramApiException: Bad Request: can't parse InputMedia: media not found
as response.The text was updated successfully, but these errors were encountered: