mirror of
https://github.com/LamGC/oracle-manager.git
synced 2025-04-29 14:17:33 +00:00
perf: 增加通过 TelegramBots 下载文件的扩展函数.
通过 TelegramBots 提供的 File 下载功能, 可无需配置代理直接下载文件(使用机器人的代理).
This commit is contained in:
parent
9352e19437
commit
32c6dfd349
@ -49,6 +49,11 @@ import java.util.concurrent.atomic.AtomicReference
|
||||
import java.util.function.Predicate
|
||||
import java.util.regex.Pattern
|
||||
|
||||
fun BaseAbilityBot.getFileAsStream(fileId: String): InputStream {
|
||||
val file = execute(GetFile(fileId))
|
||||
return downloadFileAsStream(file)
|
||||
}
|
||||
|
||||
fun BaseAbilityBot.getFileUrl(fileId: String, apiServer: String = "https://api.telegram.org"): String {
|
||||
val file = execute(GetFile(fileId))
|
||||
return "$apiServer/file/bot${botToken}/${file.filePath}"
|
||||
|
Loading…
Reference in New Issue
Block a user