mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2025-11-12 01:50:14 +00:00
complete sample with native
This commit is contained in:
10
RandomFileSenderBot/src/nativeMain/kotlin/ActualPickFile.kt
Normal file
10
RandomFileSenderBot/src/nativeMain/kotlin/ActualPickFile.kt
Normal file
@@ -0,0 +1,10 @@
|
||||
import dev.inmo.micro_utils.common.MPPFile
|
||||
import okio.FileSystem
|
||||
|
||||
actual fun pickFile(currentRoot: MPPFile): MPPFile? {
|
||||
if (FileSystem.SYSTEM.exists(currentRoot) && FileSystem.SYSTEM.listOrNull(currentRoot) == null) {
|
||||
return currentRoot
|
||||
} else {
|
||||
return pickFile(FileSystem.SYSTEM.list(currentRoot).takeIf { it.isNotEmpty() } ?.random() ?: return null)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import okio.Path.Companion.toPath
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
runBlocking {
|
||||
doRandomFileSenderBot(args.first(), args.getOrNull(1) ?.toPath() ?: "".toPath())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user