mirror of
https://github.com/InsanusMokrassar/BooruGrabberTelegramBot.git
synced 2025-11-11 09:30:12 +00:00
add request command
This commit is contained in:
@@ -8,11 +8,7 @@ import dev.inmo.micro_utils.repos.set
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
class EnableArgsParser(
|
||||
private val chatId: ChatId,
|
||||
private val repo: KeyValueRepo<ChatId, ChatSettings>,
|
||||
private val scope: CoroutineScope
|
||||
) : CliktCommand(name = "enable") {
|
||||
class EnableArgsParser: CliktCommand(name = "enable") {
|
||||
val count by option("-n").int().help("Amount of pictures to grab each trigger time").default(1).check("Count should be in range 1-10") {
|
||||
it in 1 .. 10
|
||||
}
|
||||
@@ -25,16 +21,16 @@ class EnableArgsParser(
|
||||
}.required().help("Board type. Possible values: ${ChatSettings.BoardSerializer.types.keys.joinToString { it }}")
|
||||
val gallery by option("-g", "--gallery").flag(default = false).help("Effective only when count passed > 1. Will send chosen images as gallery instead of separated images")
|
||||
|
||||
var resultSettings: ChatSettings? = null
|
||||
private set
|
||||
|
||||
override fun run() {
|
||||
val chatSettings = ChatSettings(
|
||||
resultSettings = ChatSettings(
|
||||
query.filterNot { it.isEmpty() }.joinToString(" ").trim(),
|
||||
krontab,
|
||||
board,
|
||||
count,
|
||||
gallery
|
||||
)
|
||||
scope.launchSafelyWithoutExceptions {
|
||||
repo.set(chatId, chatSettings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user