Merge pull request #11 from InsanusMokrassar/0.29.0

0.29.0
This commit is contained in:
InsanusMokrassar 2020-10-04 23:50:55 +06:00 committed by GitHub
commit 8f79b9e380
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 73 additions and 60 deletions

View File

@ -20,5 +20,5 @@ repositories {
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "com.github.insanusmokrassar:TelegramBotAPI:$telegram_bot_api_version" implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
} }

View File

@ -1,12 +1,12 @@
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.downloadFile import dev.inmo.tgbotapi.extensions.api.downloadFile
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.get.getFileAdditionalInfo import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.telegramBot import dev.inmo.tgbotapi.extensions.api.telegramBot
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.flatMap import dev.inmo.tgbotapi.extensions.utils.flatMap
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.safely import dev.inmo.tgbotapi.extensions.utils.safely
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.shortcuts.* import dev.inmo.tgbotapi.extensions.utils.shortcuts.*
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
import com.github.insanusmokrassar.TelegramBotAPI.utils.filenameFromUrl import dev.inmo.tgbotapi.utils.filenameFromUrl
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.flow.* import kotlinx.coroutines.flow.*
import java.io.File import java.io.File

View File

@ -20,5 +20,5 @@ repositories {
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "com.github.insanusmokrassar:TelegramBotAPI:$telegram_bot_api_version" implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
} }

View File

@ -1,13 +1,13 @@
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.sendTextMessage import dev.inmo.tgbotapi.extensions.api.send.sendTextMessage
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.telegramBot import dev.inmo.tgbotapi.extensions.api.telegramBot
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.formatting.codeMarkdownV2 import dev.inmo.tgbotapi.extensions.utils.formatting.codeMarkdownV2
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.formatting.regularMarkdownV2 import dev.inmo.tgbotapi.extensions.utils.formatting.regularMarkdownV2
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.safely import dev.inmo.tgbotapi.extensions.utils.safely
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates.asContentMessagesFlow import dev.inmo.tgbotapi.extensions.utils.updates.asContentMessagesFlow
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownV2 import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2
import com.github.insanusmokrassar.TelegramBotAPI.types.message.* import dev.inmo.tgbotapi.types.message.*
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.PossiblyForwardedMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.flow.* import kotlinx.coroutines.flow.*
@ -32,6 +32,7 @@ suspend fun main(vararg args: String) {
"User ${user.id.chatId.toString().codeMarkdownV2()} " + "(${user.firstName} ${user.lastName}: ${user.username ?.username ?: "Without username"})".regularMarkdownV2() "User ${user.id.chatId.toString().codeMarkdownV2()} " + "(${user.firstName} ${user.lastName}: ${user.username ?.username ?: "Without username"})".regularMarkdownV2()
} }
is ForwardFromChannelInfo -> "Channel (".regularMarkdownV2() + (forwardInfo.channelChat).title.codeMarkdownV2() + ")".regularMarkdownV2() is ForwardFromChannelInfo -> "Channel (".regularMarkdownV2() + (forwardInfo.channelChat).title.codeMarkdownV2() + ")".regularMarkdownV2()
is ForwardFromSupergroupInfo -> "Supergroup (".regularMarkdownV2() + (forwardInfo.group).title.codeMarkdownV2() + ")".regularMarkdownV2()
} }
bot.sendTextMessage(message.chat, toAnswer, MarkdownV2) bot.sendTextMessage(message.chat, toAnswer, MarkdownV2)
} }

View File

@ -20,5 +20,5 @@ repositories {
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "com.github.insanusmokrassar:TelegramBotAPI:$telegram_bot_api_version" implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
} }

View File

