mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI-examples.git
synced 2026-05-21 07:47:17 +00:00
Compare commits
6 Commits
eccbe71e68
...
7.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| c7fe90ddd7 | |||
| acb382d3f7 | |||
| 0cfe60fd77 | |||
| 6719b9e17c | |||
| 8d33dc0ab2 | |||
| 3e2ccf9cf1 |
@@ -1,9 +1,9 @@
|
|||||||
# RandomFileSenderBot
|
# InlineQueriesBot
|
||||||
|
|
||||||
This bot will send random file from input folder OR from bot working folder
|
This bot will form the inline queries for you. For that feature you should explicitly enable inline queries in bot settings
|
||||||
|
|
||||||
## Launch
|
## Launch
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
../gradlew run --args="BOT_TOKEN[ optional/folder/path]"
|
../gradlew run --args="BOT_TOKEN"
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -13,11 +13,8 @@ import dev.inmo.tgbotapi.types.inlineQueryAnswerResultsLimit
|
|||||||
import dev.inmo.tgbotapi.utils.buildEntities
|
import dev.inmo.tgbotapi.utils.buildEntities
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This bot will send files inside of working directory OR from directory in the second argument.
|
* Thi bot will create inline query answers. You
|
||||||
* You may send /send_file command to this bot to get random file from the directory OR
|
* should enable inline queries in bot settings
|
||||||
* `/send_file $number` when you want to receive required number of files. For example,
|
|
||||||
* /send_file and `/send_file 1` will have the same effect - bot will send one random file.
|
|
||||||
* But if you will send `/send_file 5` it will choose 5 random files and send them as group
|
|
||||||
*/
|
*/
|
||||||
suspend fun doInlineQueriesBot(token: String) {
|
suspend fun doInlineQueriesBot(token: String) {
|
||||||
val bot = telegramBot(token)
|
val bot = telegramBot(token)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||||
import dev.inmo.micro_utils.ktor.server.createKtorServer
|
import dev.inmo.micro_utils.ktor.server.createKtorServer
|
||||||
import dev.inmo.tgbotapi.extensions.api.answers.answer
|
import dev.inmo.tgbotapi.extensions.api.answers.answer
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.answers.answerInlineQuery
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands
|
import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.*
|
import dev.inmo.tgbotapi.extensions.api.send.*
|
||||||
@@ -9,6 +10,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
|||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.formatting.makeTelegramStartattach
|
import dev.inmo.tgbotapi.extensions.utils.formatting.makeTelegramStartattach
|
||||||
import dev.inmo.tgbotapi.extensions.utils.types.buttons.*
|
import dev.inmo.tgbotapi.extensions.utils.types.buttons.*
|
||||||
|
import dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton
|
||||||
import dev.inmo.tgbotapi.types.BotCommand
|
import dev.inmo.tgbotapi.types.BotCommand
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle
|
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.InlineQueryResultArticle
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputTextMessageContent
|
import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputTextMessageContent
|
||||||
@@ -102,7 +104,7 @@ suspend fun main(vararg args: String) {
|
|||||||
onCommand("attachment_menu") {
|
onCommand("attachment_menu") {
|
||||||
reply(
|
reply(
|
||||||
it,
|
it,
|
||||||
,
|
"Button",
|
||||||
replyMarkup = inlineKeyboard {
|
replyMarkup = inlineKeyboard {
|
||||||
row {
|
row {
|
||||||
webAppButton("Open WebApp", WebAppInfo(args[1]))
|
webAppButton("Open WebApp", WebAppInfo(args[1]))
|
||||||
@@ -111,6 +113,15 @@ suspend fun main(vararg args: String) {
|
|||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
onBaseInlineQuery {
|
||||||
|
answerInlineQuery(
|
||||||
|
it,
|
||||||
|
button = InlineQueryResultsButton.invoke(
|
||||||
|
"Open webApp",
|
||||||
|
WebAppInfo(args[1])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
onUnhandledCommand {
|
onUnhandledCommand {
|
||||||
reply(
|
reply(
|
||||||
it,
|
it,
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ org.gradle.parallel=true
|
|||||||
org.gradle.jvmargs=-Xmx2g
|
org.gradle.jvmargs=-Xmx2g
|
||||||
|
|
||||||
|
|
||||||
kotlin_version=1.8.20
|
kotlin_version=1.8.21
|
||||||
telegram_bot_api_version=7.1.0-branch_7.1.0-build1602
|
telegram_bot_api_version=7.1.1
|
||||||
micro_utils_version=0.17.8
|
micro_utils_version=0.18.0
|
||||||
serialization_version=1.5.0
|
serialization_version=1.5.0
|
||||||
ktor_version=2.3.0
|
ktor_version=2.3.0
|
||||||
|
|||||||
Reference in New Issue
Block a user