mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-10-23 08:10:09 +00:00
artifacts names has been changed
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.HttpClientConfig
|
||||
import io.ktor.client.engine.*
|
||||
|
||||
/**
|
||||
* @param proxy Standard ktor [ProxyConfig]
|
||||
* @param ktorClientEngine Engine like [io.ktor.client.engine.cio.CIO]
|
||||
* @param ktorClientConfig Config block for preconfiguring of bot [HttpClient]
|
||||
*/
|
||||
data class BotBuilder internal constructor(
|
||||
var proxy: ProxyConfig? = null,
|
||||
var ktorClientEngineFactory: HttpClientEngineFactory<HttpClientEngineConfig>? = null,
|
||||
var ktorClientConfig: (HttpClientConfig<*>.() -> Unit) ? = null
|
||||
) {
|
||||
internal fun createHttpClient(): HttpClient = ktorClientEngineFactory ?.let {
|
||||
HttpClient(
|
||||
it.create {
|
||||
this@create.proxy = this@BotBuilder.proxy ?: this@create.proxy
|
||||
}
|
||||
) {
|
||||
ktorClientConfig ?.let { it() }
|
||||
}
|
||||
} ?: HttpClient {
|
||||
ktorClientConfig ?.let { it() }
|
||||
engine {
|
||||
this@engine.proxy = this@BotBuilder.proxy ?: this@engine.proxy
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Created by [telegramBotWithCustomClientConfig] function [TelegramBot]. This executor will be preconfigured using [token] and
|
||||
* [block]
|
||||
*/
|
||||
fun telegramBot(
|
||||
token: String,
|
||||
block: BotBuilder.() -> Unit
|
||||
): TelegramBot = telegramBot(
|
||||
TelegramAPIUrlsKeeper(token),
|
||||
BotBuilder().apply(block).createHttpClient()
|
||||
)
|
@@ -0,0 +1,76 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.tgbotapi.bot.Ktor.KtorRequestsExecutor
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.HttpClientConfig
|
||||
import io.ktor.client.engine.HttpClientEngine
|
||||
|
||||
/**
|
||||
* Allows to create bot using bot [urlsKeeper] and already prepared [client]
|
||||
*/
|
||||
fun telegramBot(
|
||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||
client: HttpClient = HttpClient()
|
||||
): TelegramBot = KtorRequestsExecutor(
|
||||
urlsKeeper,
|
||||
client
|
||||
)
|
||||
|
||||
/**
|
||||
* Allows to create bot using bot [urlsKeeper] and specify [HttpClientEngine] by passing [clientEngine] param and optionally
|
||||
* configure [HttpClient] using [clientConfig]
|
||||
*/
|
||||
fun telegramBotWithCustomClientConfig(
|
||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||
clientEngine: HttpClientEngine,
|
||||
clientConfig: HttpClientConfig<*>.() -> Unit = {}
|
||||
): TelegramBot = telegramBot(
|
||||
urlsKeeper,
|
||||
HttpClient(clientEngine, clientConfig)
|
||||
)
|
||||
|
||||
/**
|
||||
* Allows to create bot using bot [urlsKeeper] and optionally configure [HttpClient] using [clientConfig]
|
||||
*/
|
||||
fun telegramBotWithCustomClientConfig(
|
||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||
clientConfig: HttpClientConfig<*>.() -> Unit = {}
|
||||
): TelegramBot = telegramBot(
|
||||
urlsKeeper,
|
||||
HttpClient(clientConfig)
|
||||
)
|
||||
|
||||
/**
|
||||
* Allows to create bot using bot [token]
|
||||
*/
|
||||
fun telegramBot(
|
||||
token: String
|
||||
): TelegramBot = telegramBotWithCustomClientConfig(TelegramAPIUrlsKeeper(token))
|
||||
|
||||
/**
|
||||
* Allows to create bot using bot [token] and already prepared [client]
|
||||
*/
|
||||
fun telegramBot(
|
||||
token: String,
|
||||
client: HttpClient
|
||||
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token), client)
|
||||
|
||||
/**
|
||||
* Allows to create bot using bot [token] and configure [HttpClient] using [clientConfig]
|
||||
*/
|
||||
fun telegramBotWithCustomClientConfig(
|
||||
token: String,
|
||||
clientConfig: HttpClientConfig<*>.() -> Unit
|
||||
): TelegramBot = telegramBotWithCustomClientConfig(TelegramAPIUrlsKeeper(token), clientConfig)
|
||||
|
||||
/**
|
||||
* Allows to create bot using bot [token] and specify [HttpClientEngine] by passing [clientEngine] param and optionally
|
||||
* configure [HttpClient] using [clientConfig]
|
||||
*/
|
||||
fun telegramBot(
|
||||
token: String,
|
||||
clientEngine: HttpClientEngine,
|
||||
clientConfig: HttpClientConfig<*>.() -> Unit = {}
|
||||
): TelegramBot = telegramBotWithCustomClientConfig(TelegramAPIUrlsKeeper(token), clientEngine, clientConfig)
|
@@ -0,0 +1,28 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.DeleteMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.deleteMessage(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier
|
||||
) = execute(
|
||||
DeleteMessage(chatId, messageId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.deleteMessage(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier
|
||||
) = deleteMessage(chat.id, messageId)
|
||||
|
||||
suspend fun TelegramBot.deleteMessage(
|
||||
message: Message
|
||||
) = deleteMessage(message.chat, message.messageId)
|
||||
|
||||
suspend fun Message.delete(
|
||||
requestsExecutor: TelegramBot
|
||||
) = requestsExecutor.deleteMessage(this)
|
@@ -0,0 +1,32 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
|
||||
import dev.inmo.tgbotapi.requests.DownloadFile
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.types.files.PathedFile
|
||||
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
|
||||
|
||||
suspend fun TelegramBot.downloadFile(
|
||||
filePath: String
|
||||
): ByteArray = execute(
|
||||
DownloadFile(filePath)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.downloadFile(
|
||||
pathedFile: PathedFile
|
||||
): ByteArray = execute(
|
||||
DownloadFile(pathedFile.filePath)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.downloadFile(
|
||||
fileId: FileId
|
||||
): ByteArray = downloadFile(
|
||||
getFileAdditionalInfo(fileId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.downloadFile(
|
||||
file: TelegramMediaFile
|
||||
): ByteArray = downloadFile(
|
||||
getFileAdditionalInfo(file)
|
||||
)
|
@@ -0,0 +1,50 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.ForwardMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.forwardMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
disableNotification: Boolean = false
|
||||
) = execute(
|
||||
ForwardMessage(fromChatId, toChatId, messageId, disableNotification)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.forwardMessage(
|
||||
fromChat: Chat,
|
||||
toChatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
disableNotification: Boolean = false
|
||||
) = forwardMessage(fromChat.id, toChatId, messageId, disableNotification)
|
||||
|
||||
suspend fun TelegramBot.forwardMessage(
|
||||
fromChatId: ChatIdentifier,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
disableNotification: Boolean = false
|
||||
) = forwardMessage(fromChatId, toChat.id, messageId, disableNotification)
|
||||
|
||||
suspend fun TelegramBot.forwardMessage(
|
||||
fromChat: Chat,
|
||||
toChat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
disableNotification: Boolean = false
|
||||
) = forwardMessage(fromChat.id, toChat.id, messageId, disableNotification)
|
||||
|
||||
suspend fun TelegramBot.forwardMessage(
|
||||
toChatId: ChatIdentifier,
|
||||
message: Message,
|
||||
disableNotification: Boolean = false
|
||||
) = forwardMessage(message.chat, toChatId, message.messageId, disableNotification)
|
||||
|
||||
suspend fun TelegramBot.forwardMessage(
|
||||
toChat: Chat,
|
||||
message: Message,
|
||||
disableNotification: Boolean = false
|
||||
) = forwardMessage(message.chat, toChat, message.messageId, disableNotification)
|
@@ -0,0 +1,26 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.GetUpdates
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
suspend fun TelegramBot.getUpdates(
|
||||
offset: UpdateIdentifier? = null,
|
||||
limit: Int = getUpdatesLimit.last,
|
||||
timeout: Seconds? = null,
|
||||
allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||
) = execute(
|
||||
GetUpdates(
|
||||
offset, limit, timeout, allowed_updates
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getUpdates(
|
||||
lastUpdate: Update,
|
||||
limit: Int = getUpdatesLimit.last,
|
||||
timeout: Seconds? = null,
|
||||
allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||
) = getUpdates(
|
||||
lastUpdate.updateId + 1, limit, timeout, allowed_updates
|
||||
)
|
@@ -0,0 +1,70 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.InternalUtils
|
||||
|
||||
import dev.inmo.tgbotapi.types.MediaGroupIdentifier
|
||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.update.*
|
||||
import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.*
|
||||
|
||||
internal fun Update.lastUpdateIdentifier(): UpdateIdentifier {
|
||||
return if (this is SentMediaGroupUpdate) {
|
||||
origins.last().updateId
|
||||
} else {
|
||||
updateId
|
||||
}
|
||||
}
|
||||
|
||||
internal fun List<Update>.lastUpdateIdentifier(): UpdateIdentifier? {
|
||||
return maxByOrNull { it.updateId } ?.lastUpdateIdentifier()
|
||||
}
|
||||
|
||||
internal fun List<Update>.convertWithMediaGroupUpdates(): List<Update> {
|
||||
val resultUpdates = mutableListOf<Update>()
|
||||
val mediaGroups = mutableMapOf<MediaGroupIdentifier, MutableList<BaseSentMessageUpdate>>()
|
||||
for (update in this) {
|
||||
val data = (update.data as? MediaGroupMessage)
|
||||
if (data == null) {
|
||||
resultUpdates.add(update)
|
||||
continue
|
||||
}
|
||||
when (update) {
|
||||
is BaseEditMessageUpdate -> resultUpdates.add(
|
||||
update.toEditMediaGroupUpdate()
|
||||
)
|
||||
is BaseSentMessageUpdate -> {
|
||||
mediaGroups.getOrPut(data.mediaGroupId) {
|
||||
mutableListOf()
|
||||
}.add(update)
|
||||
}
|
||||
else -> resultUpdates.add(update)
|
||||
}
|
||||
}
|
||||
mediaGroups.values.map {
|
||||
it.toSentMediaGroupUpdate() ?.let { mediaGroupUpdate ->
|
||||
resultUpdates.add(mediaGroupUpdate)
|
||||
}
|
||||
}
|
||||
resultUpdates.sortBy { it.updateId }
|
||||
return resultUpdates
|
||||
}
|
||||
|
||||
internal fun List<BaseSentMessageUpdate>.toSentMediaGroupUpdate(): SentMediaGroupUpdate? = (this as? SentMediaGroupUpdate) ?: let {
|
||||
if (isEmpty()) {
|
||||
return@let null
|
||||
}
|
||||
val resultList = sortedBy { it.updateId }
|
||||
when (first()) {
|
||||
is MessageUpdate -> MessageMediaGroupUpdate(resultList)
|
||||
is ChannelPostUpdate -> ChannelPostMediaGroupUpdate(resultList)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
internal fun BaseEditMessageUpdate.toEditMediaGroupUpdate(): EditMediaGroupUpdate = (this as? EditMediaGroupUpdate) ?: let {
|
||||
when (this) {
|
||||
is EditMessageUpdate -> EditMessageMediaGroupUpdate(this)
|
||||
is EditChannelPostUpdate -> EditChannelPostMediaGroupUpdate(this)
|
||||
else -> error("Unsupported type of ${BaseEditMessageUpdate::class.simpleName}")
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE")
|
||||
internal val nonstrictJsonFormat = Json {
|
||||
isLenient = true
|
||||
ignoreUnknownKeys = true
|
||||
allowSpecialFloatingPointValues = true
|
||||
useArrayPolymorphism = true
|
||||
encodeDefaults = true
|
||||
}
|
@@ -0,0 +1,155 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.LiveLocation.editLiveLocation
|
||||
import dev.inmo.tgbotapi.extensions.api.edit.LiveLocation.stopLiveLocation
|
||||
import dev.inmo.tgbotapi.requests.send.SendLocation
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||
import com.soywiz.klock.DateTime
|
||||
import com.soywiz.klock.TimeSpan
|
||||
import io.ktor.utils.io.core.Closeable
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.math.ceil
|
||||
|
||||
val defaultLivePeriodDelayMillis = (livePeriodLimit.last - 60L) * 1000L
|
||||
class LiveLocation internal constructor(
|
||||
private val requestsExecutor: TelegramBot,
|
||||
scope: CoroutineScope,
|
||||
autoCloseTimeDelay: Double,
|
||||
initMessage: ContentMessage<LocationContent>
|
||||
) : Closeable {
|
||||
private val doWhenClose = {
|
||||
scope.launch {
|
||||
requestsExecutor.stopLiveLocation(message)
|
||||
}
|
||||
}
|
||||
private val autoCloseTime = DateTime.now() + TimeSpan(autoCloseTimeDelay)
|
||||
val leftUntilCloseMillis: TimeSpan
|
||||
get() = autoCloseTime - DateTime.now()
|
||||
|
||||
var isClosed: Boolean = false
|
||||
private set
|
||||
get() = field || leftUntilCloseMillis.millisecondsLong < 0L
|
||||
|
||||
private var message: ContentMessage<LocationContent> = initMessage
|
||||
val lastLocation: Location
|
||||
get() = message.content.location
|
||||
|
||||
suspend fun updateLocation(
|
||||
location: Location,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
): Location {
|
||||
if (!isClosed) {
|
||||
message = requestsExecutor.editLiveLocation(
|
||||
message,
|
||||
location,
|
||||
replyMarkup
|
||||
)
|
||||
return lastLocation
|
||||
} else {
|
||||
error("LiveLocation is closed")
|
||||
}
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
if (isClosed) {
|
||||
return
|
||||
}
|
||||
isClosed = true
|
||||
doWhenClose()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun TelegramBot.startLiveLocation(
|
||||
scope: CoroutineScope,
|
||||
chatId: ChatIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): LiveLocation {
|
||||
val liveTimeAsDouble = liveTimeMillis.toDouble()
|
||||
val locationMessage = execute(
|
||||
SendLocation(
|
||||
chatId,
|
||||
latitude,
|
||||
longitude,
|
||||
ceil(liveTimeAsDouble / 1000).toLong(),
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
return LiveLocation(
|
||||
this,
|
||||
scope,
|
||||
liveTimeAsDouble,
|
||||
locationMessage
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun TelegramBot.startLiveLocation(
|
||||
scope: CoroutineScope,
|
||||
chat: Chat,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): LiveLocation = startLiveLocation(
|
||||
scope, chat.id, latitude, longitude, liveTimeMillis, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.startLiveLocation(
|
||||
scope: CoroutineScope,
|
||||
chatId: ChatId,
|
||||
location: Location,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): LiveLocation = startLiveLocation(
|
||||
scope, chatId, location.latitude, location.longitude, liveTimeMillis, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.startLiveLocation(
|
||||
scope: CoroutineScope,
|
||||
chat: Chat,
|
||||
location: Location,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
): LiveLocation = startLiveLocation(
|
||||
scope, chat.id, location.latitude, location.longitude, liveTimeMillis, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithLiveLocation(
|
||||
to: Message,
|
||||
scope: CoroutineScope,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = startLiveLocation(scope, to.chat, latitude, longitude, liveTimeMillis, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithLiveLocation(
|
||||
to: Message,
|
||||
scope: CoroutineScope,
|
||||
location: Location,
|
||||
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = startLiveLocation(scope, to.chat, location, liveTimeMillis, disableNotification, to.messageId, replyMarkup)
|
@@ -0,0 +1,34 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.StopPoll
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.stopPoll(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
StopPoll(chatId, messageId, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.stopPoll(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopPoll(chat.id, messageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.stopPoll(
|
||||
chatId: ChatId,
|
||||
message: Message,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopPoll(chatId, message.messageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.stopPoll(
|
||||
chat: Chat,
|
||||
message: Message,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopPoll(chat.id, message.messageId, replyMarkup)
|
@@ -0,0 +1,22 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.answers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.answers.AnswerCallbackQuery
|
||||
import dev.inmo.tgbotapi.types.CallbackQuery.CallbackQuery
|
||||
import dev.inmo.tgbotapi.types.CallbackQueryIdentifier
|
||||
|
||||
suspend fun TelegramBot.answerCallbackQuery(
|
||||
callbackQueryId: CallbackQueryIdentifier,
|
||||
text: String? = null,
|
||||
showAlert: Boolean? = null,
|
||||
url: String? = null,
|
||||
cachedTimeSeconds: Int? = null
|
||||
) = execute(AnswerCallbackQuery(callbackQueryId, text, showAlert, url, cachedTimeSeconds))
|
||||
|
||||
suspend fun TelegramBot.answerCallbackQuery(
|
||||
callbackQuery: CallbackQuery,
|
||||
text: String? = null,
|
||||
showAlert: Boolean? = null,
|
||||
url: String? = null,
|
||||
cachedTimeSeconds: Int? = null
|
||||
) = answerCallbackQuery(callbackQuery.id, text, showAlert, url, cachedTimeSeconds)
|
@@ -0,0 +1,29 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.answers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.answers.AnswerInlineQuery
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.abstracts.InlineQuery
|
||||
import dev.inmo.tgbotapi.types.InlineQueryIdentifier
|
||||
|
||||
suspend fun TelegramBot.answerInlineQuery(
|
||||
inlineQueryID: InlineQueryIdentifier,
|
||||
results: List<InlineQueryResult> = emptyList(),
|
||||
cachedTime: Int? = null,
|
||||
isPersonal: Boolean? = null,
|
||||
nextOffset: String? = null,
|
||||
switchPmText: String? = null,
|
||||
switchPmParameter: String? = null
|
||||
) = execute(
|
||||
AnswerInlineQuery(inlineQueryID, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.answerInlineQuery(
|
||||
inlineQuery: InlineQuery,
|
||||
results: List<InlineQueryResult> = emptyList(),
|
||||
cachedTime: Int? = null,
|
||||
isPersonal: Boolean? = null,
|
||||
nextOffset: String? = null,
|
||||
switchPmText: String? = null,
|
||||
switchPmParameter: String? = null
|
||||
) = answerInlineQuery(inlineQuery.id, results, cachedTime, isPersonal, nextOffset, switchPmText, switchPmParameter)
|
@@ -0,0 +1,23 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.answers.payments
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.answers.payments.AnswerPreCheckoutQueryError
|
||||
import dev.inmo.tgbotapi.requests.answers.payments.AnswerPreCheckoutQueryOk
|
||||
import dev.inmo.tgbotapi.types.PreCheckoutQueryId
|
||||
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
|
||||
|
||||
suspend fun TelegramBot.answerPreCheckoutQueryOk(
|
||||
id: PreCheckoutQueryId
|
||||
) = execute(AnswerPreCheckoutQueryOk(id))
|
||||
suspend fun TelegramBot.answerPreCheckoutQueryOk(
|
||||
preCheckoutQuery: PreCheckoutQuery
|
||||
) = answerPreCheckoutQueryOk(preCheckoutQuery.id)
|
||||
|
||||
suspend fun TelegramBot.answerPreCheckoutQueryError(
|
||||
id: PreCheckoutQueryId,
|
||||
error: String
|
||||
) = execute(AnswerPreCheckoutQueryError(id, error))
|
||||
suspend fun TelegramBot.answerPreCheckoutQueryError(
|
||||
preCheckoutQuery: PreCheckoutQuery,
|
||||
error: String
|
||||
) = answerPreCheckoutQueryError(preCheckoutQuery.id, error)
|
@@ -0,0 +1,28 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.answers.payments
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.answers.payments.AnswerShippingQueryError
|
||||
import dev.inmo.tgbotapi.requests.answers.payments.AnswerShippingQueryOk
|
||||
import dev.inmo.tgbotapi.types.ShippingQueryIdentifier
|
||||
import dev.inmo.tgbotapi.types.payments.ShippingOption
|
||||
import dev.inmo.tgbotapi.types.payments.ShippingQuery
|
||||
|
||||
suspend fun TelegramBot.answerShippingQueryOk(
|
||||
id: ShippingQueryIdentifier,
|
||||
shippingOptions: List<ShippingOption>
|
||||
) = execute(AnswerShippingQueryOk(id, shippingOptions))
|
||||
suspend fun TelegramBot.answerShippingQueryOk(
|
||||
shippingQuery: ShippingQuery,
|
||||
shippingOptions: List<ShippingOption>
|
||||
) = answerShippingQueryOk(shippingQuery.id, shippingOptions)
|
||||
|
||||
suspend fun TelegramBot.answerShippingQueryError(
|
||||
id: ShippingQueryIdentifier,
|
||||
error: String
|
||||
) = execute(AnswerShippingQueryError(id, error))
|
||||
suspend fun TelegramBot.answerShippingQueryError(
|
||||
shippingQuery: ShippingQuery,
|
||||
error: String
|
||||
) = answerShippingQueryError(shippingQuery.id, error)
|
||||
|
||||
|
@@ -0,0 +1,6 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.bot
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.bot.GetMe
|
||||
|
||||
suspend fun TelegramBot.getMe() = execute(GetMe)
|
@@ -0,0 +1,6 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.bot
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.bot.GetMyCommands
|
||||
|
||||
suspend fun TelegramBot.getMyCommands() = execute(GetMyCommands)
|
@@ -0,0 +1,13 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.bot
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.bot.SetMyCommands
|
||||
import dev.inmo.tgbotapi.types.BotCommand
|
||||
|
||||
suspend fun TelegramBot.setMyCommands(
|
||||
commands: List<BotCommand>
|
||||
) = execute(SetMyCommands(commands))
|
||||
|
||||
suspend fun TelegramBot.setMyCommands(
|
||||
vararg commands: BotCommand
|
||||
) = setMyCommands(commands.toList())
|
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.ExportChatInviteLink
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.exportChatInviteLink(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(ExportChatInviteLink(chatId))
|
||||
|
||||
suspend fun TelegramBot.exportChatInviteLink(
|
||||
chat: PublicChat
|
||||
) = exportChatInviteLink(chat.id)
|
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.LeaveChat
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.leaveChat(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(LeaveChat(chatId))
|
||||
|
||||
suspend fun TelegramBot.leaveChat(
|
||||
chat: PublicChat
|
||||
) = leaveChat(chat.id)
|
@@ -0,0 +1,132 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.get
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.get.GetChat
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.*
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.extended.*
|
||||
import dev.inmo.tgbotapi.types.chat.extended.*
|
||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||
|
||||
suspend fun TelegramBot.getChat(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(GetChat(chatId))
|
||||
|
||||
suspend fun TelegramBot.getChat(
|
||||
chat: Chat
|
||||
) = getChat(chat.id)
|
||||
|
||||
/**
|
||||
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
|
||||
* [ExtendedPublicChat] with unsafe operator "as"
|
||||
*
|
||||
* @throws ClassCastException
|
||||
*/
|
||||
@PreviewFeature
|
||||
suspend fun TelegramBot.getChat(
|
||||
chat: PublicChat
|
||||
) = getChat(chat.id) as ExtendedPublicChat
|
||||
|
||||
|
||||
/**
|
||||
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
|
||||
* [ExtendedChannelChat] with unsafe operator "as"
|
||||
*
|
||||
* @throws ClassCastException
|
||||
*/
|
||||
@PreviewFeature
|
||||
suspend fun TelegramBot.getChat(
|
||||
chat: ChannelChat
|
||||
) = getChat(chat.id) as ExtendedChannelChat
|
||||
|
||||
/**
|
||||
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
|
||||
* [ExtendedChannelChatImpl] with unsafe operator "as"
|
||||
*
|
||||
* @throws ClassCastException
|
||||
*/
|
||||
@PreviewFeature
|
||||
suspend fun TelegramBot.getChat(
|
||||
chat: ChannelChatImpl
|
||||
) = getChat(chat.id) as ExtendedChannelChatImpl
|
||||
|
||||
|
||||
/**
|
||||
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
|
||||
* [ExtendedGroupChat] with unsafe operator "as"
|
||||
*
|
||||
* @throws ClassCastException
|
||||
*/
|
||||
@PreviewFeature
|
||||
suspend fun TelegramBot.getChat(
|
||||
chat: GroupChat
|
||||
) = getChat(chat.id) as ExtendedGroupChat
|
||||
|
||||
/**
|
||||
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
|
||||
* [ExtendedGroupChatImpl] with unsafe operator "as"
|
||||
*
|
||||
* @throws ClassCastException
|
||||
*/
|
||||
@PreviewFeature
|
||||
suspend fun TelegramBot.getChat(
|
||||
chat: GroupChatImpl
|
||||
) = getChat(chat.id) as ExtendedGroupChatImpl
|
||||
|
||||
|
||||
/**
|
||||
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
|
||||
* [ExtendedSupergroupChat] with unsafe operator "as"
|
||||
*
|
||||
* @throws ClassCastException
|
||||
*/
|
||||
@PreviewFeature
|
||||
suspend fun TelegramBot.getChat(
|
||||
chat: SupergroupChat
|
||||
) = getChat(chat.id) as ExtendedSupergroupChat
|
||||
|
||||
/**
|
||||
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
|
||||
* [ExtendedSupergroupChatImpl] with unsafe operator "as"
|
||||
*
|
||||
* @throws ClassCastException
|
||||
*/
|
||||
@PreviewFeature
|
||||
suspend fun TelegramBot.getChat(
|
||||
chat: SupergroupChatImpl
|
||||
) = getChat(chat.id) as ExtendedSupergroupChatImpl
|
||||
|
||||
|
||||
/**
|
||||
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
|
||||
* [ExtendedPrivateChat] with unsafe operator "as"
|
||||
*
|
||||
* @throws ClassCastException
|
||||
*/
|
||||
@PreviewFeature
|
||||
suspend fun TelegramBot.getChat(
|
||||
chat: PrivateChat
|
||||
) = getChat(chat.id) as ExtendedPrivateChat
|
||||
|
||||
/**
|
||||
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
|
||||
* [ExtendedPrivateChatImpl] with unsafe operator "as"
|
||||
*
|
||||
* @throws ClassCastException
|
||||
*/
|
||||
@PreviewFeature
|
||||
suspend fun TelegramBot.getChat(
|
||||
chat: PrivateChatImpl
|
||||
) = getChat(chat.id) as ExtendedPrivateChatImpl
|
||||
|
||||
/**
|
||||
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
|
||||
* [ExtendedUser] with unsafe operator "as"
|
||||
*
|
||||
* @throws ClassCastException
|
||||
*/
|
||||
@PreviewFeature
|
||||
suspend fun TelegramBot.getChat(
|
||||
chat: CommonUser
|
||||
) = getChat(chat.id) as ExtendedUser
|
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.get
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.get.GetChatAdministrators
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.getChatAdministrators(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(GetChatAdministrators(chatId))
|
||||
|
||||
suspend fun TelegramBot.getChatAdministrators(
|
||||
chat: PublicChat
|
||||
) = getChatAdministrators(chat.id)
|
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.get
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.get.GetChatMembersCount
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.getChatMembersCount(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(GetChatMembersCount(chatId))
|
||||
|
||||
suspend fun TelegramBot.getChatMembersCount(
|
||||
chat: PublicChat
|
||||
) = getChatMembersCount(chat.id)
|
@@ -0,0 +1,26 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.members
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.members.GetChatMember
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.getChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId
|
||||
) = execute(GetChatMember(chatId, userId))
|
||||
|
||||
suspend fun TelegramBot.getChatMember(
|
||||
chat: PublicChat,
|
||||
userId: UserId
|
||||
) = getChatMember(chat.id, userId)
|
||||
|
||||
suspend fun TelegramBot.getChatMember(
|
||||
chatId: ChatId,
|
||||
user: User
|
||||
) = getChatMember(chatId, user.id)
|
||||
|
||||
suspend fun TelegramBot.getChatMember(
|
||||
chat: PublicChat,
|
||||
user: User
|
||||
) = getChatMember(chat.id, user.id)
|
@@ -0,0 +1,30 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.members
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.members.KickChatMember
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.kickChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null
|
||||
) = execute(KickChatMember(chatId, userId, untilDate))
|
||||
|
||||
suspend fun TelegramBot.kickChatMember(
|
||||
chat: PublicChat,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null
|
||||
) = kickChatMember(chat.id, userId, untilDate)
|
||||
|
||||
suspend fun TelegramBot.kickChatMember(
|
||||
chatId: ChatId,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null
|
||||
) = kickChatMember(chatId, user.id, untilDate)
|
||||
|
||||
suspend fun TelegramBot.kickChatMember(
|
||||
chat: PublicChat,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null
|
||||
) = kickChatMember(chat.id, user.id, untilDate)
|
@@ -0,0 +1,112 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.members
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.promoteChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null,
|
||||
canChangeInfo: Boolean? = null,
|
||||
canPostMessages: Boolean? = null,
|
||||
canEditMessages: Boolean? = null,
|
||||
canDeleteMessages: Boolean? = null,
|
||||
canInviteUsers: Boolean? = null,
|
||||
canRestrictMembers: Boolean? = null,
|
||||
canPinMessages: Boolean? = null,
|
||||
canPromoteMembers: Boolean? = null
|
||||
) = execute(
|
||||
PromoteChatMember(
|
||||
chatId,
|
||||
userId,
|
||||
untilDate,
|
||||
canChangeInfo,
|
||||
canPostMessages,
|
||||
canEditMessages,
|
||||
canDeleteMessages,
|
||||
canInviteUsers,
|
||||
canRestrictMembers,
|
||||
canPinMessages,
|
||||
canPromoteMembers
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.promoteChatMember(
|
||||
chat: PublicChat,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null,
|
||||
canChangeInfo: Boolean? = null,
|
||||
canPostMessages: Boolean? = null,
|
||||
canEditMessages: Boolean? = null,
|
||||
canDeleteMessages: Boolean? = null,
|
||||
canInviteUsers: Boolean? = null,
|
||||
canRestrictMembers: Boolean? = null,
|
||||
canPinMessages: Boolean? = null,
|
||||
canPromoteMembers: Boolean? = null
|
||||
) = promoteChatMember(
|
||||
chat.id,
|
||||
userId,
|
||||
untilDate,
|
||||
canChangeInfo,
|
||||
canPostMessages,
|
||||
canEditMessages,
|
||||
canDeleteMessages,
|
||||
canInviteUsers,
|
||||
canRestrictMembers,
|
||||
canPinMessages,
|
||||
canPromoteMembers
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.promoteChatMember(
|
||||
chatId: ChatId,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null,
|
||||
canChangeInfo: Boolean? = null,
|
||||
canPostMessages: Boolean? = null,
|
||||
canEditMessages: Boolean? = null,
|
||||
canDeleteMessages: Boolean? = null,
|
||||
canInviteUsers: Boolean? = null,
|
||||
canRestrictMembers: Boolean? = null,
|
||||
canPinMessages: Boolean? = null,
|
||||
canPromoteMembers: Boolean? = null
|
||||
) = promoteChatMember(
|
||||
chatId,
|
||||
user.id,
|
||||
untilDate,
|
||||
canChangeInfo,
|
||||
canPostMessages,
|
||||
canEditMessages,
|
||||
canDeleteMessages,
|
||||
canInviteUsers,
|
||||
canRestrictMembers,
|
||||
canPinMessages,
|
||||
canPromoteMembers
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.promoteChatMember(
|
||||
chat: PublicChat,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null,
|
||||
canChangeInfo: Boolean? = null,
|
||||
canPostMessages: Boolean? = null,
|
||||
canEditMessages: Boolean? = null,
|
||||
canDeleteMessages: Boolean? = null,
|
||||
canInviteUsers: Boolean? = null,
|
||||
canRestrictMembers: Boolean? = null,
|
||||
canPinMessages: Boolean? = null,
|
||||
canPromoteMembers: Boolean? = null
|
||||
) = promoteChatMember(
|
||||
chat.id,
|
||||
user.id,
|
||||
untilDate,
|
||||
canChangeInfo,
|
||||
canPostMessages,
|
||||
canEditMessages,
|
||||
canDeleteMessages,
|
||||
canInviteUsers,
|
||||
canRestrictMembers,
|
||||
canPinMessages,
|
||||
canPromoteMembers
|
||||
)
|
@@ -0,0 +1,36 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.members
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.members.RestrictChatMember
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.ChatPermissions
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.restrictChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = execute(RestrictChatMember(chatId, userId, untilDate, permissions))
|
||||
|
||||
suspend fun TelegramBot.restrictChatMember(
|
||||
chat: PublicChat,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = restrictChatMember(chat.id, userId, untilDate, permissions)
|
||||
|
||||
suspend fun TelegramBot.restrictChatMember(
|
||||
chatId: ChatId,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = restrictChatMember(chatId, user.id, untilDate, permissions)
|
||||
|
||||
suspend fun TelegramBot.restrictChatMember(
|
||||
chat: PublicChat,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = restrictChatMember(chat.id, user.id, untilDate, permissions)
|
||||
|
@@ -0,0 +1,30 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.members
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.members.SetChatAdministratorCustomTitle
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.setChatAdministratorCustomTitle(
|
||||
chatId: ChatId,
|
||||
userId: UserId,
|
||||
customTitle: String
|
||||
) = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle))
|
||||
|
||||
suspend fun TelegramBot.setChatAdministratorCustomTitle(
|
||||
chat: PublicChat,
|
||||
userId: UserId,
|
||||
customTitle: String
|
||||
) = setChatAdministratorCustomTitle(chat.id, userId, customTitle)
|
||||
|
||||
suspend fun TelegramBot.setChatAdministratorCustomTitle(
|
||||
chatId: ChatId,
|
||||
user: User,
|
||||
customTitle: String
|
||||
) = setChatAdministratorCustomTitle(chatId, user.id, customTitle)
|
||||
|
||||
suspend fun TelegramBot.setChatAdministratorCustomTitle(
|
||||
chat: PublicChat,
|
||||
user: User,
|
||||
customTitle: String
|
||||
) = setChatAdministratorCustomTitle(chat.id, user.id, customTitle)
|
@@ -0,0 +1,27 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.members
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.members.UnbanChatMember
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.unbanChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId
|
||||
) = execute(UnbanChatMember(chatId, userId))
|
||||
|
||||
suspend fun TelegramBot.unbanChatMember(
|
||||
chat: PublicChat,
|
||||
userId: UserId
|
||||
) = unbanChatMember(chat.id, userId)
|
||||
|
||||
suspend fun TelegramBot.unbanChatMember(
|
||||
chatId: ChatId,
|
||||
user: User
|
||||
) = unbanChatMember(chatId, user.id)
|
||||
|
||||
suspend fun TelegramBot.unbanChatMember(
|
||||
chat: PublicChat,
|
||||
user: User
|
||||
) = unbanChatMember(chat.id, user.id)
|
||||
|
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.modify
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.modify.DeleteChatPhoto
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.deleteChatPhoto(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(DeleteChatPhoto(chatId))
|
||||
|
||||
suspend fun TelegramBot.deleteChatPhoto(
|
||||
chat: PublicChat
|
||||
) = deleteChatPhoto(chat.id)
|
@@ -0,0 +1,29 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.modify
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.modify.PinChatMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.pinChatMessage(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
disableNotification: Boolean = false
|
||||
) = execute(PinChatMessage(chatId, messageId, disableNotification))
|
||||
|
||||
suspend fun TelegramBot.pinChatMessage(
|
||||
chat: PublicChat,
|
||||
messageId: MessageIdentifier,
|
||||
disableNotification: Boolean = false
|
||||
) = pinChatMessage(chat.id, messageId, disableNotification)
|
||||
|
||||
suspend fun TelegramBot.pinChatMessage(
|
||||
message: Message,
|
||||
disableNotification: Boolean = false
|
||||
) = if (message.chat is PublicChat) {
|
||||
pinChatMessage(message.chat.id, message.messageId, disableNotification)
|
||||
} else {
|
||||
error("It is possible to pin messages only in non one-to-one chats")
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.modify
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.modify.SetChatDescription
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.setChatDescription(
|
||||
chatId: ChatIdentifier,
|
||||
description: String
|
||||
) = execute(SetChatDescription(chatId, description))
|
||||
|
||||
suspend fun TelegramBot.setChatDescription(
|
||||
chat: PublicChat,
|
||||
description: String
|
||||
) = setChatDescription(chat.id, description)
|
@@ -0,0 +1,17 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.modify
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.modify.SetChatPermissions
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.ChatPermissions
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.setDefaultChatMembersPermissions(
|
||||
chatId: ChatIdentifier,
|
||||
permissions: ChatPermissions
|
||||
) = execute(SetChatPermissions(chatId, permissions))
|
||||
|
||||
suspend fun TelegramBot.setDefaultChatMembersPermissions(
|
||||
chat: PublicChat,
|
||||
permissions: ChatPermissions
|
||||
) = setDefaultChatMembersPermissions(chat.id, permissions)
|
@@ -0,0 +1,17 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.modify
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.chat.modify.SetChatPhoto
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.setChatPhoto(
|
||||
chatId: ChatIdentifier,
|
||||
photo: MultipartFile
|
||||
) = execute(SetChatPhoto(chatId, photo))
|
||||
|
||||
suspend fun TelegramBot.setChatPhoto(
|
||||
chat: PublicChat,
|
||||
photo: MultipartFile
|
||||
) = setChatPhoto(chat.id, photo)
|
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.modify
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.modify.SetChatTitle
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.setChatTitle(
|
||||
chatId: ChatIdentifier,
|
||||
title: String
|
||||
) = execute(SetChatTitle(chatId, title))
|
||||
|
||||
suspend fun TelegramBot.setChatTitle(
|
||||
chat: PublicChat,
|
||||
title: String
|
||||
) = setChatTitle(chat.id, title)
|
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.modify
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.modify.UnpinChatMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.PublicChat
|
||||
|
||||
suspend fun TelegramBot.unpinChatMessage(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(UnpinChatMessage(chatId))
|
||||
|
||||
suspend fun TelegramBot.unpinChatMessage(
|
||||
chat: PublicChat
|
||||
) = unpinChatMessage(chat.id)
|
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.stickers.DeleteChatStickerSet
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.SupergroupChat
|
||||
|
||||
suspend fun TelegramBot.deleteChatStickerSet(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(DeleteChatStickerSet(chatId))
|
||||
|
||||
suspend fun TelegramBot.deleteChatStickerSet(
|
||||
chat: SupergroupChat
|
||||
) = deleteChatStickerSet(chat.id)
|
@@ -0,0 +1,17 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.chat.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.chat.stickers.SetChatStickerSet
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.StickerSetName
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.SupergroupChat
|
||||
|
||||
suspend fun TelegramBot.setChatStickerSet(
|
||||
chatId: ChatIdentifier,
|
||||
stickerSetName: StickerSetName
|
||||
) = execute(SetChatStickerSet(chatId, stickerSetName))
|
||||
|
||||
suspend fun TelegramBot.setChatStickerSet(
|
||||
chat: SupergroupChat,
|
||||
stickerSetName: StickerSetName
|
||||
) = setChatStickerSet(chat.id, stickerSetName)
|
@@ -0,0 +1,60 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.LiveLocation.EditChatMessageLiveLocation
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageLiveLocation(
|
||||
chatId, messageId, latitude, longitude, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(chat.id, messageId, latitude, longitude, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
message: ContentMessage<LocationContent>,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(message.chat, message.messageId, latitude, longitude, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
location: Location,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageLiveLocation(
|
||||
chatId, messageId, location.latitude, location.longitude, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
location: Location,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(chat.id, messageId, location.latitude, location.longitude, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
message: ContentMessage<LocationContent>,
|
||||
location: Location,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(message.chat, message.messageId, location.latitude, location.longitude, replyMarkup)
|
@@ -0,0 +1,23 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.LiveLocation.EditInlineMessageLiveLocation
|
||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.Location
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditInlineMessageLiveLocation(
|
||||
inlineMessageId, latitude, longitude, replyMarkup
|
||||
)
|
||||
)
|
||||
suspend fun TelegramBot.editLiveLocation(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
location: Location,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editLiveLocation(inlineMessageId, location.latitude, location.longitude, replyMarkup)
|
@@ -0,0 +1,31 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.LiveLocation.StopChatMessageLiveLocation
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||
|
||||
suspend fun TelegramBot.stopLiveLocation(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
StopChatMessageLiveLocation(
|
||||
chatId, messageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.stopLiveLocation(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopLiveLocation(chat.id, messageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.stopLiveLocation(
|
||||
message: ContentMessage<LocationContent>,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = stopLiveLocation(message.chat, message.messageId, replyMarkup)
|
@@ -0,0 +1,15 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.LiveLocation.StopInlineMessageLiveLocation
|
||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
suspend fun TelegramBot.stopLiveLocation(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
StopInlineMessageLiveLocation(
|
||||
inlineMessageId, replyMarkup
|
||||
)
|
||||
)
|
@@ -0,0 +1,29 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.ReplyMarkup
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.ReplyMarkup.EditChatMessageReplyMarkup
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageReplyMarkup(chatId, messageId, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(chat.id, messageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||
message: Message,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageReplyMarkup(message.chat.id, message.messageId, replyMarkup)
|
||||
|
@@ -0,0 +1,11 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.ReplyMarkup
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.ReplyMarkup.EditInlineMessageReplyMarkup
|
||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(EditInlineMessageReplyMarkup(inlineMessageId, replyMarkup))
|
@@ -0,0 +1,39 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.caption
|
||||
|
||||
import dev.inmo.tgbotapi.CommonAbstracts.CaptionedInput
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.caption.EditChatMessageCaption
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
|
||||
suspend fun TelegramBot.editMessageCaption(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageCaption(chatId, messageId, text, parseMode, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.editMessageCaption(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageCaption(chat.id, messageId, text, parseMode, replyMarkup)
|
||||
|
||||
suspend fun <T> TelegramBot.editMessageCaption(
|
||||
message: ContentMessage<T>,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
): ContentMessage<MediaContent> where T : CaptionedInput, T : MediaContent {
|
||||
return editMessageCaption(message.chat.id, message.messageId, text, parseMode, replyMarkup)
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.caption
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.caption.EditInlineMessageCaption
|
||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
suspend fun TelegramBot.editMessageCaption(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(EditInlineMessageCaption(inlineMessageId, text, parseMode, replyMarkup))
|
@@ -0,0 +1,33 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.media
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.media.EditChatMessageMedia
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.InputMedia.InputMedia
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
||||
|
||||
suspend fun TelegramBot.editMessageMedia(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
media: InputMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageMedia(chatId, messageId, media, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.editMessageMedia(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
media: InputMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageMedia(chat.id, messageId, media, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.editMessageMedia(
|
||||
message: ContentMessage<out MediaContent>,
|
||||
media: InputMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageMedia(message.chat.id, message.messageId, media, replyMarkup)
|
@@ -0,0 +1,13 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.media
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.media.EditInlineMessageMedia
|
||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.InputMedia.InputMedia
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
suspend fun TelegramBot.editMessageCaption(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
media: InputMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(EditInlineMessageMedia(inlineMessageId, media, replyMarkup))
|
@@ -0,0 +1,39 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.text
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.text.EditChatMessageText
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(chat.id, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: ContentMessage<TextContent>,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
@@ -0,0 +1,15 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.edit.text
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.text.EditInlineMessageText
|
||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, disableWebPagePreview, replyMarkup))
|
@@ -0,0 +1,54 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.games
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.games.GetGameHighScoresByChat
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.GameContent
|
||||
|
||||
suspend fun TelegramBot.getGameScore(
|
||||
userId: UserId,
|
||||
chatId: ChatId,
|
||||
messageId: MessageIdentifier
|
||||
) = execute(
|
||||
GetGameHighScoresByChat(userId, chatId, messageId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getGameScore(
|
||||
user: CommonUser,
|
||||
chatId: ChatId,
|
||||
messageId: MessageIdentifier
|
||||
) = getGameScore(
|
||||
user.id, chatId, messageId
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getGameScore(
|
||||
userId: UserId,
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier
|
||||
) = getGameScore(
|
||||
userId, chat.id, messageId
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getGameScore(
|
||||
user: CommonUser,
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier
|
||||
) = getGameScore(
|
||||
user.id, chat.id, messageId
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getGameScore(
|
||||
userId: UserId,
|
||||
message: ContentMessage<GameContent>
|
||||
) = getGameScore(
|
||||
userId, message.chat.id, message.messageId
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getGameScore(
|
||||
user: CommonUser,
|
||||
message: ContentMessage<GameContent>
|
||||
) = getGameScore(
|
||||
user.id, message.chat.id, message.messageId
|
||||
)
|
@@ -0,0 +1,19 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.games
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.games.GetGameHighScoresByInlineMessageId
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
|
||||
suspend fun TelegramBot.getGameScore(
|
||||
userId: UserId,
|
||||
inlineMessageId: InlineMessageIdentifier
|
||||
) = execute(
|
||||
GetGameHighScoresByInlineMessageId(
|
||||
userId, inlineMessageId
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getGameScore(
|
||||
user: CommonUser,
|
||||
inlineMessageId: InlineMessageIdentifier
|
||||
) = getGameScore(user.id, inlineMessageId)
|
@@ -0,0 +1,72 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.games
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.games.SetGameScoreByChatId
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||
import dev.inmo.tgbotapi.types.message.content.GameContent
|
||||
|
||||
suspend fun TelegramBot.setGameScore(
|
||||
userId: UserId,
|
||||
score: Long,
|
||||
chatId: ChatId,
|
||||
messageId: MessageIdentifier,
|
||||
force: Boolean = false,
|
||||
disableEditMessage: Boolean = false
|
||||
) = execute(
|
||||
SetGameScoreByChatId(userId, score, chatId, messageId, force, disableEditMessage)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setGameScore(
|
||||
user: CommonUser,
|
||||
score: Long,
|
||||
chatId: ChatId,
|
||||
messageId: MessageIdentifier,
|
||||
force: Boolean = false,
|
||||
disableEditMessage: Boolean = false
|
||||
) = setGameScore(
|
||||
user.id, score, chatId, messageId, force, disableEditMessage
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setGameScore(
|
||||
userId: UserId,
|
||||
score: Long,
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
force: Boolean = false,
|
||||
disableEditMessage: Boolean = false
|
||||
) = setGameScore(
|
||||
userId, score, chat.id, messageId, force, disableEditMessage
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setGameScore(
|
||||
user: CommonUser,
|
||||
score: Long,
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
force: Boolean = false,
|
||||
disableEditMessage: Boolean = false
|
||||
) = setGameScore(
|
||||
user.id, score, chat.id, messageId, force, disableEditMessage
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setGameScore(
|
||||
userId: UserId,
|
||||
score: Long,
|
||||
message: ContentMessage<GameContent>,
|
||||
force: Boolean = false,
|
||||
disableEditMessage: Boolean = false
|
||||
) = setGameScore(
|
||||
userId, score, message.chat.id, message.messageId, force, disableEditMessage
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setGameScore(
|
||||
user: CommonUser,
|
||||
score: Long,
|
||||
message: ContentMessage<GameContent>,
|
||||
force: Boolean = false,
|
||||
disableEditMessage: Boolean = false
|
||||
) = setGameScore(
|
||||
user.id, score, message.chat.id, message.messageId, force, disableEditMessage
|
||||
)
|
@@ -0,0 +1,25 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.games
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.games.SetGameScoreByInlineMessageId
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
|
||||
suspend fun TelegramBot.setGameScore(
|
||||
userId: UserId,
|
||||
score: Long,
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
force: Boolean = false,
|
||||
disableEditMessage: Boolean = false
|
||||
) = execute(
|
||||
SetGameScoreByInlineMessageId(
|
||||
userId, score, inlineMessageId, force, disableEditMessage
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setGameScore(
|
||||
user: CommonUser,
|
||||
score: Long,
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
force: Boolean = false,
|
||||
disableEditMessage: Boolean = false
|
||||
) = setGameScore(user.id, score, inlineMessageId, force, disableEditMessage)
|
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.get
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.get.GetFile
|
||||
import dev.inmo.tgbotapi.types.files.abstracts.TelegramMediaFile
|
||||
|
||||
suspend fun TelegramBot.getFileAdditionalInfo(
|
||||
fileId: FileId
|
||||
) = execute(
|
||||
GetFile(fileId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getFileAdditionalInfo(
|
||||
file: TelegramMediaFile
|
||||
) = getFileAdditionalInfo(file.fileId)
|
@@ -0,0 +1,17 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.get
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.get.GetStickerSet
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
|
||||
suspend fun TelegramBot.getStickerSet(
|
||||
name: String
|
||||
) = execute(
|
||||
GetStickerSet(name)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getStickerSet(
|
||||
sticker: Sticker
|
||||
) = getStickerSet(
|
||||
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
|
||||
)
|
@@ -0,0 +1,22 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.get
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.get.GetUserProfilePhotos
|
||||
import dev.inmo.tgbotapi.types.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
|
||||
suspend fun TelegramBot.getUserProfilePhotos(
|
||||
userId: UserId,
|
||||
offset: Int? = null,
|
||||
limit: Int? = null
|
||||
) = execute(
|
||||
GetUserProfilePhotos(
|
||||
userId, offset, limit
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getUserProfilePhotos(
|
||||
user: CommonUser,
|
||||
offset: Int? = null,
|
||||
limit: Int? = null
|
||||
) = getUserProfilePhotos(user.id, offset, limit)
|
@@ -0,0 +1,102 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.SendAction
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.actions.*
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
|
||||
suspend fun TelegramBot.sendBotAction(
|
||||
chatId: ChatIdentifier,
|
||||
action: BotAction
|
||||
) = execute(
|
||||
SendAction(chatId, action)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendBotAction(
|
||||
chat: Chat,
|
||||
action: BotAction
|
||||
) = sendBotAction(chat.id, action)
|
||||
|
||||
|
||||
suspend fun TelegramBot.sendActionTyping(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, TypingAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadPhoto(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadPhotoAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionRecordVideo(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, RecordVideoAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadVideo(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadVideoAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionRecordAudio(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, RecordAudioAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadAudio(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadAudioAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadDocument(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadDocumentAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionFindLocation(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, FindLocationAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionRecordVideoNote(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, RecordVideoNoteAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadVideoNote(
|
||||
chatId: ChatIdentifier
|
||||
) = sendBotAction(chatId, UploadVideoNoteAction)
|
||||
|
||||
|
||||
suspend fun TelegramBot.sendActionTyping(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, TypingAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadPhoto(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadPhotoAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionRecordVideo(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, RecordVideoAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadVideo(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadVideoAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionRecordAudio(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, RecordAudioAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadAudio(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadAudioAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadDocument(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadDocumentAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionFindLocation(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, FindLocationAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionRecordVideoNote(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, RecordVideoNoteAction)
|
||||
|
||||
suspend fun TelegramBot.sendActionUploadVideoNote(
|
||||
chat: Chat
|
||||
) = sendBotAction(chat, UploadVideoNoteAction)
|
||||
|
@@ -0,0 +1,86 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.SendContact
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.sendContact(
|
||||
chatId: ChatIdentifier,
|
||||
phoneNumber: String,
|
||||
firstName: String,
|
||||
lastName: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendContact(
|
||||
chatId, phoneNumber, firstName, lastName, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendContact(
|
||||
chatId: ChatIdentifier,
|
||||
contact: Contact,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendContact(
|
||||
chatId, contact, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendContact(
|
||||
chat: Chat,
|
||||
phoneNumber: String,
|
||||
firstName: String,
|
||||
lastName: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendContact(
|
||||
chat.id, phoneNumber, firstName, lastName, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendContact(
|
||||
chat: Chat,
|
||||
contact: Contact,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendContact(
|
||||
chat.id, contact, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
phoneNumber: String,
|
||||
firstName: String,
|
||||
lastName: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendContact(
|
||||
to.chat,
|
||||
phoneNumber,
|
||||
firstName,
|
||||
lastName,
|
||||
disableNotification,
|
||||
to.messageId,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
contact: Contact,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendContact(
|
||||
to.chat,
|
||||
contact,
|
||||
disableNotification,
|
||||
to.messageId,
|
||||
replyMarkup
|
||||
)
|
@@ -0,0 +1,35 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.SendDice
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.dice.DiceAnimationType
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.sendDice(
|
||||
chatId: ChatIdentifier,
|
||||
animationType: DiceAnimationType? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendDice(chatId, animationType, disableNotification, replyToMessageId, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendDice(
|
||||
chat: Chat,
|
||||
animationType: DiceAnimationType? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendDice(chat.id, animationType, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
animationType: DiceAnimationType? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendDice(to.chat, animationType, disableNotification, to.messageId, replyMarkup)
|
@@ -0,0 +1,100 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.SendLocation
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chatId: ChatIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendLocation(
|
||||
chatId,
|
||||
latitude,
|
||||
longitude,
|
||||
disableNotification = disableNotification,
|
||||
replyToMessageId = replyToMessageId,
|
||||
replyMarkup = replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chatId: ChatIdentifier,
|
||||
location: Location,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(
|
||||
chatId,
|
||||
location.latitude,
|
||||
location.longitude,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chat: Chat,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(
|
||||
chat.id,
|
||||
latitude,
|
||||
longitude,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendLocation(
|
||||
chat: Chat,
|
||||
location: Location,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(
|
||||
chat.id,
|
||||
location.latitude,
|
||||
location.longitude,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(
|
||||
to.chat,
|
||||
latitude,
|
||||
longitude,
|
||||
disableNotification,
|
||||
to.messageId,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
location: Location,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendLocation(
|
||||
to.chat,
|
||||
location,
|
||||
disableNotification,
|
||||
to.messageId,
|
||||
replyMarkup
|
||||
)
|
@@ -0,0 +1,72 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.SendTextMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.sendMessage(
|
||||
chatId: ChatIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendTextMessage(chatId, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendTextMessage(
|
||||
chatId: ChatIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendMessage(
|
||||
chatId, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendMessage(
|
||||
chat: Chat,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
|
||||
suspend fun TelegramBot.sendTextMessage(
|
||||
chat: Chat,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendTextMessage(
|
||||
to.chat,
|
||||
text,
|
||||
parseMode,
|
||||
disableWebPagePreview,
|
||||
disableNotification,
|
||||
to.messageId,
|
||||
replyMarkup
|
||||
)
|
@@ -0,0 +1,121 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.SendVenue
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.venue.Venue
|
||||
|
||||
suspend fun TelegramBot.sendVenue(
|
||||
chatId: ChatIdentifier,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
title: String,
|
||||
address: String,
|
||||
foursquareId: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendVenue(
|
||||
chatId, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendVenue(
|
||||
chat: Chat,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
title: String,
|
||||
address: String,
|
||||
foursquareId: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVenue(
|
||||
chat.id, latitude, longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendVenue(
|
||||
chatId: ChatIdentifier,
|
||||
location: Location,
|
||||
title: String,
|
||||
address: String,
|
||||
foursquareId: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVenue(
|
||||
chatId, location.latitude, location.longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendVenue(
|
||||
chat: Chat,
|
||||
location: Location,
|
||||
title: String,
|
||||
address: String,
|
||||
foursquareId: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVenue(
|
||||
chat.id, location.latitude, location.longitude, title, address, foursquareId, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendVenue(
|
||||
chatId: ChatIdentifier,
|
||||
venue: Venue,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendVenue(
|
||||
chatId, venue, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendVenue(
|
||||
chat: Chat,
|
||||
venue: Venue,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVenue(
|
||||
chat.id, venue, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
title: String,
|
||||
address: String,
|
||||
foursquareId: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVenue(
|
||||
to.chat, latitude, longitude, title, address, foursquareId, disableNotification, to.messageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
location: Location,
|
||||
title: String,
|
||||
address: String,
|
||||
foursquareId: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVenue(
|
||||
to.chat, location, title, address, foursquareId, disableNotification, to.messageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
venue: Venue,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVenue(
|
||||
to.chat, venue, disableNotification, to.messageId, replyMarkup
|
||||
)
|
@@ -0,0 +1,77 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send.games
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.games.SendGame
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.games.Game
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.sendGame(
|
||||
chatId: ChatIdentifier,
|
||||
gameShortName: String,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendGame(
|
||||
chatId, gameShortName, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendGame(
|
||||
chat: Chat,
|
||||
gameShortName: String,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendGame(
|
||||
chat.id, gameShortName, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendGame(
|
||||
chatId: ChatIdentifier,
|
||||
game: Game,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendGame(
|
||||
chatId, game.title, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendGame(
|
||||
chat: Chat,
|
||||
game: Game,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendGame(
|
||||
chat.id, game.title, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithGame(
|
||||
to: Message,
|
||||
gameShortName: String,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendGame(
|
||||
to.chat, gameShortName, disableNotification, to.messageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithGame(
|
||||
to: Message,
|
||||
game: Game,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendGame(
|
||||
to.chat, game.title, disableNotification, to.messageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
game: Game,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = replyWithGame(to, game, disableNotification, replyMarkup)
|
@@ -0,0 +1,131 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendAnimation
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.files.AnimationFile
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.sendAnimation(
|
||||
chatId: ChatIdentifier,
|
||||
animation: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendAnimation(
|
||||
chatId,
|
||||
animation,
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendAnimation(
|
||||
chatId: ChatIdentifier,
|
||||
animation: AnimationFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(
|
||||
chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendAnimation(
|
||||
chat: Chat,
|
||||
animation: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(chat.id, animation, thumb, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.sendAnimation(
|
||||
chat: Chat,
|
||||
animation: AnimationFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(chat.id, animation, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithAnimation(
|
||||
to: Message,
|
||||
animation: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(
|
||||
to.chat,
|
||||
animation,
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
disableNotification,
|
||||
to.messageId,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithAnimation(
|
||||
to: Message,
|
||||
animation: AnimationFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(to.chat, animation, text, parseMode, duration, width, height, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
animation: AnimationFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = replyWithAnimation(to, animation, text, parseMode, duration, width, height, disableNotification, replyMarkup)
|
@@ -0,0 +1,110 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendAudio
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.files.AnimationFile
|
||||
import dev.inmo.tgbotapi.types.files.AudioFile
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.sendAudio(
|
||||
chatId: ChatIdentifier,
|
||||
audio: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
performer: String? = null,
|
||||
title: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendAudio(
|
||||
chatId,
|
||||
audio,
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
duration,
|
||||
performer,
|
||||
title,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendAudio(
|
||||
chat: Chat,
|
||||
audio: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
performer: String? = null,
|
||||
title: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAudio(chat.id, audio, thumb, text, parseMode, duration, performer, title, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.sendAudio(
|
||||
chatId: ChatIdentifier,
|
||||
audio: AudioFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
title: String? = audio.title,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.sendAudio(
|
||||
chat: Chat,
|
||||
audio: AudioFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
title: String? = audio.title,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAudio(chat.id, audio, text, parseMode, title, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithAudio(
|
||||
to: Message,
|
||||
audio: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
performer: String? = null,
|
||||
title: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithAudio(
|
||||
to: Message,
|
||||
audio: AudioFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
title: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAudio(to.chat, audio, text, parseMode, title, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
audio: AudioFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
title: String? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = replyWithAudio(to, audio, text, parseMode, title, disableNotification, replyMarkup)
|
@@ -0,0 +1,95 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendDocument
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.files.DocumentFile
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.sendDocument(
|
||||
chatId: ChatIdentifier,
|
||||
document: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendDocument(
|
||||
chatId,
|
||||
document,
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendDocument(
|
||||
chat: Chat,
|
||||
document: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendDocument(chat.id, document, thumb, text, parseMode, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.sendDocument(
|
||||
chatId: ChatIdentifier,
|
||||
document: DocumentFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendDocument(
|
||||
chatId, document.fileId, document.thumb ?.fileId, text, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendDocument(
|
||||
chat: Chat,
|
||||
document: DocumentFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendDocument(chat.id, document, text, parseMode, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithDocument(
|
||||
to: Message,
|
||||
document: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendDocument(to.chat, document, thumb, text, parseMode, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithDocument(
|
||||
to: Message,
|
||||
document: DocumentFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendDocument(to.chat, document, text, parseMode, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
document: DocumentFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = replyWithDocument(to, document, text, parseMode, disableNotification, replyMarkup)
|
@@ -0,0 +1,41 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendMediaGroup
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.InputMedia.MediaGroupMemberInputMedia
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.sendMediaGroup(
|
||||
chatId: ChatIdentifier,
|
||||
media: List<MediaGroupMemberInputMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null
|
||||
) = execute(
|
||||
SendMediaGroup(
|
||||
chatId, media, disableNotification, replyToMessageId
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendMediaGroup(
|
||||
chat: Chat,
|
||||
media: List<MediaGroupMemberInputMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null
|
||||
) = sendMediaGroup(
|
||||
chat.id, media, disableNotification, replyToMessageId
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithMediaGroup(
|
||||
to: Message,
|
||||
media: List<MediaGroupMemberInputMedia>,
|
||||
disableNotification: Boolean = false
|
||||
) = sendMediaGroup(to.chat, media, disableNotification, to.messageId)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
media: List<MediaGroupMemberInputMedia>,
|
||||
disableNotification: Boolean = false
|
||||
) = replyWithMediaGroup(to, media, disableNotification)
|
@@ -0,0 +1,90 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendPhoto
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.files.Photo
|
||||
import dev.inmo.tgbotapi.types.files.biggest
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.sendPhoto(
|
||||
chatId: ChatIdentifier,
|
||||
fileId: InputFile,
|
||||
caption: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendPhoto(
|
||||
chatId,
|
||||
fileId,
|
||||
caption,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendPhoto(
|
||||
chat: Chat,
|
||||
fileId: InputFile,
|
||||
caption: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat.id, fileId, caption, parseMode, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.sendPhoto(
|
||||
chatId: ChatIdentifier,
|
||||
photo: Photo,
|
||||
caption: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), caption, parseMode, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.sendPhoto(
|
||||
chat: Chat,
|
||||
photo: Photo,
|
||||
caption: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(chat.id, photo, caption, parseMode, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithPhoto(
|
||||
to: Message,
|
||||
fileId: InputFile,
|
||||
caption: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(to.chat, fileId, caption, parseMode, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithPhoto(
|
||||
to: Message,
|
||||
photo: Photo,
|
||||
caption: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(to.chat, photo, caption, parseMode, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
photo: Photo,
|
||||
caption: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = replyWithPhoto(to, photo, caption, parseMode, disableNotification, replyMarkup)
|
@@ -0,0 +1,66 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendSticker
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.sendSticker(
|
||||
chatId: ChatIdentifier,
|
||||
sticker: InputFile,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendSticker(chatId, sticker, disableNotification, replyToMessageId, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendSticker(
|
||||
chat: Chat,
|
||||
sticker: InputFile,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(chat.id, sticker, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.sendSticker(
|
||||
chatId: ChatIdentifier,
|
||||
sticker: Sticker,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(chatId, sticker.fileId, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.sendSticker(
|
||||
chat: Chat,
|
||||
sticker: Sticker,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(chat, sticker.fileId, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithSticker(
|
||||
to: Message,
|
||||
sticker: InputFile,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(to.chat, sticker, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithSticker(
|
||||
to: Message,
|
||||
sticker: Sticker,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(to.chat, sticker, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
sticker: Sticker,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = replyWithSticker(to, sticker, disableNotification, replyMarkup)
|
@@ -0,0 +1,107 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendVideo
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.files.VideoFile
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.sendVideo(
|
||||
chatId: ChatIdentifier,
|
||||
video: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendVideo(
|
||||
chatId,
|
||||
video,
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
null,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendVideo(
|
||||
chatId: ChatIdentifier,
|
||||
video: VideoFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.sendVideo(
|
||||
chat: Chat,
|
||||
video: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chat.id, video, thumb, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
|
||||
suspend fun TelegramBot.sendVideo(
|
||||
chat: Chat,
|
||||
video: VideoFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(chat.id, video, text, parseMode, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithVideo(
|
||||
to: Message,
|
||||
video: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(to.chat, video, thumb, text, parseMode, duration, width, height, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithVideo(
|
||||
to: Message,
|
||||
video: VideoFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(to.chat, video, text, parseMode, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
video: VideoFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = replyWithVideo(to, video, text, parseMode, disableNotification, replyMarkup)
|
@@ -0,0 +1,104 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendVideoNote
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.files.VideoFile
|
||||
import dev.inmo.tgbotapi.types.files.VideoNoteFile
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.sendVideoNote(
|
||||
chatId: ChatIdentifier,
|
||||
videoNote: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
size: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendVideoNote(
|
||||
chatId,
|
||||
videoNote,
|
||||
thumb,
|
||||
text,
|
||||
parseMode,
|
||||
duration,
|
||||
size,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendVideoNote(
|
||||
chatId: ChatIdentifier,
|
||||
videoNote: VideoNoteFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideoNote(
|
||||
chatId, videoNote.fileId, videoNote.thumb ?.fileId, text, parseMode, videoNote.duration, videoNote.width, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendVideoNote(
|
||||
chat: Chat,
|
||||
videoNote: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
size: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideoNote(chat.id, videoNote, thumb, text, parseMode, duration, size, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.sendVideoNote(
|
||||
chat: Chat,
|
||||
videoNote: VideoNoteFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideoNote(chat.id, videoNote, text, parseMode, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithVideoNote(
|
||||
to: Message,
|
||||
videoNote: InputFile,
|
||||
thumb: InputFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
size: Int? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideoNote(to.chat, videoNote, thumb, text, parseMode, duration, size, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithVideoNote(
|
||||
to: Message,
|
||||
videoNote: VideoNoteFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideoNote(to.chat, videoNote, text, parseMode, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
videoNote: VideoNoteFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = replyWithVideoNote(to, videoNote, text, parseMode, disableNotification, replyMarkup)
|
@@ -0,0 +1,96 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send.media
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||
import dev.inmo.tgbotapi.requests.send.media.SendVoice
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.files.AudioFile
|
||||
import dev.inmo.tgbotapi.types.files.VoiceFile
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.sendVoice(
|
||||
chatId: ChatIdentifier,
|
||||
voice: InputFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendVoice(
|
||||
chatId,
|
||||
voice,
|
||||
text,
|
||||
parseMode,
|
||||
duration,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendVoice(
|
||||
chat: Chat,
|
||||
voice: InputFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(chat.id, voice, text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.sendVoice(
|
||||
chatId: ChatIdentifier,
|
||||
voice: VoiceFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(
|
||||
chatId, voice.fileId, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendVoice(
|
||||
chat: Chat,
|
||||
voice: VoiceFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(chat.id, voice, text, parseMode, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithVoice(
|
||||
to: Message,
|
||||
voice: InputFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(to.chat, voice, text, parseMode, duration, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithVoice(
|
||||
to: Message,
|
||||
voice: VoiceFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(to.chat, voice, text, parseMode, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
voice: VoiceFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = replyWithVoice(to, voice, text, parseMode, disableNotification, replyMarkup)
|
@@ -0,0 +1,76 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send.payments
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.payments.SendInvoice
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.payments.LabeledPrice
|
||||
import dev.inmo.tgbotapi.types.payments.abstracts.Currency
|
||||
|
||||
suspend fun TelegramBot.sendInvoice(
|
||||
chatId: ChatId,
|
||||
title: String,
|
||||
description: String,
|
||||
payload: String,
|
||||
providerToken: String,
|
||||
startParameter: StartParameter,
|
||||
currency: Currency,
|
||||
prices: List<LabeledPrice>,
|
||||
providerData: String? = null,
|
||||
requireName: Boolean = false,
|
||||
requirePhoneNumber: Boolean = false,
|
||||
requireEmail: Boolean = false,
|
||||
requireShippingAddress: Boolean = false,
|
||||
shouldSendPhoneNumberToProvider: Boolean = false,
|
||||
shouldSendEmailToProvider: Boolean = false,
|
||||
priceDependOnShipAddress: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendInvoice(chatId, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, replyMarkup)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendInvoice(
|
||||
user: CommonUser,
|
||||
title: String,
|
||||
description: String,
|
||||
payload: String,
|
||||
providerToken: String,
|
||||
startParameter: StartParameter,
|
||||
currency: Currency,
|
||||
prices: List<LabeledPrice>,
|
||||
providerData: String? = null,
|
||||
requireName: Boolean = false,
|
||||
requirePhoneNumber: Boolean = false,
|
||||
requireEmail: Boolean = false,
|
||||
requireShippingAddress: Boolean = false,
|
||||
shouldSendPhoneNumberToProvider: Boolean = false,
|
||||
shouldSendEmailToProvider: Boolean = false,
|
||||
priceDependOnShipAddress: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = sendInvoice(user.id, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithInvoice(
|
||||
to: Message,
|
||||
title: String,
|
||||
description: String,
|
||||
payload: String,
|
||||
providerToken: String,
|
||||
startParameter: StartParameter,
|
||||
currency: Currency,
|
||||
prices: List<LabeledPrice>,
|
||||
providerData: String? = null,
|
||||
requireName: Boolean = false,
|
||||
requirePhoneNumber: Boolean = false,
|
||||
requireEmail: Boolean = false,
|
||||
requireShippingAddress: Boolean = false,
|
||||
shouldSendPhoneNumberToProvider: Boolean = false,
|
||||
shouldSendEmailToProvider: Boolean = false,
|
||||
priceDependOnShipAddress: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = sendInvoice(to.chat.id, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, to.messageId, replyMarkup)
|
@@ -0,0 +1,201 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send.polls
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.polls.SendQuizPoll
|
||||
import dev.inmo.tgbotapi.requests.send.polls.SendRegularPoll
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.chat.abstracts.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.polls.*
|
||||
|
||||
suspend fun TelegramBot.sendRegularPoll(
|
||||
chatId: ChatIdentifier,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
allowMultipleAnswers: Boolean = false,
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendRegularPoll(
|
||||
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
suspend fun TelegramBot.sendRegularPoll(
|
||||
chatId: ChatIdentifier,
|
||||
poll: RegularPoll,
|
||||
isClosed: Boolean = false,
|
||||
question: String = poll.question,
|
||||
options: List<String> = poll.options.map { it.text },
|
||||
isAnonymous: Boolean = poll.isAnonymous,
|
||||
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
suspend fun TelegramBot.sendRegularPoll(
|
||||
chat: Chat,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
allowMultipleAnswers: Boolean = false,
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendRegularPoll(
|
||||
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendRegularPoll(
|
||||
chat: Chat,
|
||||
poll: RegularPoll,
|
||||
isClosed: Boolean = false,
|
||||
question: String = poll.question,
|
||||
options: List<String> = poll.options.map { it.text },
|
||||
isAnonymous: Boolean = poll.isAnonymous,
|
||||
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendRegularPoll(
|
||||
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
|
||||
suspend fun TelegramBot.sendQuizPoll(
|
||||
chatId: ChatIdentifier,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
correctOptionId: Int,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
explanation: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendQuizPoll(
|
||||
chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendQuizPoll(
|
||||
chat: Chat,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
correctOptionId: Int,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
explanation: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(
|
||||
chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendQuizPoll(
|
||||
chatId: ChatIdentifier,
|
||||
isClosed: Boolean = false,
|
||||
quizPoll: QuizPoll,
|
||||
question: String = quizPoll.question,
|
||||
options: List<String> = quizPoll.options.map { it.text },
|
||||
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
||||
isAnonymous: Boolean = quizPoll.isAnonymous,
|
||||
explanation: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(
|
||||
chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.sendQuizPoll(
|
||||
chat: Chat,
|
||||
isClosed: Boolean = false,
|
||||
quizPoll: QuizPoll,
|
||||
question: String = quizPoll.question,
|
||||
options: List<String> = quizPoll.options.map { it.text },
|
||||
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
||||
isAnonymous: Boolean = quizPoll.isAnonymous,
|
||||
explanation: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(
|
||||
chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithRegularPoll(
|
||||
to: Message,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
allowMultipleAnswers: Boolean = false,
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendRegularPoll(to.chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithRegularPoll(
|
||||
to: Message,
|
||||
poll: RegularPoll,
|
||||
isClosed: Boolean = false,
|
||||
question: String = poll.question,
|
||||
options: List<String> = poll.options.map { it.text },
|
||||
isAnonymous: Boolean = poll.isAnonymous,
|
||||
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendRegularPoll(to.chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithQuizPoll(
|
||||
to: Message,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
correctOptionId: Int,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
explanation: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, to.messageId, replyMarkup)
|
||||
|
||||
suspend inline fun TelegramBot.replyWithQuizPoll(
|
||||
to: Message,
|
||||
isClosed: Boolean = false,
|
||||
quizPoll: QuizPoll,
|
||||
question: String = quizPoll.question,
|
||||
options: List<String> = quizPoll.options.map { it.text },
|
||||
correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"),
|
||||
isAnonymous: Boolean = quizPoll.isAnonymous,
|
||||
explanation: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
closeInfo: ScheduledCloseInfo? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, disableNotification, to.messageId, replyMarkup)
|
||||
|
@@ -0,0 +1,90 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stickers.AddAnimatedStickerToSet
|
||||
import dev.inmo.tgbotapi.types.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
AddAnimatedStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
AddAnimatedStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSetName: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addAnimatedStickerToSet(
|
||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSetName: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addAnimatedStickerToSet(
|
||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addAnimatedStickerToSet(
|
||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addAnimatedStickerToSet(
|
||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addAnimatedStickerToSet(
|
||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addAnimatedStickerToSet(
|
||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
@@ -0,0 +1,90 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stickers.AddStaticStickerToSet
|
||||
import dev.inmo.tgbotapi.types.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
AddStaticStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
AddStaticStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSetName: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStaticStickerToSet(
|
||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSetName: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStaticStickerToSet(
|
||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStaticStickerToSet(
|
||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStaticStickerToSet(
|
||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStaticStickerToSet(
|
||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.addStaticStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStaticStickerToSet(
|
||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
@@ -0,0 +1,54 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stickers.CreateNewAnimatedStickerSet
|
||||
import dev.inmo.tgbotapi.types.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
|
||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewAnimatedStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewAnimatedStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
|
||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewAnimatedStickerSet(
|
||||
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewAnimatedStickerSet(
|
||||
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
@@ -0,0 +1,54 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stickers.CreateNewStaticStickerSet
|
||||
import dev.inmo.tgbotapi.types.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||
|
||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewStaticStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
||||
userId: UserId,
|
||||
name: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CreateNewStaticStickerSet(userId, name, sticker, emojis, containsMasks, maskPosition)
|
||||
)
|
||||
|
||||
|
||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewStaticStickerSet(
|
||||
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
||||
user: CommonUser,
|
||||
name: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
containsMasks: Boolean? = null,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = createNewStaticStickerSet(
|
||||
user.id, name, sticker, emojis, containsMasks, maskPosition
|
||||
)
|
@@ -0,0 +1,20 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.stickers.DeleteStickerFromSet
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
|
||||
suspend fun TelegramBot.deleteStickerFromSet(
|
||||
sticker: FileId
|
||||
) = execute(
|
||||
DeleteStickerFromSet(
|
||||
sticker
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.deleteStickerFromSet(
|
||||
sticker: Sticker
|
||||
) = deleteStickerFromSet(
|
||||
sticker.fileId
|
||||
)
|
@@ -0,0 +1,24 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
|
||||
suspend fun TelegramBot.setStickerPositionInSet(
|
||||
sticker: FileId,
|
||||
position: Int
|
||||
) = execute(
|
||||
SetStickerPositionInSet(
|
||||
sticker,
|
||||
position
|
||||
)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerPositionInSet(
|
||||
sticker: Sticker,
|
||||
position: Int
|
||||
) = setStickerPositionInSet(
|
||||
sticker.fileId,
|
||||
position
|
||||
)
|
@@ -0,0 +1,74 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.thumbs
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumb
|
||||
import dev.inmo.tgbotapi.types.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
userId: UserId,
|
||||
thumbSetName: String,
|
||||
thumb: FileId
|
||||
) = execute(
|
||||
SetStickerSetThumb(userId, thumbSetName, thumb)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
userId: UserId,
|
||||
thumbSetName: String,
|
||||
thumb: MultipartFile
|
||||
) = execute(
|
||||
SetStickerSetThumb(userId, thumbSetName, thumb)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
user: CommonUser,
|
||||
thumbSetName: String,
|
||||
thumb: FileId
|
||||
) = setStickerSetThumb(
|
||||
user.id, thumbSetName, thumb
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
user: CommonUser,
|
||||
thumbSetName: String,
|
||||
thumb: MultipartFile
|
||||
) = setStickerSetThumb(
|
||||
user.id, thumbSetName, thumb
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
userId: UserId,
|
||||
thumbSet: StickerSet,
|
||||
thumb: FileId
|
||||
) = setStickerSetThumb(
|
||||
userId, thumbSet.name, thumb
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
userId: UserId,
|
||||
thumbSet: StickerSet,
|
||||
thumb: MultipartFile
|
||||
) = setStickerSetThumb(
|
||||
userId, thumbSet.name, thumb
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
user: CommonUser,
|
||||
thumbSet: StickerSet,
|
||||
thumb: FileId
|
||||
) = setStickerSetThumb(
|
||||
user.id, thumbSet.name, thumb
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setStickerSetThumb(
|
||||
user: CommonUser,
|
||||
thumbSet: StickerSet,
|
||||
thumb: MultipartFile
|
||||
) = setStickerSetThumb(
|
||||
user.id, thumbSet.name, thumb
|
||||
)
|
||||
|
@@ -0,0 +1,21 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.stickers.UploadStickerFile
|
||||
import dev.inmo.tgbotapi.types.CommonUser
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
|
||||
suspend fun TelegramBot.uploadStickerFile(
|
||||
userId: UserId,
|
||||
sticker: MultipartFile
|
||||
) = execute(
|
||||
UploadStickerFile(userId, sticker)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.uploadStickerFile(
|
||||
user: CommonUser,
|
||||
sticker: MultipartFile
|
||||
) = execute(
|
||||
UploadStickerFile(user.id, sticker)
|
||||
)
|
@@ -0,0 +1,49 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.utils
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.api.InternalUtils.convertWithMediaGroupUpdates
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import dev.inmo.tgbotapi.updateshandlers.UpdateReceiver
|
||||
import dev.inmo.tgbotapi.utils.extensions.accumulateByKey
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* Create [UpdateReceiver] object which will correctly accumulate updates and send into output updates which INCLUDE
|
||||
* [dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MediaGroupUpdate]s.
|
||||
*
|
||||
* @see UpdateReceiver
|
||||
*/
|
||||
fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation(
|
||||
output: UpdateReceiver<Update>,
|
||||
mediaGroupsDebounceMillis: Long = 1000L
|
||||
): UpdateReceiver<Update> {
|
||||
val updatesChannel = Channel<Update>(Channel.UNLIMITED)
|
||||
val mediaGroupChannel = Channel<Pair<String, BaseMessageUpdate>>(Channel.UNLIMITED)
|
||||
val mediaGroupAccumulatedChannel = mediaGroupChannel.accumulateByKey(
|
||||
mediaGroupsDebounceMillis,
|
||||
scope = this
|
||||
)
|
||||
|
||||
launch {
|
||||
launch {
|
||||
for (update in updatesChannel) {
|
||||
when (val data = update.data) {
|
||||
is MediaGroupMessage -> mediaGroupChannel.send("${data.mediaGroupId}${update::class.simpleName}" to update as BaseMessageUpdate)
|
||||
else -> output(update)
|
||||
}
|
||||
}
|
||||
}
|
||||
launch {
|
||||
for ((_, mediaGroup) in mediaGroupAccumulatedChannel) {
|
||||
mediaGroup.convertWithMediaGroupUpdates().forEach {
|
||||
output(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { updatesChannel.send(it) }
|
||||
}
|
@@ -0,0 +1,6 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.webhook
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.webhook.DeleteWebhook
|
||||
|
||||
suspend fun TelegramBot.deleteWebhook() = execute(DeleteWebhook())
|
@@ -0,0 +1,6 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.webhook
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.webhook.GetWebhookInfo
|
||||
|
||||
suspend fun TelegramBot.getWebhookInfo() = execute(GetWebhookInfo())
|
@@ -0,0 +1,47 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.webhook
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||
import dev.inmo.tgbotapi.requests.webhook.SetWebhook
|
||||
|
||||
/**
|
||||
* Use this method to send information about webhook (like [url])
|
||||
*/
|
||||
suspend fun TelegramBot.setWebhookInfo(
|
||||
url: String,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null
|
||||
) = execute(
|
||||
SetWebhook(
|
||||
url, maxAllowedConnections, allowedUpdates
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* Use this method to send information about webhook (like [url] and [certificate])
|
||||
*/
|
||||
suspend fun TelegramBot.setWebhookInfo(
|
||||
url: String,
|
||||
certificate: FileId,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null
|
||||
) = execute(
|
||||
SetWebhook(
|
||||
url, certificate, maxAllowedConnections, allowedUpdates
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* Use this method to send information about webhook (like [url] and [certificate])
|
||||
*/
|
||||
suspend fun TelegramBot.setWebhookInfo(
|
||||
url: String,
|
||||
certificate: MultipartFile,
|
||||
maxAllowedConnections: Int? = null,
|
||||
allowedUpdates: List<String>? = null
|
||||
) = execute(
|
||||
SetWebhook(
|
||||
url, certificate, maxAllowedConnections, allowedUpdates
|
||||
)
|
||||
)
|
Reference in New Issue
Block a user