@@ -10,6 +10,7 @@ import com.github.kotlintelegrambot.entities.inlinequeryresults.InlineQueryResul
1010import com.github.kotlintelegrambot.entities.inlinequeryresults.InputMessageContent
1111import com.github.kotlintelegrambot.extensions.filters.Filter
1212import com.github.kotlintelegrambot.logging.LogLevel
13+ import com.github.livingwithhippos.unchained_bot.data.model.DownloadItem
1314import com.github.livingwithhippos.unchained_bot.data.model.Stream
1415import com.github.livingwithhippos.unchained_bot.data.model.TorrentItem
1516import com.github.livingwithhippos.unchained_bot.data.model.UploadedTorrent
@@ -26,7 +27,6 @@ import com.github.livingwithhippos.unchained_bot.utilities.isMagnet
2627import com.github.livingwithhippos.unchained_bot.utilities.isTorrent
2728import com.github.livingwithhippos.unchained_bot.utilities.isWebUrl
2829import com.github.livingwithhippos.unchained_bot.utilities.runCommand
29- import com.github.livingwithhippos.unchained_bot.data.model.DownloadItem
3030import kotlinx.coroutines.CoroutineScope
3131import kotlinx.coroutines.Dispatchers
3232import kotlinx.coroutines.Job
@@ -48,7 +48,8 @@ class BotApplication : KoinComponent {
4848 private val privateApiKey: String = getKoin().getProperty(" PRIVATE_API_KEY" ) ? : " "
4949 private val wgetArguments: String = getKoin().getProperty(" WGET_ARGUMENTS" ) ? : " --no-verbose"
5050 private val logLevelArgument: String = getKoin().getProperty(" LOG_LEVEL" ) ? : " error"
51- private val enableQueriesArgument: Boolean = getKoin().getProperty<String >(" ENABLE_QUERIES" ).equals(" true" , true )
51+ private val enableQuery: String = getKoin().getProperty(" ENABLE_QUERIES" ) ? : " false"
52+ private val enableQueriesArgument: Boolean = enableQuery.equals(" true" , true ) || enableQuery == " 1"
5253 private val whitelistedUser: Long = getKoin().getProperty<String >(" WHITELISTED_USER" )?.toLongOrNull() ? : 0
5354 private val localeArgument: String = getKoin().getProperty(" LOCALE" ) ? : " en"
5455
@@ -344,6 +345,8 @@ class BotApplication : KoinComponent {
344345 }
345346 }
346347
348+ // todo: add torrents and magnet support, add downloads and torrents list from the menu as items if the query is empty
349+ // decide what to do with authentication, use env variable
347350 if (enableQueriesArgument) {
348351 // N.B: you need to enable the inlining with BotFather using `/setinline` to use this
349352 inlineQuery {
@@ -366,7 +369,24 @@ class BotApplication : KoinComponent {
366369 itemMessage,
367370 parseMode = ParseMode .MARKDOWN
368371 ),
369- description = localization.unrestrictDescription
372+ description = localization.unrestrictDescription,
373+ url = null
374+ )
375+ )
376+
377+ bot.answerInlineQuery(inlineQuery.id, inlineResults)
378+
379+ } else {
380+ val inlineResults = listOf (
381+ InlineQueryResult .Article (
382+ id = " 1" ,
383+ title = localization.error,
384+ inputMessageContent = InputMessageContent .Text (
385+ localization.unrestrictError,
386+ parseMode = ParseMode .MARKDOWN
387+ ),
388+ description = localization.unrestrictError,
389+ url = null
370390 )
371391 )
372392
@@ -384,7 +404,8 @@ class BotApplication : KoinComponent {
384404 }
385405
386406 private fun printCurrentParameters () {
387- println ("""
407+ println (
408+ """
388409
389410 ******************
390411 * BOT PARAMETERS *
0 commit comments