mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 12:08:43 +00:00
complete filling of requests extensions
This commit is contained in:
parent
c7d5fdd2e0
commit
e43ad41d2f
@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
package com.github.insanusmokrassar.TelegramBotAPI.requests
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
|
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||||
@ -27,3 +28,23 @@ data class GetUpdates(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getUpdates(
|
||||||
|
offset: UpdateIdentifier? = null,
|
||||||
|
limit: Int? = null,
|
||||||
|
timeout: Int? = null,
|
||||||
|
allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||||
|
) = execute(
|
||||||
|
GetUpdates(
|
||||||
|
offset, limit, timeout, allowed_updates
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getUpdates(
|
||||||
|
lastUpdate: Update,
|
||||||
|
limit: Int? = null,
|
||||||
|
timeout: Int? = null,
|
||||||
|
allowed_updates: List<String>? = ALL_UPDATES_LIST
|
||||||
|
) = getUpdates(
|
||||||
|
lastUpdate.updateId + 1, limit, timeout, allowed_updates
|
||||||
|
)
|
||||||
|
@ -6,6 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendLocation
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
@ -98,3 +99,37 @@ suspend fun RequestsExecutor.startLiveLocation(
|
|||||||
locationMessage
|
locationMessage
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.startLiveLocation(
|
||||||
|
scope: CoroutineScope,
|
||||||
|
chat: Chat,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
): LiveLocation = startLiveLocation(
|
||||||
|
scope, chat.id, latitude, longitude, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.startLiveLocation(
|
||||||
|
scope: CoroutineScope,
|
||||||
|
chatId: ChatId,
|
||||||
|
location: Location,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
): LiveLocation = startLiveLocation(
|
||||||
|
scope, chatId, location.latitude, location.longitude, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.startLiveLocation(
|
||||||
|
scope: CoroutineScope,
|
||||||
|
chat: Chat,
|
||||||
|
location: Location,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
): LiveLocation = startLiveLocation(
|
||||||
|
scope, chat.id, location.latitude, location.longitude, disableNotification, replyToMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
@ -27,6 +27,6 @@ suspend fun RequestsExecutor.getStickerSet(
|
|||||||
|
|
||||||
suspend fun RequestsExecutor.getStickerSet(
|
suspend fun RequestsExecutor.getStickerSet(
|
||||||
sticker: Sticker
|
sticker: Sticker
|
||||||
) = execute(
|
) = getStickerSet(
|
||||||
GetStickerSet(sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method"))
|
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
|
||||||
)
|
)
|
||||||
|
@ -7,6 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.*
|
|||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent
|
||||||
@ -87,3 +88,34 @@ suspend fun RequestsExecutor.sendLocation(
|
|||||||
replyToMessageId,
|
replyToMessageId,
|
||||||
replyMarkup
|
replyMarkup
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.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 RequestsExecutor.sendLocation(
|
||||||
|
chat: Chat,
|
||||||
|
location: Location,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = sendLocation(
|
||||||
|
chat.id,
|
||||||
|
location.latitude,
|
||||||
|
location.longitude,
|
||||||
|
disableNotification,
|
||||||
|
replyToMessageId,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send.media
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.MultipartFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.Request
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toJsonWithoutNulls
|
||||||
@ -85,3 +87,23 @@ data class SendMediaGroupData internal constructor(
|
|||||||
data class SendMediaGroupFiles internal constructor(
|
data class SendMediaGroupFiles internal constructor(
|
||||||
val files: List<MultipartFile>
|
val files: List<MultipartFile>
|
||||||
) : Files by (files.map { it.fileId to it }.toMap())
|
) : Files by (files.map { it.fileId to it }.toMap())
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendMediaGroup(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
media: List<MediaGroupMemberInputMedia>,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null
|
||||||
|
) = execute(
|
||||||
|
SendMediaGroup(
|
||||||
|
chatId, media, disableNotification, replyToMessageId
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendMediaGroup(
|
||||||
|
chat: Chat,
|
||||||
|
media: List<MediaGroupMemberInputMedia>,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null
|
||||||
|
) = sendMediaGroup(
|
||||||
|
chat.id, media, disableNotification, replyToMessageId
|
||||||
|
)
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.SimpleRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.WebhookInfo
|
import com.github.insanusmokrassar.TelegramBotAPI.types.WebhookInfo
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
@ -13,3 +14,5 @@ class GetWebhookInfo : SimpleRequest<WebhookInfo> {
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.getWebhookInfo() = execute(GetWebhookInfo())
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.webhook
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.abstracts.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.DataRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.DataRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.MultipartRequestImpl
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.base.MultipartRequestImpl
|
||||||
@ -64,3 +65,28 @@ data class SetWebhook internal constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setWebhookInfo(
|
||||||
|
url: String,
|
||||||
|
certificate: FileId,
|
||||||
|
maxAllowedConnections: Int? = null,
|
||||||
|
allowedUpdates: List<String>? = null
|
||||||
|
) = execute(
|
||||||
|
SetWebhook(
|
||||||
|
url, certificate.fileId, maxAllowedConnections, allowedUpdates
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.setWebhookInfo(
|
||||||
|
url: String,
|
||||||
|
certificate: MultipartFile,
|
||||||
|
maxAllowedConnections: Int? = null,
|
||||||
|
allowedUpdates: List<String>? = null
|
||||||
|
) = execute(
|
||||||
|
MultipartRequestImpl(
|
||||||
|
SetWebhook(
|
||||||
|
url, null, maxAllowedConnections, allowedUpdates
|
||||||
|
),
|
||||||
|
mapOf(certificateField to certificate)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user