【问题标题】:Send document file with Telegram library "canoe" for scala使用 Telegram 库“canoe”为 scala 发送文档文件
【发布时间】:2021-04-21 17:19:13
【问题描述】:

我想弄清楚,我如何下载和上传带有独木舟库的 java.io.File。

https://github.com/augustjune/canoe

非常糟糕的文档和少量示例。如果有人知道如何做到这一点,请帮助。

【问题讨论】:

    标签: scala telegram-bot telegram-api


    【解决方案1】:

    看来我找到了解决办法,

    def filePrepareResponse[F[_]: TelegramClient](semaphore: Semaphore[F]): Scenario[F, Unit] = {
       val in: InputFile.Upload = InputFile.fromBytes("file.pdf", Files.readAllBytes(new File("/home/dmitry/Downloads/Обращение.PDF").toPath))
       for {
         chat <- Scenario.expect(command("download").chat)
         _    <- Scenario.eval(chat.send(DocumentContent(in)))
       } yield ()}
    

    为我工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-16
      • 2022-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-23
      相关资源
      最近更新 更多