@ -1,5 +1,5 @@
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.bot.getMe import dev.inmo.tgbotapi.extensions.api.bot.getMe
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.telegramBot import dev.inmo.tgbotapi.extensions.api.telegramBot
/** /**
* This is one of the most easiest bot - it will just print information about itself * This is one of the most easiest bot - it will just print information about itself

View File

@ -20,5 +20,5 @@ repositories {
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "com.github.insanusmokrassar:TelegramBotAPI:$telegram_bot_api_version" implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
} }

View File

@ -1,14 +1,17 @@
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.chat.get.getChat import dev.inmo.tgbotapi.extensions.api.chat.get.getChat
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.sendTextMessage import dev.inmo.tgbotapi.extensions.api.chat.get.getChatAdministrators
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.telegramBot import dev.inmo.tgbotapi.extensions.api.send.reply
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.formatting.linkMarkdownV2 import dev.inmo.tgbotapi.extensions.api.send.sendTextMessage
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.formatting.textMentionMarkdownV2 import dev.inmo.tgbotapi.extensions.api.telegramBot
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.safely import dev.inmo.tgbotapi.extensions.utils.formatting.linkMarkdownV2
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling import dev.inmo.tgbotapi.extensions.utils.formatting.textMentionMarkdownV2
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownV2 import dev.inmo.tgbotapi.extensions.utils.safely
import com.github.insanusmokrassar.TelegramBotAPI.types.User import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.* import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.escapeMarkdownV2Common import dev.inmo.tgbotapi.types.User
import dev.inmo.tgbotapi.types.chat.abstracts.*
import dev.inmo.tgbotapi.types.toChatId
import dev.inmo.tgbotapi.utils.extensions.escapeMarkdownV2Common
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
@ -23,11 +26,16 @@ suspend fun main(vararg args: String) {
val scope = CoroutineScope(Dispatchers.Default) val scope = CoroutineScope(Dispatchers.Default)
scope.launch {
println(bot.getChatAdministrators((-1001433262056L).toChatId()))
}
bot.startGettingFlowsUpdatesByLongPolling(scope = scope) { bot.startGettingFlowsUpdatesByLongPolling(scope = scope) {
messageFlow.onEach { messageFlow.onEach {
safely { safely {
val chat = it.data.chat val message = it.data
val message = "Oh, hi, " + when (chat) { val chat = message.chat
val answerText = "Oh, hi, " + when (chat) {
is PrivateChat -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id) is PrivateChat -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id)
is User -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id) is User -> "${chat.firstName} ${chat.lastName}".textMentionMarkdownV2(chat.id)
is SupergroupChat -> (chat.username ?.username ?: bot.getChat(chat).inviteLink) ?.let { is SupergroupChat -> (chat.username ?.username ?: bot.getChat(chat).inviteLink) ?.let {
@ -38,7 +46,11 @@ suspend fun main(vararg args: String) {
} ?: chat.title } ?: chat.title
else -> "Unknown :(".escapeMarkdownV2Common() else -> "Unknown :(".escapeMarkdownV2Common()
} }
bot.sendTextMessage(chat, message, MarkdownV2) bot.reply(
message,
answerText,
MarkdownV2
)
} }
}.launchIn(scope) }.launchIn(scope)
channelPostFlow.onEach { channelPostFlow.onEach {

View File

@ -20,5 +20,5 @@ repositories {
dependencies { dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "com.github.insanusmokrassar:TelegramBotAPI:$telegram_bot_api_version" implementation "dev.inmo:tgbotapi:$telegram_bot_api_version"
} }

View File

@ -1,13 +1,13 @@
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.bot.getMe import dev.inmo.tgbotapi.extensions.api.bot.getMe
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.bot.setMyCommands import dev.inmo.tgbotapi.extensions.api.bot.setMyCommands
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media.sendDocument import dev.inmo.tgbotapi.extensions.api.send.media.sendDocument
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.sendTextMessage import dev.inmo.tgbotapi.extensions.api.send.sendTextMessage
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.telegramBot import dev.inmo.tgbotapi.extensions.api.telegramBot
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.safely import dev.inmo.tgbotapi.extensions.utils.safely
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates.filterExactCommands import dev.inmo.tgbotapi.extensions.utils.updates.filterExactCommands
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.toInputFile import dev.inmo.tgbotapi.requests.abstracts.toInputFile
import com.github.insanusmokrassar.TelegramBotAPI.types.BotCommand import dev.inmo.tgbotapi.types.BotCommand
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach

View File

@ -28,7 +28,7 @@ kotlin {
dependencies { dependencies {
implementation kotlin('stdlib') implementation kotlin('stdlib')
api "com.github.insanusmokrassar:TelegramBotAPI:$telegram_bot_api_version" api "dev.inmo:tgbotapi:$telegram_bot_api_version"
} }
} }
} }

View File

@ -1,11 +1,11 @@
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.bot.getMe import dev.inmo.tgbotapi.extensions.api.bot.getMe
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.send.media.sendMediaGroup import dev.inmo.tgbotapi.extensions.api.send.media.sendMediaGroup
import com.github.insanusmokrassar.TelegramBotAPI.extensions.api.telegramBot import dev.inmo.tgbotapi.extensions.api.telegramBot
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.safely import dev.inmo.tgbotapi.extensions.utils.safely
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.shortcuts.* import dev.inmo.tgbotapi.extensions.utils.shortcuts.*
import com.github.insanusmokrassar.TelegramBotAPI.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingFlowsUpdatesByLongPolling
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaGroupContent import dev.inmo.tgbotapi.types.message.content.abstracts.MediaGroupContent
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach

View File

@ -2,4 +2,4 @@ kotlin.code.style=official
org.gradle.parallel=true org.gradle.parallel=true
kotlin_version=1.4.10 kotlin_version=1.4.10
telegram_bot_api_version=0.28.4 telegram_bot_api_version=0.29.0