1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-09 09:53:47 +00:00

moving to an explicit API mode

refactored the rest 🌚
This commit is contained in:
bpavuk 2024-07-14 15:33:24 +03:00
parent f36373b718
commit 4085913bc3
No known key found for this signature in database
GPG Key ID: B501D26D9DEA9CFE
30 changed files with 224 additions and 214 deletions

View File

@ -12,7 +12,7 @@ import io.ktor.client.engine.*
* @param ktorClientEngine Engine like [io.ktor.client.engine.cio.CIO]
* @param ktorClientConfig Config block for preconfiguring of bot [HttpClient]
*/
data class BotBuilder internal constructor(
public data class BotBuilder internal constructor(
var proxy: ProxyConfig? = null,
var ktorClientEngineFactory: HttpClientEngineFactory<HttpClientEngineConfig>? = null,
var ktorClientConfig: (HttpClientConfig<*>.() -> Unit) ? = null
@ -37,12 +37,12 @@ data class BotBuilder internal constructor(
* @return Created by [telegramBotWithCustomClientConfig] function [TelegramBot]. This executor will be preconfigured using [token] and
* [block]
*/
fun buildBot(
public fun buildBot(
token: String,
apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
block: BotBuilder.() -> Unit
) = telegramBot(
): TelegramBot = telegramBot(
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
BotBuilder().apply(block).createHttpClient()
)

View File

@ -11,7 +11,7 @@ import io.ktor.client.engine.*
/**
* Allows to create bot using bot [urlsKeeper] and already prepared [client]
*/
fun telegramBot(
public fun telegramBot(
urlsKeeper: TelegramAPIUrlsKeeper,
client: HttpClient = HttpClient()
): TelegramBot = telegramBot(urlsKeeper) {
@ -23,11 +23,11 @@ fun telegramBot(
* configure it with [clientConfig]
*/
@Suppress("NOTHING_TO_INLINE")
inline fun <T: HttpClientEngineConfig> telegramBot(
public inline fun <T: HttpClientEngineConfig> telegramBot(
urlsKeeper: TelegramAPIUrlsKeeper,
clientFactory: HttpClientEngineFactory<T>,
noinline clientConfig: HttpClientConfig<T>.() -> Unit = {}
) = telegramBot(
): TelegramBot = telegramBot(
urlsKeeper,
HttpClient(clientFactory, clientConfig)
)
@ -37,11 +37,11 @@ inline fun <T: HttpClientEngineConfig> telegramBot(
* configure [HttpClient] using [clientConfig]
*/
@Suppress("NOTHING_TO_INLINE")
inline fun telegramBot(
public inline fun telegramBot(
urlsKeeper: TelegramAPIUrlsKeeper,
clientEngine: HttpClientEngine,
noinline clientConfig: HttpClientConfig<*>.() -> Unit = {}
) = telegramBot(
): TelegramBot = telegramBot(
urlsKeeper,
HttpClient(clientEngine, clientConfig)
)
@ -51,10 +51,10 @@ inline fun telegramBot(
* [clientConfig]
*/
@Suppress("NOTHING_TO_INLINE")
inline fun telegramBot(
public inline fun telegramBot(
urlsKeeper: TelegramAPIUrlsKeeper,
noinline clientConfig: HttpClientConfig<*>.() -> Unit
) = telegramBot(
): TelegramBot = telegramBot(
urlsKeeper,
HttpClient(clientConfig)
)
@ -63,7 +63,7 @@ inline fun telegramBot(
* Allows to create bot using bot [token], [apiUrl] (for custom api servers) and already prepared [client]
*/
@Suppress("NOTHING_TO_INLINE")
inline fun telegramBot(
public inline fun telegramBot(
token: String,
apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
@ -71,13 +71,13 @@ inline fun telegramBot(
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, testServer, apiUrl), client)
@Suppress("NOTHING_TO_INLINE")
inline fun <T: HttpClientEngineConfig> telegramBot(
public inline fun <T: HttpClientEngineConfig> telegramBot(
token: String,
clientFactory: HttpClientEngineFactory<T>,
apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
noinline clientConfig: HttpClientConfig<T>.() -> Unit = {}
) = telegramBot(
): TelegramBot = telegramBot(
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
clientFactory,
clientConfig
@ -88,13 +88,13 @@ inline fun <T: HttpClientEngineConfig> telegramBot(
* configure [HttpClient] using [clientConfig]
*/
@Suppress("NOTHING_TO_INLINE")
inline fun telegramBot(
public inline fun telegramBot(
token: String,
clientEngine: HttpClientEngine,
apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
noinline clientConfig: HttpClientConfig<*>.() -> Unit = {}
) = telegramBot(
): TelegramBot = telegramBot(
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
clientEngine,
clientConfig
@ -105,12 +105,12 @@ inline fun telegramBot(
* [clientConfig]
*/
@Suppress("NOTHING_TO_INLINE")
inline fun telegramBot(
public inline fun telegramBot(
token: String,
apiUrl: String = telegramBotAPIDefaultUrl,
testServer: Boolean = false,
noinline clientConfig: HttpClientConfig<*>.() -> Unit
) = telegramBot(
): TelegramBot = telegramBot(
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
clientConfig
)

View File

@ -4,4 +4,4 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.local.Close
@Suppress("unused")
suspend inline fun TelegramBot.close() = execute(Close)
public suspend inline fun TelegramBot.close(): Boolean = execute(Close)

View File

@ -9,19 +9,19 @@ import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.content.MediaGroupCollectionContent
suspend fun TelegramBot.deleteMessage(
public suspend fun TelegramBot.deleteMessage(
chatId: ChatIdentifier,
messageId: MessageId
) = execute(
): Boolean = execute(
DeleteMessage(chatId, messageId)
)
suspend fun TelegramBot.deleteMessage(
public suspend fun TelegramBot.deleteMessage(
chat: Chat,
messageId: MessageId
) = deleteMessage(chat.id, messageId)
): Boolean = deleteMessage(chat.id, messageId)
suspend fun TelegramBot.deleteMessage(
public suspend fun TelegramBot.deleteMessage(
message: AccessibleMessage
): Boolean {
val mediaGroupContent = ((message as? ContentMessage<*>) ?.content as? MediaGroupCollectionContent<*>)
@ -34,20 +34,20 @@ suspend fun TelegramBot.deleteMessage(
}
}
suspend fun TelegramBot.delete(
public suspend fun TelegramBot.delete(
chatId: ChatIdentifier,
messageId: MessageId
) = deleteMessage(chatId, messageId)
): Boolean = deleteMessage(chatId, messageId)
suspend fun TelegramBot.delete(
public suspend fun TelegramBot.delete(
chat: Chat,
messageId: MessageId
) = deleteMessage(chat, messageId)
): Boolean = deleteMessage(chat, messageId)
suspend fun TelegramBot.delete(
public suspend fun TelegramBot.delete(
message: AccessibleMessage
) = deleteMessage(message)
): Boolean = deleteMessage(message)
suspend fun AccessibleMessage.delete(
public suspend fun AccessibleMessage.delete(
requestsExecutor: TelegramBot
) = requestsExecutor.deleteMessage(this)
): Boolean = requestsExecutor.deleteMessage(this)

View File

@ -7,10 +7,10 @@ import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
import kotlin.jvm.JvmName
suspend fun TelegramBot.deleteMessages(
public suspend fun TelegramBot.deleteMessages(
chatId: ChatIdentifier,
messageIds: List<MessageId>
) = messageIds.chunked(deleteMessagesLimit.last).map {
): Boolean = messageIds.chunked(deleteMessagesLimit.last).map {
execute(
DeleteMessages(
chatId = chatId,
@ -19,17 +19,17 @@ suspend fun TelegramBot.deleteMessages(
)
}.all { it }
suspend fun TelegramBot.deleteMessages(
public suspend fun TelegramBot.deleteMessages(
chatId: ChatIdentifier,
messageIds: Array<MessageId>
) = deleteMessages(
): Boolean = deleteMessages(
chatId = chatId,
messageIds = messageIds.toList()
)
suspend fun TelegramBot.deleteMessages(
public suspend fun TelegramBot.deleteMessages(
messagesMetas: List<Message.MetaInfo>
) = messagesMetas.groupBy { it.chatId }.map { (chatId, messages) ->
): Boolean = messagesMetas.groupBy { it.chatId }.map { (chatId, messages) ->
deleteMessages(
chatId = chatId,
messageIds = messages.map { it.messageId }
@ -37,25 +37,25 @@ suspend fun TelegramBot.deleteMessages(
}.all { it }
@JvmName("deleteMessagesWithMessages")
suspend fun TelegramBot.deleteMessages(
public suspend fun TelegramBot.deleteMessages(
messages: List<AccessibleMessage>
) = deleteMessages(messages.map { it.metaInfo })
): Boolean = deleteMessages(messages.map { it.metaInfo })
suspend fun TelegramBot.delete(
public suspend fun TelegramBot.delete(
chatId: ChatIdentifier,
messageIds: List<MessageId>
) = deleteMessages(chatId = chatId, messageIds = messageIds)
): Boolean = deleteMessages(chatId = chatId, messageIds = messageIds)
suspend fun TelegramBot.delete(
public suspend fun TelegramBot.delete(
chatId: ChatIdentifier,
messageIds: Array<MessageId>
) = deleteMessages(chatId = chatId, messageIds = messageIds)
): Boolean = deleteMessages(chatId = chatId, messageIds = messageIds)
suspend fun TelegramBot.delete(
public suspend fun TelegramBot.delete(
messagesMetas: List<Message.MetaInfo>
) = deleteMessages(messagesMetas)
): Boolean = deleteMessages(messagesMetas)
@JvmName("deleteWithMessages")
suspend fun TelegramBot.delete(
public suspend fun TelegramBot.delete(
messages: List<AccessibleMessage>
) = deleteMessages(messages)
): Boolean = deleteMessages(messages)

View File

@ -7,58 +7,59 @@ import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage
import dev.inmo.tgbotapi.types.threadId
suspend fun TelegramBot.forwardMessage(
public suspend fun TelegramBot.forwardMessage(
fromChatId: ChatIdentifier,
toChatId: ChatIdentifier,
messageId: MessageId,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false
) = execute(
): PossiblyForwardedMessage = execute(
ForwardMessage(fromChatId, toChatId, messageId, threadId, disableNotification, protectContent)
)
suspend fun TelegramBot.forwardMessage(
public suspend fun TelegramBot.forwardMessage(
fromChat: Chat,
toChatId: ChatIdentifier,
messageId: MessageId,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false
) = forwardMessage(fromChat.id, toChatId, messageId, threadId, disableNotification, protectContent)
): PossiblyForwardedMessage = forwardMessage(fromChat.id, toChatId, messageId, threadId, disableNotification, protectContent)
suspend fun TelegramBot.forwardMessage(
public suspend fun TelegramBot.forwardMessage(
fromChatId: ChatIdentifier,
toChat: Chat,
messageId: MessageId,
threadId: MessageThreadId? = toChat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false
) = forwardMessage(fromChatId, toChat.id, messageId, threadId, disableNotification, protectContent)
): PossiblyForwardedMessage = forwardMessage(fromChatId, toChat.id, messageId, threadId, disableNotification, protectContent)
suspend fun TelegramBot.forwardMessage(
public suspend fun TelegramBot.forwardMessage(
fromChat: Chat,
toChat: Chat,
messageId: MessageId,
threadId: MessageThreadId? = toChat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false
) = forwardMessage(fromChat.id, toChat.id, messageId, threadId, disableNotification, protectContent)
): PossiblyForwardedMessage = forwardMessage(fromChat.id, toChat.id, messageId, threadId, disableNotification, protectContent)
suspend fun TelegramBot.forwardMessage(
public suspend fun TelegramBot.forwardMessage(
toChatId: ChatIdentifier,
message: AccessibleMessage,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false
) = forwardMessage(message.chat, toChatId, message.messageId, threadId, disableNotification, protectContent)
): PossiblyForwardedMessage = forwardMessage(message.chat, toChatId, message.messageId, threadId, disableNotification, protectContent)
suspend fun TelegramBot.forwardMessage(
public suspend fun TelegramBot.forwardMessage(
toChat: Chat,
message: AccessibleMessage,
threadId: MessageThreadId? = toChat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false
) = forwardMessage(message.chat, toChat, message.messageId, threadId, disableNotification, protectContent)
): PossiblyForwardedMessage = forwardMessage(message.chat, toChat, message.messageId, threadId, disableNotification, protectContent)

View File

@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
import kotlin.jvm.JvmName
suspend fun TelegramBot.forwardMessages(
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: List<MessageId>,
@ -16,7 +16,7 @@ suspend fun TelegramBot.forwardMessages(
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
) = messageIds.chunked(forwardMessagesLimit.last).flatMap {
): List<MessageId> = messageIds.chunked(forwardMessagesLimit.last).flatMap {
execute(
ForwardMessages(
toChatId = toChatId,
@ -30,7 +30,7 @@ suspend fun TelegramBot.forwardMessages(
)
}
suspend fun TelegramBot.forwardMessages(
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: Array<MessageId>,
@ -38,7 +38,7 @@ suspend fun TelegramBot.forwardMessages(
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
) = forwardMessages(
): List<MessageId> = forwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = messageIds.toList(),
@ -48,14 +48,14 @@ suspend fun TelegramBot.forwardMessages(
removeCaption = removeCaption
)
suspend fun TelegramBot.forwardMessages(
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
messagesMetas: List<Message.MetaInfo>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
) = messagesMetas.groupBy { it.chatId }.flatMap { (chatId, messages) ->
): List<MessageId> = messagesMetas.groupBy { it.chatId }.flatMap { (chatId, messages) ->
forwardMessages(
toChatId = toChatId,
fromChatId = chatId,
@ -68,14 +68,14 @@ suspend fun TelegramBot.forwardMessages(
}
@JvmName("forwardMessagesWithMessages")
suspend fun TelegramBot.forwardMessages(
public suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier,
messages: List<AccessibleMessage>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
) = forwardMessages(
): List<MessageId> = forwardMessages(
toChatId = toChatId,
messagesMetas = messages.map { it.metaInfo },
threadId = threadId,
@ -84,7 +84,7 @@ suspend fun TelegramBot.forwardMessages(
removeCaption = removeCaption
)
suspend fun TelegramBot.forward(
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: List<MessageId>,
@ -92,7 +92,7 @@ suspend fun TelegramBot.forward(
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
) = forwardMessages(
): List<MessageId> = forwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = messageIds,
@ -102,7 +102,7 @@ suspend fun TelegramBot.forward(
removeCaption = removeCaption
)
suspend fun TelegramBot.forward(
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
fromChatId: ChatIdentifier,
messageIds: Array<MessageId>,
@ -110,7 +110,7 @@ suspend fun TelegramBot.forward(
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
) = forwardMessages(
): List<MessageId> = forwardMessages(
toChatId = toChatId,
fromChatId = fromChatId,
messageIds = messageIds,
@ -120,14 +120,14 @@ suspend fun TelegramBot.forward(
removeCaption = removeCaption
)
suspend fun TelegramBot.forward(
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
messagesMetas: List<Message.MetaInfo>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
) = forwardMessages(
): List<MessageId> = forwardMessages(
toChatId = toChatId,
messagesMetas = messagesMetas,
threadId = threadId,
@ -137,14 +137,14 @@ suspend fun TelegramBot.forward(
)
@JvmName("forwardWithMessages")
suspend fun TelegramBot.forward(
public suspend fun TelegramBot.forward(
toChatId: ChatIdentifier,
messages: List<AccessibleMessage>,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
removeCaption: Boolean = false
) = forwardMessages(
): List<MessageId> = forwardMessages(
toChatId = toChatId,
messages = messages,
threadId = threadId,

View File

@ -5,22 +5,22 @@ import dev.inmo.tgbotapi.requests.GetUpdates
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.update.abstracts.Update
suspend fun TelegramBot.getUpdates(
public suspend fun TelegramBot.getUpdates(
offset: UpdateId? = null,
limit: Int = getUpdatesLimit.last,
timeout: Seconds? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST
) = execute(
): List<Update> = execute(
GetUpdates(
offset, limit, timeout, allowed_updates
)
)
suspend fun TelegramBot.getUpdates(
public suspend fun TelegramBot.getUpdates(
lastUpdate: Update,
limit: Int = getUpdatesLimit.last,
timeout: Seconds? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST
) = getUpdates(
): List<Update> = getUpdates(
lastUpdate.updateId + 1, limit, timeout, allowed_updates
)

View File

@ -4,23 +4,24 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.GetUpdatesRaw
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.update.abstracts.Update
import kotlinx.serialization.json.JsonArray
suspend fun TelegramBot.getRawUpdates(
public suspend fun TelegramBot.getRawUpdates(
offset: UpdateId? = null,
limit: Int = getUpdatesLimit.last,
timeout: Seconds? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST
) = execute(
): JsonArray = execute(
GetUpdatesRaw(
offset, limit, timeout, allowed_updates
)
)
suspend fun TelegramBot.getRawUpdates(
public suspend fun TelegramBot.getRawUpdates(
lastUpdate: Update,
limit: Int = getUpdatesLimit.last,
timeout: Seconds? = null,
allowed_updates: List<String>? = ALL_UPDATES_LIST
) = getRawUpdates(
): JsonArray = getRawUpdates(
lastUpdate.updateId + 1, limit, timeout, allowed_updates
)

View File

@ -1,9 +1,11 @@
package dev.inmo.tgbotapi.extensions.api
import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob
import dev.inmo.micro_utils.coroutines.LinkedSupervisorScope
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
import dev.inmo.tgbotapi.abstracts.*
import dev.inmo.tgbotapi.abstracts.Headed
import dev.inmo.tgbotapi.abstracts.HorizontallyAccured
import dev.inmo.tgbotapi.abstracts.Locationed
import dev.inmo.tgbotapi.abstracts.ProximityAlertable
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.edit.edit
@ -16,17 +18,20 @@ import dev.inmo.tgbotapi.types.location.LiveLocation
import dev.inmo.tgbotapi.types.location.Location
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.LocationContent
import kotlinx.coroutines.*
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.FlowCollector
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.isActive
import kotlinx.serialization.Serializable
import kotlin.js.JsName
import kotlin.jvm.JvmName
import kotlin.math.ceil
@Serializable
data class EditLiveLocationInfo(
public data class EditLiveLocationInfo(
override val latitude: Double,
override val longitude: Double,
override val horizontalAccuracy: Meters? = null,
@ -39,7 +44,7 @@ data class EditLiveLocationInfo(
* Will [sendLiveLocation] with the first [EditLiveLocationInfo] data and update than. Each [liveTimeMillis] passing,
* the message will be sent again and new edits will be applied to the new message
*/
suspend fun TelegramBot.handleLiveLocation(
public suspend fun TelegramBot.handleLiveLocation(
chatId: ChatIdentifier,
locationsFlow: Flow<EditLiveLocationInfo>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
@ -112,7 +117,7 @@ suspend fun TelegramBot.handleLiveLocation(
*/
@JvmName("handleLiveLocationWithLocation")
@JsName("handleLiveLocationWithLocation")
suspend fun TelegramBot.handleLiveLocation(
public suspend fun TelegramBot.handleLiveLocation(
chatId: ChatIdentifier,
locationsFlow: Flow<Location>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
@ -153,7 +158,7 @@ suspend fun TelegramBot.handleLiveLocation(
*/
@JvmName("handleLiveLocationWithLatLong")
@JsName("handleLiveLocationWithLatLong")
suspend fun TelegramBot.handleLiveLocation(
public suspend fun TelegramBot.handleLiveLocation(
chatId: ChatIdentifier,
locationsFlow: Flow<Pair<Double, Double>>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,

View File

@ -23,13 +23,13 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import kotlin.math.ceil
const val indefiniteLivePeriodDelayMillis = LiveLocation.INDEFINITE_LIVE_PERIOD * 1000L
const val defaultLivePeriodDelayMillis = indefiniteLivePeriodDelayMillis
public const val indefiniteLivePeriodDelayMillis: Long = LiveLocation.INDEFINITE_LIVE_PERIOD * 1000L
public const val defaultLivePeriodDelayMillis: Long = indefiniteLivePeriodDelayMillis
/**
* @see startLiveLocation
*/
class LiveLocationProvider internal constructor(
public class LiveLocationProvider internal constructor(
private val requestsExecutor: TelegramBot,
scope: CoroutineScope,
autoCloseTimeDelay: Double,
@ -41,23 +41,23 @@ class LiveLocationProvider internal constructor(
}
}
private val autoCloseTime = DateTime.now() + TimeSpan(autoCloseTimeDelay)
val leftUntilCloseMillis: TimeSpan
public val leftUntilCloseMillis: TimeSpan
get() = autoCloseTime - DateTime.now()
var isClosed: Boolean = false
public var isClosed: Boolean = false
private set
get() = field || leftUntilCloseMillis.millisecondsLong < 0L
var message: ContentMessage<LocationContent> = initMessage
public var message: ContentMessage<LocationContent> = initMessage
private set
val lastLocation: LiveLocation
public val lastLocation: LiveLocation
get() = message.content.location as LiveLocation
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun updateLocation(
public suspend fun updateLocation(
location: LiveLocation,
replyMarkup: InlineKeyboardMarkup? = null
): LiveLocation {
@ -86,7 +86,7 @@ class LiveLocationProvider internal constructor(
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/
suspend fun TelegramBot.startLiveLocation(
public suspend fun TelegramBot.startLiveLocation(
scope: CoroutineScope,
chatId: ChatIdentifier,
latitude: Double,
@ -135,7 +135,7 @@ suspend fun TelegramBot.startLiveLocation(
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/
suspend fun TelegramBot.startLiveLocation(
public suspend fun TelegramBot.startLiveLocation(
scope: CoroutineScope,
chat: Chat,
latitude: Double,
@ -173,7 +173,7 @@ suspend fun TelegramBot.startLiveLocation(
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/
suspend fun TelegramBot.startLiveLocation(
public suspend fun TelegramBot.startLiveLocation(
scope: CoroutineScope,
chatId: IdChatIdentifier,
location: StaticLocation,
@ -210,7 +210,7 @@ suspend fun TelegramBot.startLiveLocation(
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/
suspend fun TelegramBot.startLiveLocation(
public suspend fun TelegramBot.startLiveLocation(
scope: CoroutineScope,
chat: Chat,
location: StaticLocation,
@ -247,7 +247,7 @@ suspend fun TelegramBot.startLiveLocation(
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/
suspend inline fun TelegramBot.replyWithLiveLocation(
public suspend inline fun TelegramBot.replyWithLiveLocation(
to: AccessibleMessage,
scope: CoroutineScope,
latitude: Double,
@ -263,7 +263,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation(
effectId: EffectId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = startLiveLocation(
): LiveLocationProvider = startLiveLocation(
scope,
to.chat,
latitude,
@ -285,7 +285,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation(
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/
suspend inline fun TelegramBot.replyWithLiveLocation(
public suspend inline fun TelegramBot.replyWithLiveLocation(
to: AccessibleMessage,
scope: CoroutineScope,
location: StaticLocation,
@ -300,7 +300,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation(
effectId: EffectId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = startLiveLocation(
): LiveLocationProvider = startLiveLocation(
scope,
to.chat,
location,

View File

@ -3,4 +3,4 @@ package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.local.LogOut
suspend inline fun TelegramBot.logOut() = execute(LogOut)
public suspend inline fun TelegramBot.logOut(): Boolean = execute(LogOut)

View File

@ -7,17 +7,18 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.polls.Poll
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.stopPoll(
public suspend fun TelegramBot.stopPoll(
chatId: ChatIdentifier,
messageId: MessageId,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
): Poll = execute(
StopPoll(chatId, messageId, businessConnectionId, replyMarkup)
)
@ -25,31 +26,31 @@ suspend fun TelegramBot.stopPoll(
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.stopPoll(
public suspend fun TelegramBot.stopPoll(
chat: Chat,
messageId: MessageId,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chat.id, messageId, businessConnectionId, replyMarkup)
): Poll = stopPoll(chat.id, messageId, businessConnectionId, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.stopPoll(
public suspend fun TelegramBot.stopPoll(
chatId: IdChatIdentifier,
message: AccessibleMessage,
businessConnectionId: BusinessConnectionId? = chatId.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chatId, message.messageId, businessConnectionId, replyMarkup)
): Poll = stopPoll(chatId, message.messageId, businessConnectionId, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.stopPoll(
public suspend fun TelegramBot.stopPoll(
chat: Chat,
message: AccessibleMessage,
businessConnectionId: BusinessConnectionId? = chat.id.businessConnectionId,
replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chat.id, message.messageId, businessConnectionId, replyMarkup)
): Poll = stopPoll(chat.id, message.messageId, businessConnectionId, replyMarkup)

View File

@ -12,38 +12,38 @@ import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.stickers.MaskPosition
import dev.inmo.tgbotapi.types.stickers.StickerSet
suspend fun TelegramBot.addStickerToSet(
public suspend fun TelegramBot.addStickerToSet(
userId: UserId,
stickerSetName: StickerSetName,
inputSticker: InputSticker
) = execute(
): Boolean = execute(
AddStickerToSet(userId, stickerSetName, inputSticker)
)
suspend fun TelegramBot.addStickerToSet(
public suspend fun TelegramBot.addStickerToSet(
userId: UserId,
stickerSetName: String,
inputSticker: InputSticker
) = addStickerToSet(userId, StickerSetName(stickerSetName), inputSticker)
): Boolean = addStickerToSet(userId, StickerSetName(stickerSetName), inputSticker)
suspend fun TelegramBot.addStickerToSet(
public suspend fun TelegramBot.addStickerToSet(
userId: UserId,
stickerSet: StickerSet,
sticker: InputSticker
) = addStickerToSet(
): Boolean = addStickerToSet(
userId,
stickerSet.name,
sticker
)
suspend fun TelegramBot.addStickerToSet(
public suspend fun TelegramBot.addStickerToSet(
userId: UserId,
stickerSet: StickerSet,
sticker: InputFile,
format: StickerFormat,
emojis: List<String>,
keywords: List<String> = emptyList()
) = addStickerToSet(
): Boolean = addStickerToSet(
userId,
stickerSet,
when (stickerSet.stickerType) {
@ -68,14 +68,14 @@ suspend fun TelegramBot.addStickerToSet(
}
)
suspend fun TelegramBot.addStickerToSet(
public suspend fun TelegramBot.addStickerToSet(
userId: UserId,
stickerSet: StickerSet,
sticker: InputFile,
format: StickerFormat,
emojis: List<String>,
maskPosition: MaskPosition? = null
) = addStickerToSet(
): Boolean = addStickerToSet(
userId,
stickerSet.name,
when (stickerSet.stickerType) {
@ -101,34 +101,34 @@ suspend fun TelegramBot.addStickerToSet(
}
)
suspend fun TelegramBot.addStickerToSet(
public suspend fun TelegramBot.addStickerToSet(
user: CommonUser,
stickerSet: StickerSet,
sticker: InputSticker
) = addStickerToSet(
): Boolean = addStickerToSet(
user.id,
stickerSet.name,
sticker
)
suspend fun TelegramBot.addStickerToSet(
public suspend fun TelegramBot.addStickerToSet(
user: CommonUser,
stickerSet: StickerSet,
sticker: InputFile,
format: StickerFormat,
emojis: List<String>,
keywords: List<String> = emptyList()
) = addStickerToSet(
): Boolean = addStickerToSet(
user.id, stickerSet, sticker, format, emojis, keywords
)
suspend fun TelegramBot.addStickerToSet(
public suspend fun TelegramBot.addStickerToSet(
user: CommonUser,
stickerSet: StickerSet,
sticker: InputFile,
format: StickerFormat,
emojis: List<String>,
maskPosition: MaskPosition? = null
) = addStickerToSet(
): Boolean = addStickerToSet(
user.id, stickerSet, sticker, format, emojis, maskPosition
)

View File

@ -7,23 +7,23 @@ import dev.inmo.tgbotapi.types.StickerFormat
import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.UserId
suspend fun TelegramBot.createNewStickerSet(
public suspend fun TelegramBot.createNewStickerSet(
userId: UserId,
name: String,
title: String,
stickers: List<InputSticker>,
needsRepainting: Boolean = false
) = execute(
): Boolean = execute(
CreateNewStickerSet(userId, name, title, stickers, needsRepainting)
)
suspend fun TelegramBot.createNewStickerSet(
public suspend fun TelegramBot.createNewStickerSet(
user: CommonUser,
name: String,
title: String,
stickers: List<InputSticker>,
needsRepainting: Boolean = false,
) = createNewStickerSet(
): Boolean = createNewStickerSet(
user.id, name, title, stickers, needsRepainting
)

View File

@ -5,16 +5,16 @@ 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(
public suspend fun TelegramBot.deleteStickerFromSet(
sticker: FileId
) = execute(
): Boolean = execute(
DeleteStickerFromSet(
sticker
)
)
suspend fun TelegramBot.deleteStickerFromSet(
public suspend fun TelegramBot.deleteStickerFromSet(
sticker: Sticker
) = deleteStickerFromSet(
): Boolean = deleteStickerFromSet(
sticker.fileId
)

View File

@ -8,18 +8,18 @@ import dev.inmo.tgbotapi.types.StickerSetName
import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.stickers.StickerSet
suspend fun TelegramBot.deleteStickerSet(
public suspend fun TelegramBot.deleteStickerSet(
name: StickerSetName
) = execute(
): Boolean = execute(
DeleteStickerSet(name)
)
suspend fun TelegramBot.deleteStickerSet(
public suspend fun TelegramBot.deleteStickerSet(
sticker: Sticker
) = deleteStickerSet(
): Boolean = deleteStickerSet(
sticker.stickerSetName ?: error("Unable to take name of sticker set from sticker $sticker")
)
suspend fun TelegramBot.deleteStickerSet(
public suspend fun TelegramBot.deleteStickerSet(
stickerSet: StickerSet,
) = deleteStickerSet(stickerSet.name)
): Boolean = deleteStickerSet(stickerSet.name)

View File

@ -14,35 +14,35 @@ import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.stickers.MaskPosition
import dev.inmo.tgbotapi.types.stickers.StickerSet
suspend fun TelegramBot.replaceStickerInSet(
public suspend fun TelegramBot.replaceStickerInSet(
userId: UserId,
stickerSetName: StickerSetName,
oldSticker: FileId,
newSticker: InputSticker
) = execute(
): Boolean = execute(
ReplaceStickerInSet(userId, stickerSetName, oldSticker, newSticker)
)
suspend fun TelegramBot.replaceStickerInSet(
public suspend fun TelegramBot.replaceStickerInSet(
userId: UserId,
stickerSetName: String,
oldSticker: FileId,
newSticker: InputSticker
) = replaceStickerInSet(userId, StickerSetName(stickerSetName), oldSticker, newSticker)
): Boolean = replaceStickerInSet(userId, StickerSetName(stickerSetName), oldSticker, newSticker)
suspend fun TelegramBot.replaceStickerInSet(
public suspend fun TelegramBot.replaceStickerInSet(
userId: UserId,
stickerSet: StickerSet,
oldSticker: FileId,
newSticker: InputSticker
) = replaceStickerInSet(
): Boolean = replaceStickerInSet(
userId,
stickerSet.name,
oldSticker,
newSticker
)
suspend fun TelegramBot.replaceStickerInSet(
public suspend fun TelegramBot.replaceStickerInSet(
userId: UserId,
stickerSet: StickerSet,
oldSticker: FileId,
@ -50,7 +50,7 @@ suspend fun TelegramBot.replaceStickerInSet(
format: StickerFormat,
emojis: List<String>,
keywords: List<String> = emptyList()
) = replaceStickerInSet(
): Boolean = replaceStickerInSet(
userId,
stickerSet,
oldSticker,
@ -76,7 +76,7 @@ suspend fun TelegramBot.replaceStickerInSet(
}
)
suspend fun TelegramBot.replaceStickerInSet(
public suspend fun TelegramBot.replaceStickerInSet(
userId: UserId,
stickerSet: StickerSet,
oldSticker: FileId,
@ -84,7 +84,7 @@ suspend fun TelegramBot.replaceStickerInSet(
format: StickerFormat,
emojis: List<String>,
maskPosition: MaskPosition? = null
) = replaceStickerInSet(
): Boolean = replaceStickerInSet(
userId,
stickerSet.name,
oldSticker,
@ -111,19 +111,19 @@ suspend fun TelegramBot.replaceStickerInSet(
}
)
suspend fun TelegramBot.replaceStickerInSet(
public suspend fun TelegramBot.replaceStickerInSet(
user: CommonUser,
stickerSet: StickerSet,
oldSticker: FileId,
newSticker: InputSticker
) = replaceStickerInSet(
): Boolean = replaceStickerInSet(
user.id,
stickerSet.name,
oldSticker,
newSticker
)
suspend fun TelegramBot.replaceStickerInSet(
public suspend fun TelegramBot.replaceStickerInSet(
user: CommonUser,
stickerSet: StickerSet,
oldSticker: FileId,
@ -131,11 +131,11 @@ suspend fun TelegramBot.replaceStickerInSet(
format: StickerFormat,
emojis: List<String>,
keywords: List<String> = emptyList()
) = replaceStickerInSet(
): Boolean = replaceStickerInSet(
user.id, stickerSet, oldSticker, sticker, format, emojis, keywords
)
suspend fun TelegramBot.replaceStickerInSet(
public suspend fun TelegramBot.replaceStickerInSet(
user: CommonUser,
stickerSet: StickerSet,
oldSticker: FileId,
@ -143,6 +143,6 @@ suspend fun TelegramBot.replaceStickerInSet(
format: StickerFormat,
emojis: List<String>,
maskPosition: MaskPosition? = null
) = replaceStickerInSet(
): Boolean = replaceStickerInSet(
user.id, stickerSet, oldSticker, sticker, format, emojis, maskPosition
)

View File

@ -11,16 +11,16 @@ import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.stickers.StickerSet
suspend fun TelegramBot.setCustomEmojiStickerSetThumbnail(
public suspend fun TelegramBot.setCustomEmojiStickerSetThumbnail(
stickerSetName: StickerSetName,
customEmojiId: CustomEmojiId
) = execute(
): Boolean = execute(
SetCustomEmojiStickerSetThumbnail(stickerSetName, customEmojiId)
)
suspend fun TelegramBot.setCustomEmojiStickerSetThumbnail(
public suspend fun TelegramBot.setCustomEmojiStickerSetThumbnail(
stickerSet: StickerSet,
customEmojiId: CustomEmojiId
) = setCustomEmojiStickerSetThumbnail(
): Boolean = setCustomEmojiStickerSetThumbnail(
stickerSet.name, customEmojiId
)

View File

@ -6,20 +6,20 @@ import dev.inmo.tgbotapi.requests.stickers.SetStickerEmojiList
import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet
import dev.inmo.tgbotapi.types.files.Sticker
suspend fun TelegramBot.setStickerEmojiList(
public suspend fun TelegramBot.setStickerEmojiList(
sticker: FileId,
emojis: List<String>
) = execute(
): Boolean = execute(
SetStickerEmojiList(
sticker,
emojis
)
)
suspend fun TelegramBot.setStickerEmojiList(
public suspend fun TelegramBot.setStickerEmojiList(
sticker: Sticker,
vararg emojis: String
) = setStickerEmojiList(
): Boolean = setStickerEmojiList(
sticker.fileId,
emojis.toList()
)

View File

@ -7,20 +7,20 @@ import dev.inmo.tgbotapi.requests.stickers.SetStickerKeywords
import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet
import dev.inmo.tgbotapi.types.files.Sticker
suspend fun TelegramBot.setStickerKeywords(
public suspend fun TelegramBot.setStickerKeywords(
sticker: FileId,
keywords: List<String>
) = execute(
): Boolean = execute(
SetStickerKeywords(
sticker,
keywords
)
)
suspend fun TelegramBot.setStickerKeywords(
public suspend fun TelegramBot.setStickerKeywords(
sticker: Sticker,
vararg keywords: String
) = setStickerKeywords(
): Boolean = setStickerKeywords(
sticker.fileId,
keywords.toList()
)

View File

@ -8,10 +8,10 @@ import dev.inmo.tgbotapi.requests.stickers.SetStickerPositionInSet
import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.stickers.MaskPosition
suspend fun TelegramBot.setStickerMaskPosition(
public suspend fun TelegramBot.setStickerMaskPosition(
sticker: FileId,
maskPosition: MaskPosition
) = execute(
): Boolean = execute(
SetStickerMaskPosition(
sticker,
maskPosition

View File

@ -5,20 +5,20 @@ 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(
public suspend fun TelegramBot.setStickerPositionInSet(
sticker: FileId,
position: Int
) = execute(
): Boolean = execute(
SetStickerPositionInSet(
sticker,
position
)
)
suspend fun TelegramBot.setStickerPositionInSet(
public suspend fun TelegramBot.setStickerPositionInSet(
sticker: Sticker,
position: Int
) = setStickerPositionInSet(
): Boolean = setStickerPositionInSet(
sticker.fileId,
position
)

View File

@ -10,74 +10,74 @@ import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.stickers.StickerSet
suspend fun TelegramBot.setStickerSetThumbnail(
public suspend fun TelegramBot.setStickerSetThumbnail(
userId: UserId,
stickerSetName: StickerSetName,
format: StickerFormat,
thumbnail: FileId
) = execute(
): Boolean = execute(
SetStickerSetThumbnail(userId, stickerSetName, format, thumbnail)
)
suspend fun TelegramBot.setStickerSetThumbnail(
public suspend fun TelegramBot.setStickerSetThumbnail(
userId: UserId,
stickerSetName: StickerSetName,
format: StickerFormat,
thumbnail: MultipartFile
) = execute(
): Boolean = execute(
SetStickerSetThumbnail(userId, stickerSetName, format, thumbnail)
)
suspend fun TelegramBot.setStickerSetThumbnail(
public suspend fun TelegramBot.setStickerSetThumbnail(
user: CommonUser,
stickerSetName: StickerSetName,
format: StickerFormat,
thumbnail: FileId
) = setStickerSetThumbnail(
): Boolean = setStickerSetThumbnail(
user.id, stickerSetName, format, thumbnail
)
suspend fun TelegramBot.setStickerSetThumbnail(
public suspend fun TelegramBot.setStickerSetThumbnail(
user: CommonUser,
stickerSetName: StickerSetName,
format: StickerFormat,
thumbnail: MultipartFile
) = setStickerSetThumbnail(
): Boolean = setStickerSetThumbnail(
user.id, stickerSetName, format, thumbnail
)
suspend fun TelegramBot.setStickerSetThumbnail(
public suspend fun TelegramBot.setStickerSetThumbnail(
userId: UserId,
stickerSet: StickerSet,
format: StickerFormat,
thumbnail: FileId
) = setStickerSetThumbnail(
): Boolean = setStickerSetThumbnail(
userId, stickerSet.name, format, thumbnail
)
suspend fun TelegramBot.setStickerSetThumbnail(
public suspend fun TelegramBot.setStickerSetThumbnail(
userId: UserId,
stickerSet: StickerSet,
format: StickerFormat,
thumbnail: MultipartFile
) = setStickerSetThumbnail(
): Boolean = setStickerSetThumbnail(
userId, stickerSet.name, format, thumbnail
)
suspend fun TelegramBot.setStickerSetThumbnail(
public suspend fun TelegramBot.setStickerSetThumbnail(
user: CommonUser,
stickerSet: StickerSet,
format: StickerFormat,
thumbnail: FileId
) = setStickerSetThumbnail(
): Boolean = setStickerSetThumbnail(
user.id, stickerSet, format, thumbnail
)
suspend fun TelegramBot.setStickerSetThumbnail(
public suspend fun TelegramBot.setStickerSetThumbnail(
user: CommonUser,
stickerSet: StickerSet,
format: StickerFormat,
thumbnail: MultipartFile
) = setStickerSetThumbnail(
): Boolean = setStickerSetThumbnail(
user.id, stickerSet, format, thumbnail
)

View File

@ -6,17 +6,17 @@ import dev.inmo.tgbotapi.types.StickerSetName
import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.stickers.StickerSet
suspend fun TelegramBot.setStickerSetTitle(
public suspend fun TelegramBot.setStickerSetTitle(
name: StickerSetName,
title: String
) = execute(SetStickerSetTitle(name, title))
): Boolean = execute(SetStickerSetTitle(name, title))
suspend fun TelegramBot.setStickerSetTitle(
public suspend fun TelegramBot.setStickerSetTitle(
sticker: Sticker,
title: String
) = setStickerSetTitle(sticker.stickerSetName ?: error("Unable to take name of sticker set from sticker $sticker"), title)
): Boolean = setStickerSetTitle(sticker.stickerSetName ?: error("Unable to take name of sticker set from sticker $sticker"), title)
suspend fun TelegramBot.setStickerSetTitle(
public suspend fun TelegramBot.setStickerSetTitle(
stickerSet: StickerSet,
title: String
) = setStickerSetTitle(stickerSet.name, title)
): Boolean = setStickerSetTitle(stickerSet.name, title)

View File

@ -6,19 +6,20 @@ import dev.inmo.tgbotapi.requests.stickers.UploadStickerFile
import dev.inmo.tgbotapi.types.StickerFormat
import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.files.File
suspend fun TelegramBot.uploadStickerFile(
public suspend fun TelegramBot.uploadStickerFile(
userId: UserId,
sticker: MultipartFile,
stickerFormat: StickerFormat
) = execute(
): File = execute(
UploadStickerFile(userId, sticker, stickerFormat)
)
suspend fun TelegramBot.uploadStickerFile(
public suspend fun TelegramBot.uploadStickerFile(
user: CommonUser,
sticker: MultipartFile,
stickerFormat: StickerFormat
) = execute(
): File = execute(
UploadStickerFile(user.id, sticker, stickerFormat)
)

View File

@ -17,7 +17,7 @@ import kotlinx.coroutines.launch
*
* @see UpdateReceiver
*/
fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation(
public fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation(
output: UpdateReceiver<Update>,
mediaGroupsDebounceMillis: Long = 1000L
): UpdateReceiver<Update> {

View File

@ -3,4 +3,4 @@ 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())
public suspend fun TelegramBot.deleteWebhook(): Boolean = execute(DeleteWebhook())

View File

@ -2,5 +2,6 @@ package dev.inmo.tgbotapi.extensions.api.webhook
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.webhook.GetWebhookInfo
import dev.inmo.tgbotapi.types.WebhookInfo
suspend fun TelegramBot.getWebhookInfo() = execute(GetWebhookInfo())
public suspend fun TelegramBot.getWebhookInfo(): WebhookInfo = execute(GetWebhookInfo())

View File

@ -9,14 +9,14 @@ import dev.inmo.tgbotapi.types.ALL_UPDATES_LIST
/**
* Use this method to send information about webhook (like [url])
*/
suspend fun TelegramBot.setWebhookInfo(
public suspend fun TelegramBot.setWebhookInfo(
url: String,
ipAddress: String? = null,
maxAllowedConnections: Int? = null,
allowedUpdates: List<String>? = ALL_UPDATES_LIST,
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
) = execute(
): Boolean = execute(
SetWebhook(
url, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken
)
@ -25,7 +25,7 @@ suspend fun TelegramBot.setWebhookInfo(
/**
* Use this method to send information about webhook (like [url] and [certificate])
*/
suspend fun TelegramBot.setWebhookInfo(
public suspend fun TelegramBot.setWebhookInfo(
url: String,
certificate: FileId,
ipAddress: String? = null,
@ -33,7 +33,7 @@ suspend fun TelegramBot.setWebhookInfo(
allowedUpdates: List<String>? = ALL_UPDATES_LIST,
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
) = execute(
): Boolean = execute(
SetWebhook(
url, certificate, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken
)
@ -42,7 +42,7 @@ suspend fun TelegramBot.setWebhookInfo(
/**
* Use this method to send information about webhook (like [url] and [certificate])
*/
suspend fun TelegramBot.setWebhookInfo(
public suspend fun TelegramBot.setWebhookInfo(
url: String,
certificate: MultipartFile,
ipAddress: String? = null,
@ -50,7 +50,7 @@ suspend fun TelegramBot.setWebhookInfo(
allowedUpdates: List<String>? = ALL_UPDATES_LIST,
dropPendingUpdates: Boolean? = null,
secretToken: String? = null
) = execute(
): Boolean = execute(
SetWebhook(
url, certificate, ipAddress, maxAllowedConnections, allowedUpdates, dropPendingUpdates, secretToken
)