mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
removing of deprecations
This commit is contained in:
parent
865edf385f
commit
89881a7349
@ -15,6 +15,8 @@
|
||||
* `File#toInputFile` extension now will throw error when file does not exists
|
||||
* `InlineKeyboardMarkup` will check that `PayInlineKeyboardButton` is the first in case if it is exists in
|
||||
`keyboard`
|
||||
* `makeLinkToMessage` now is not `PreviewFeature`
|
||||
* All deprecations was removed
|
||||
|
||||
## 0.24.0
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.bot
|
||||
|
||||
import io.ktor.utils.io.core.Closeable
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
|
||||
interface UpdatesPoller : Closeable {
|
||||
fun start(scope: CoroutineScope = CoroutineScope(Dispatchers.Default))
|
||||
}
|
@ -21,13 +21,3 @@ data class GetChat(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getChat(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(GetChat(chatId))
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getChat(
|
||||
chat: Chat
|
||||
) = getChat(chat.id)
|
||||
|
@ -26,13 +26,3 @@ data class GetChatAdministrators(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getChatAdministrators(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(GetChatAdministrators(chatId))
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getChatAdministrators(
|
||||
chat: PublicChat
|
||||
) = getChatAdministrators(chat.id)
|
||||
|
@ -20,13 +20,3 @@ data class GetChatMembersCount(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getChatMembersCount(
|
||||
chatId: ChatIdentifier
|
||||
) = execute(GetChatMembersCount(chatId))
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getChatMembersCount(
|
||||
chat: PublicChat
|
||||
) = getChatMembersCount(chat.id)
|
||||
|
@ -21,27 +21,3 @@ data class GetChatMember(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId
|
||||
) = execute(GetChatMember(chatId, userId))
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getChatMember(
|
||||
chat: PublicChat,
|
||||
userId: UserId
|
||||
) = getChatMember(chat.id, userId)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getChatMember(
|
||||
chatId: ChatId,
|
||||
user: User
|
||||
) = getChatMember(chatId, user.id)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getChatMember(
|
||||
chat: PublicChat,
|
||||
user: User
|
||||
) = getChatMember(chat.id, user.id)
|
||||
|
@ -26,36 +26,3 @@ data class RestrictChatMember(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.restrictChatMember(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = execute(RestrictChatMember(chatId, userId, untilDate, permissions))
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.restrictChatMember(
|
||||
chat: PublicChat,
|
||||
userId: UserId,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = restrictChatMember(chat.id, userId, untilDate, permissions)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.restrictChatMember(
|
||||
chatId: ChatId,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = restrictChatMember(chatId, user.id, untilDate, permissions)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.restrictChatMember(
|
||||
chat: PublicChat,
|
||||
user: User,
|
||||
untilDate: TelegramDate? = null,
|
||||
permissions: ChatPermissions = ChatPermissions()
|
||||
) = restrictChatMember(chat.id, user.id, untilDate, permissions)
|
||||
|
||||
|
@ -33,31 +33,3 @@ data class SetChatAdministratorCustomTitle(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||
chatId: ChatId,
|
||||
userId: UserId,
|
||||
customTitle: String
|
||||
) = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle))
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||
chat: PublicChat,
|
||||
userId: UserId,
|
||||
customTitle: String
|
||||
) = setChatAdministratorCustomTitle(chat.id, userId, customTitle)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||
chatId: ChatId,
|
||||
user: User,
|
||||
customTitle: String
|
||||
) = setChatAdministratorCustomTitle(chatId, user.id, customTitle)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.setChatAdministratorCustomTitle(
|
||||
chat: PublicChat,
|
||||
user: User,
|
||||
customTitle: String
|
||||
) = setChatAdministratorCustomTitle(chat.id, user.id, customTitle)
|
@ -27,15 +27,3 @@ data class SetChatDescription (
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.setChatDescription(
|
||||
chatId: ChatIdentifier,
|
||||
description: String
|
||||
) = execute(SetChatDescription(chatId, description))
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.setChatDescription(
|
||||
chat: PublicChat,
|
||||
description: String
|
||||
) = setChatDescription(chat.id, description)
|
||||
|
@ -22,15 +22,3 @@ data class SetChatPermissions (
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.setDefaultChatMembersPermissions(
|
||||
chatId: ChatIdentifier,
|
||||
permissions: ChatPermissions
|
||||
) = execute(SetChatPermissions(chatId, permissions))
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.setDefaultChatMembersPermissions(
|
||||
chat: PublicChat,
|
||||
permissions: ChatPermissions
|
||||
) = setDefaultChatMembersPermissions(chat.id, permissions)
|
||||
|
@ -23,15 +23,3 @@ data class SetChatPhoto (
|
||||
override val mediaMap: Map<String, MultipartFile> = mapOf(photoField to photo)
|
||||
override val paramsJson: JsonObject = toJson(serializer())
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.setChatPhoto(
|
||||
chatId: ChatIdentifier,
|
||||
photo: MultipartFile
|
||||
) = execute(SetChatPhoto(chatId, photo))
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.setChatPhoto(
|
||||
chat: PublicChat,
|
||||
photo: MultipartFile
|
||||
) = setChatPhoto(chat.id, photo)
|
||||
|
@ -35,33 +35,3 @@ data class EditChatMessageCaption(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.editMessageCaption(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageCaption(chatId, messageId, text, parseMode, replyMarkup)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.editMessageCaption(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageCaption(chat.id, messageId, text, parseMode, replyMarkup)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun <T> RequestsExecutor.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)
|
||||
}
|
||||
|
@ -23,11 +23,3 @@ data class EditInlineMessageCaption(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.editMessageCaption(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(EditInlineMessageCaption(inlineMessageId, text, parseMode, replyMarkup))
|
||||
|
@ -40,28 +40,3 @@ data class EditChatMessageMedia(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.editMessageMedia(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
media: InputMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageMedia(chatId, messageId, media, replyMarkup)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.editMessageMedia(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
media: InputMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageMedia(chat.id, messageId, media, replyMarkup)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.editMessageMedia(
|
||||
message: ContentMessage<out MediaContent>,
|
||||
media: InputMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageMedia(message.chat.id, message.messageId, media, replyMarkup)
|
||||
|
@ -28,10 +28,3 @@ data class EditInlineMessageMedia(
|
||||
|
||||
override fun method(): String = editMessageMediaMethod
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.editMessageCaption(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
media: InputMedia,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(EditInlineMessageMedia(inlineMessageId, media, replyMarkup))
|
||||
|
@ -36,34 +36,3 @@ data class EditChatMessageText(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.editMessageText(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.editMessageText(
|
||||
chat: Chat,
|
||||
messageId: MessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(chat.id, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.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)
|
@ -19,15 +19,3 @@ data class GetFile(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getFileAdditionalInfo(
|
||||
fileId: FileId
|
||||
) = execute(
|
||||
GetFile(fileId)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getFileAdditionalInfo(
|
||||
file: TelegramMediaFile
|
||||
) = getFileAdditionalInfo(file.fileId)
|
||||
|
@ -18,17 +18,3 @@ data class GetStickerSet(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getStickerSet(
|
||||
name: String
|
||||
) = execute(
|
||||
GetStickerSet(name)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getStickerSet(
|
||||
sticker: Sticker
|
||||
) = getStickerSet(
|
||||
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
|
||||
)
|
||||
|
@ -29,21 +29,3 @@ data class GetUserProfilePhotos(
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getUserProfilePhotos(
|
||||
userId: UserId,
|
||||
offset: Int? = null,
|
||||
limit: Int? = null
|
||||
) = execute(
|
||||
GetUserProfilePhotos(
|
||||
userId, offset, limit
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getUserProfilePhotos(
|
||||
user: CommonUser,
|
||||
offset: Int? = null,
|
||||
limit: Int? = null
|
||||
) = getUserProfilePhotos(user.id, offset, limit)
|
||||
|
@ -75,59 +75,3 @@ fun Venue.toRequest(
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.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
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.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
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVenue(
|
||||
chatId: ChatIdentifier,
|
||||
venue: Venue,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendVenue(
|
||||
chatId, venue, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVenue(
|
||||
chat: Chat,
|
||||
venue: Venue,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVenue(
|
||||
chat.id, venue, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
@ -115,144 +115,3 @@ data class SendAnimationFiles internal constructor(
|
||||
animationField to animation,
|
||||
thumbField to thumb
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendAnimation(
|
||||
chatId: ChatIdentifier,
|
||||
animation: FileId,
|
||||
thumb: FileId? = 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(
|
||||
SendAnimationData(
|
||||
chatId,
|
||||
animation.fileId,
|
||||
thumb ?.fileId,
|
||||
text,
|
||||
parseMode,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendAnimation(
|
||||
chatId: ChatIdentifier,
|
||||
animation: AnimationFile,
|
||||
thumb: PhotoSize? = animation.thumb,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(
|
||||
chatId, animation.fileId, thumb ?.fileId, text, parseMode, animation.duration, animation.width, animation.height, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendAnimation(
|
||||
chatId: ChatIdentifier,
|
||||
animation: MultipartFile,
|
||||
thumb: FileId? = 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(
|
||||
MultipartRequestImpl(
|
||||
SendAnimationData(
|
||||
chatId, null, thumb ?.fileId, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup
|
||||
),
|
||||
SendAnimationFiles(animation)
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendAnimation(
|
||||
chatId: ChatIdentifier,
|
||||
animation: MultipartFile,
|
||||
thumb: MultipartFile? = 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(
|
||||
MultipartRequestImpl(
|
||||
SendAnimationData(
|
||||
chatId, null, null, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup
|
||||
),
|
||||
SendAnimationFiles(animation, thumb)
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendAnimation(
|
||||
chatId: ChatIdentifier,
|
||||
animation: FileId,
|
||||
thumb: MultipartFile,
|
||||
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(
|
||||
MultipartRequestImpl(
|
||||
SendAnimationData(
|
||||
chatId, animation.fileId, null, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup
|
||||
),
|
||||
SendAnimationFiles(null, thumb)
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendAnimation(
|
||||
chatId: ChatIdentifier,
|
||||
animation: MultipartFile,
|
||||
thumb: PhotoSize? = 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(
|
||||
chatId, animation, thumb ?.fileId , text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendAnimation(
|
||||
chatId: ChatIdentifier,
|
||||
animation: AnimationFile,
|
||||
thumb: MultipartFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendAnimation(
|
||||
chatId, animation.fileId, thumb, text, parseMode, animation.duration, animation.width, animation.height, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
|
@ -87,25 +87,3 @@ data class SendMediaGroupData internal constructor(
|
||||
data class SendMediaGroupFiles internal constructor(
|
||||
val files: List<MultipartFile>
|
||||
) : Files by (files.map { it.fileId to it }.toMap())
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendMediaGroup(
|
||||
chatId: ChatIdentifier,
|
||||
media: List<MediaGroupMemberInputMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null
|
||||
) = execute(
|
||||
SendMediaGroup(
|
||||
chatId, media, disableNotification, replyToMessageId
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendMediaGroup(
|
||||
chat: Chat,
|
||||
media: List<MediaGroupMemberInputMedia>,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null
|
||||
) = sendMediaGroup(
|
||||
chat.id, media, disableNotification, replyToMessageId
|
||||
)
|
||||
|
@ -85,95 +85,3 @@ data class SendPhotoFiles internal constructor(
|
||||
) : Files by mapOf(
|
||||
photoField to photo
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendPhoto(
|
||||
chatId: ChatIdentifier,
|
||||
fileId: FileId,
|
||||
caption: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendPhotoData(
|
||||
chatId,
|
||||
fileId.fileId,
|
||||
caption,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendPhoto(
|
||||
chatId: ChatIdentifier,
|
||||
file: PhotoSize,
|
||||
caption: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(
|
||||
chatId, file.fileId, caption, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendPhoto(
|
||||
chatId: ChatIdentifier,
|
||||
photo: Photo,
|
||||
caption: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(
|
||||
chatId, photo.biggest() ?: throw IllegalArgumentException("Photo $photo is empty"), caption, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendPhoto(
|
||||
chat: Chat,
|
||||
fileId: FileId,
|
||||
caption: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(
|
||||
chat.id,
|
||||
fileId,
|
||||
caption,
|
||||
parseMode,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendPhoto(
|
||||
chat: Chat,
|
||||
file: PhotoSize,
|
||||
caption: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(
|
||||
chat.id, file.fileId, caption, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendPhoto(
|
||||
chat: Chat,
|
||||
photo: Photo,
|
||||
caption: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendPhoto(
|
||||
chat.id, photo.biggest() ?: throw IllegalArgumentException("Photo $photo is empty"), caption, parseMode, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
@ -65,68 +65,3 @@ data class SendStickerByFile internal constructor(
|
||||
override val mediaMap: Map<String, MultipartFile> = mapOf(stickerField to sticker)
|
||||
override val paramsJson: JsonObject = sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer())
|
||||
}
|
||||
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendSticker(
|
||||
chatId: ChatIdentifier,
|
||||
sticker: FileId,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendStickerByFileId(chatId, sticker, disableNotification, replyToMessageId, replyMarkup)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendSticker(
|
||||
chatId: ChatIdentifier,
|
||||
sticker: MultipartFile,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendStickerByFile(
|
||||
SendStickerByFileId(chatId, null, disableNotification, replyToMessageId, replyMarkup),
|
||||
sticker
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendSticker(
|
||||
chat: Chat,
|
||||
sticker: FileId,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(chat.id, sticker, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendSticker(
|
||||
chat: Chat,
|
||||
sticker: MultipartFile,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(chat.id, sticker, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendSticker(
|
||||
chatId: ChatIdentifier,
|
||||
sticker: Sticker,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(
|
||||
chatId, sticker.fileId, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendSticker(
|
||||
chat: Chat,
|
||||
sticker: Sticker,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendSticker(chat.id, sticker.fileId, disableNotification, replyToMessageId, replyMarkup)
|
||||
|
||||
|
@ -119,148 +119,3 @@ data class SendVideoFiles internal constructor(
|
||||
videoField to video,
|
||||
thumbField to thumb
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVideo(
|
||||
chatId: ChatIdentifier,
|
||||
video: FileId,
|
||||
thumb: FileId? = 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(
|
||||
SendVideoData(
|
||||
chatId,
|
||||
video.fileId,
|
||||
thumb ?.fileId,
|
||||
text,
|
||||
parseMode,
|
||||
duration,
|
||||
width,
|
||||
height,
|
||||
null,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVideo(
|
||||
chatId: ChatIdentifier,
|
||||
video: VideoFile,
|
||||
thumb: PhotoSize? = video.thumb,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(
|
||||
chatId, video.fileId, thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVideo(
|
||||
chatId: ChatIdentifier,
|
||||
video: MultipartFile,
|
||||
thumb: FileId? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
supportStreaming: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
MultipartRequestImpl(
|
||||
SendVideoData(
|
||||
chatId, null, thumb ?.fileId, text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup
|
||||
),
|
||||
SendVideoFiles(video)
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVideo(
|
||||
chatId: ChatIdentifier,
|
||||
video: MultipartFile,
|
||||
thumb: MultipartFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
supportStreaming: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
MultipartRequestImpl(
|
||||
SendVideoData(
|
||||
chatId, null, null, text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup
|
||||
),
|
||||
SendVideoFiles(video, thumb)
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVideo(
|
||||
chatId: ChatIdentifier,
|
||||
video: FileId,
|
||||
thumb: MultipartFile,
|
||||
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(
|
||||
MultipartRequestImpl(
|
||||
SendVideoData(
|
||||
chatId, video.fileId, null, text, parseMode, duration, width, height, null, disableNotification, replyToMessageId, replyMarkup
|
||||
),
|
||||
SendVideoFiles(null, thumb)
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVideo(
|
||||
chatId: ChatIdentifier,
|
||||
video: MultipartFile,
|
||||
thumb: PhotoSize? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
width: Int? = null,
|
||||
height: Int? = null,
|
||||
supportStreaming: Boolean? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(
|
||||
chatId, video, thumb ?.fileId , text, parseMode, duration, width, height, supportStreaming, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVideo(
|
||||
chatId: ChatIdentifier,
|
||||
video: VideoFile,
|
||||
thumb: MultipartFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVideo(
|
||||
chatId, video.fileId, thumb, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
|
@ -106,132 +106,3 @@ data class SendVoiceFiles internal constructor(
|
||||
voiceField to voice,
|
||||
thumbField to thumb
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVoice(
|
||||
chatId: ChatIdentifier,
|
||||
voice: FileId,
|
||||
thumb: FileId? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendVoiceData(
|
||||
chatId,
|
||||
voice.fileId,
|
||||
thumb ?.fileId,
|
||||
text,
|
||||
parseMode,
|
||||
duration,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVoice(
|
||||
chatId: ChatIdentifier,
|
||||
voice: AudioFile,
|
||||
thumb: PhotoSize? = voice.thumb,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(
|
||||
chatId, voice.fileId, thumb ?.fileId, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVoice(
|
||||
chatId: ChatIdentifier,
|
||||
voice: MultipartFile,
|
||||
thumb: FileId? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
MultipartRequestImpl(
|
||||
SendVoiceData(
|
||||
chatId, null, thumb ?.fileId, text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup
|
||||
),
|
||||
SendVoiceFiles(voice)
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVoice(
|
||||
chatId: ChatIdentifier,
|
||||
voice: MultipartFile,
|
||||
thumb: MultipartFile? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
MultipartRequestImpl(
|
||||
SendVoiceData(
|
||||
chatId, null, null, text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup
|
||||
),
|
||||
SendVoiceFiles(voice, thumb)
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVoice(
|
||||
chatId: ChatIdentifier,
|
||||
voice: FileId,
|
||||
thumb: MultipartFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
MultipartRequestImpl(
|
||||
SendVoiceData(
|
||||
chatId, voice.fileId, null, text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup
|
||||
),
|
||||
SendVoiceFiles(null, thumb)
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVoice(
|
||||
chatId: ChatIdentifier,
|
||||
voice: MultipartFile,
|
||||
thumb: PhotoSize? = null,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
duration: Long? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(
|
||||
chatId, voice, thumb ?.fileId , text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendVoice(
|
||||
chatId: ChatIdentifier,
|
||||
voice: AudioFile,
|
||||
thumb: MultipartFile,
|
||||
text: String? = null,
|
||||
parseMode: ParseMode? = null,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendVoice(
|
||||
chatId, voice.fileId, thumb, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
|
@ -106,51 +106,3 @@ data class SendInvoice(
|
||||
photoHeight = null
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.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)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.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)
|
||||
|
@ -185,136 +185,3 @@ data class SendQuizPoll(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendRegularPoll(
|
||||
chatId: ChatIdentifier,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
allowMultipleAnswers: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendRegularPoll(
|
||||
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.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,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendRegularPoll(
|
||||
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendRegularPoll(
|
||||
chat: Chat,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
allowMultipleAnswers: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendRegularPoll(
|
||||
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.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,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendRegularPoll(
|
||||
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendQuizPoll(
|
||||
chatId: ChatIdentifier,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
correctOptionId: Int,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendQuizPoll(
|
||||
chatId, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.sendQuizPoll(
|
||||
chat: Chat,
|
||||
question: String,
|
||||
options: List<String>,
|
||||
correctOptionId: Int,
|
||||
isAnonymous: Boolean = true,
|
||||
isClosed: Boolean = false,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(
|
||||
chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.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,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendQuizPoll(
|
||||
chatId, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.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,
|
||||
disableNotification: Boolean = false,
|
||||
replyToMessageId: MessageIdentifier? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendQuizPoll(
|
||||
chat.id, question, options, correctOptionId, isAnonymous, isClosed, disableNotification, replyToMessageId, replyMarkup
|
||||
)
|
||||
|
@ -50,98 +50,3 @@ data class AddStickerToSet internal constructor(
|
||||
|
||||
override fun method(): String = "addStickerToSet"
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.addStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
AddStickerToSet(
|
||||
userId, stickerSetName, emojis, sticker, maskPosition
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.addStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSetName: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = execute(
|
||||
CommonMultipartFileRequest(
|
||||
AddStickerToSet(
|
||||
userId, stickerSetName, emojis, null, maskPosition
|
||||
),
|
||||
mapOf(pngStickerField to sticker)
|
||||
)
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.addStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSetName: String,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStickerToSet(
|
||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.addStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSetName: String,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStickerToSet(
|
||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.addStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStickerToSet(
|
||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.addStickerToSet(
|
||||
userId: UserId,
|
||||
stickerSet: StickerSet,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStickerToSet(
|
||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.addStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: FileId,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStickerToSet(
|
||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.addStickerToSet(
|
||||
user: CommonUser,
|
||||
stickerSet: StickerSet,
|
||||
sticker: MultipartFile,
|
||||
emojis: String,
|
||||
maskPosition: MaskPosition? = null
|
||||
) = addStickerToSet(
|
||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
||||
)
|
||||
|
@ -14,6 +14,3 @@ class GetWebhookInfo : SimpleRequest<WebhookInfo> {
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to extracting into separated library")
|
||||
suspend fun RequestsExecutor.getWebhookInfo() = execute(GetWebhookInfo())
|
||||
|
@ -3,7 +3,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.abstracts
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatMember.RawChatMember
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
|
||||
interface ChatMember {
|
||||
val user: User
|
||||
|
@ -3,7 +3,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQue
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InlineQueryResult.abstracts.InlineQueryResult
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
|
||||
@Serializer(InlineQueryResult::class)
|
||||
internal object InlineQueryResultSerializer : KSerializer<InlineQueryResult> {
|
||||
|
@ -3,7 +3,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.InputMessageContent.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InlineQueries.abstracts.InputMessageContent
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
|
||||
@Serializer(InputMessageContent::class)
|
||||
internal object InputMessageContentSerializer : KSerializer<InputMessageContent> {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
|
||||
@Serializer(InputMedia::class)
|
||||
internal object InputMediaSerializer : KSerializer<InputMedia> {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia
|
||||
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
|
||||
@Serializer(MediaGroupMemberInputMedia::class)
|
||||
internal object MediaGroupMemberInputMediaSerializer : KSerializer<MediaGroupMemberInputMedia> {
|
||||
|
@ -3,7 +3,6 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardB
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.internal.StringDescriptor
|
||||
import kotlinx.serialization.json.*
|
||||
|
||||
internal object InlineKeyboardButtonSerializer : KSerializer<InlineKeyboardButton> {
|
||||
|
@ -2,54 +2,21 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.message
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.ChannelChat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||
|
||||
@Deprecated(
|
||||
"Renamed",
|
||||
ReplaceWith(
|
||||
"ForwardInfo",
|
||||
"com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardInfo"
|
||||
)
|
||||
)
|
||||
typealias ForwardedMessage = ForwardInfo
|
||||
sealed class ForwardInfo {
|
||||
abstract val dateOfOriginal: TelegramDate
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
"Renamed",
|
||||
ReplaceWith(
|
||||
"AnonymousForwardInfo",
|
||||
"com.github.insanusmokrassar.TelegramBotAPI.types.message.AnonymousForwardInfo"
|
||||
)
|
||||
)
|
||||
typealias AnonymousForwardedMessage = AnonymousForwardInfo
|
||||
data class AnonymousForwardInfo(
|
||||
override val dateOfOriginal: TelegramDate,
|
||||
val senderName: String
|
||||
) : ForwardInfo()
|
||||
|
||||
@Deprecated(
|
||||
"Renamed",
|
||||
ReplaceWith(
|
||||
"UserForwardInfo",
|
||||
"com.github.insanusmokrassar.TelegramBotAPI.types.message.UserForwardInfo"
|
||||
)
|
||||
)
|
||||
typealias UserForwardedMessage = UserForwardInfo
|
||||
data class UserForwardInfo(
|
||||
override val dateOfOriginal: TelegramDate,
|
||||
val from: User
|
||||
) : ForwardInfo()
|
||||
|
||||
@Deprecated(
|
||||
"Renamed",
|
||||
ReplaceWith(
|
||||
"ForwardFromChannelInfo",
|
||||
"com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardFromChannelInfo"
|
||||
)
|
||||
)
|
||||
typealias ForwardedFromChannelMessage = ForwardFromChannelInfo
|
||||
data class ForwardFromChannelInfo(
|
||||
override val dateOfOriginal: TelegramDate,
|
||||
val messageId: MessageIdentifier,
|
||||
|
@ -4,10 +4,4 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.message.ForwardInfo
|
||||
|
||||
interface PossiblyForwardedMessage : Message {
|
||||
val forwardInfo: ForwardInfo?
|
||||
@Deprecated(
|
||||
"Renamed",
|
||||
ReplaceWith("forwardInfo")
|
||||
)
|
||||
val forwarded: ForwardInfo?
|
||||
get() = forwardInfo
|
||||
}
|
@ -1,144 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.UpdatesPoller
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.GetUpdates
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.webhook.DeleteWebhook
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.UpdateIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.MediaGroupMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.executeUnsafe
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.engine.HttpClientEngine
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
|
||||
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
|
||||
fun KtorUpdatesPoller(
|
||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||
engine: HttpClientEngine,
|
||||
timeoutSeconds: Int? = null,
|
||||
oneTimeUpdatesLimit: Int? = null,
|
||||
allowedUpdates: List<String> = ALL_UPDATES_LIST,
|
||||
exceptionsHandler: (Exception) -> Boolean = { true },
|
||||
updatesReceiver: UpdateReceiver<Update>
|
||||
): KtorUpdatesPoller {
|
||||
val executor = KtorRequestsExecutor(
|
||||
telegramAPIUrlsKeeper,
|
||||
HttpClient(engine)
|
||||
)
|
||||
|
||||
return KtorUpdatesPoller(
|
||||
executor,
|
||||
timeoutSeconds,
|
||||
oneTimeUpdatesLimit,
|
||||
allowedUpdates,
|
||||
exceptionsHandler,
|
||||
updatesReceiver
|
||||
)
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
|
||||
class KtorUpdatesPoller(
|
||||
private val executor: RequestsExecutor,
|
||||
private val timeoutSeconds: Int? = null,
|
||||
private val oneTimeUpdatesLimit: Int? = null,
|
||||
private val allowedUpdates: List<String> = ALL_UPDATES_LIST,
|
||||
private val exceptionsHandler: (Exception) -> Boolean = { true },
|
||||
private val updatesReceiver: UpdateReceiver<Update>
|
||||
) : UpdatesPoller {
|
||||
private var lastHandledUpdate: UpdateIdentifier = 0L
|
||||
private val mediaGroup: MutableList<BaseMessageUpdate> = mutableListOf()
|
||||
|
||||
private var pollerJob: Job? = null
|
||||
|
||||
private suspend fun sendToBlock(data: Update) {
|
||||
updatesReceiver(data)
|
||||
lastHandledUpdate = data.updateId
|
||||
}
|
||||
|
||||
private suspend fun pushMediaGroupUpdate(update: BaseMessageUpdate? = null) {
|
||||
val inputMediaGroupId = (update ?.data as? MediaGroupMessage) ?.mediaGroupId
|
||||
if (mediaGroup.isNotEmpty() && inputMediaGroupId ?.equals(mediaGroup.mediaGroupId) != true) {
|
||||
mediaGroup.sortBy { it.updateId }
|
||||
mediaGroup.convertWithMediaGroupUpdates().forEach {
|
||||
sendToBlock(it)
|
||||
}
|
||||
mediaGroup.clear()
|
||||
}
|
||||
inputMediaGroupId ?.let {
|
||||
mediaGroup.add(update)
|
||||
} ?: sendToBlock(update ?: return)
|
||||
}
|
||||
|
||||
private suspend fun getUpdates(): List<Update> {
|
||||
return executor.execute(
|
||||
GetUpdates(
|
||||
lastHandledUpdate + 1, // incremented because offset counted from 1 when updates id from 0
|
||||
oneTimeUpdatesLimit,
|
||||
timeoutSeconds,
|
||||
allowedUpdates
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun handleUpdates(updates: List<Update>) {
|
||||
for (update in updates) {
|
||||
(update as? BaseMessageUpdate) ?.let {
|
||||
if (it.data is MediaGroupMessage) {
|
||||
pushMediaGroupUpdate(it)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} ?:let {
|
||||
pushMediaGroupUpdate()
|
||||
sendToBlock(update)
|
||||
}
|
||||
}
|
||||
|
||||
pushMediaGroupUpdate()
|
||||
}
|
||||
|
||||
private val startStopScope = CoroutineScope(Dispatchers.Default)
|
||||
private val startStopQueue = Channel<CoroutineScope?>(2)
|
||||
private val startStopJob = startStopScope.launch {
|
||||
for (scope in startStopQueue) {
|
||||
scope ?.also {
|
||||
pollerJob ?: scope.launch {
|
||||
executor.executeUnsafe(DeleteWebhook())
|
||||
while (isActive) {
|
||||
try {
|
||||
val updates = getUpdates()
|
||||
handleUpdates(updates)
|
||||
} catch (e: Exception) {
|
||||
if (exceptionsHandler(e)) {
|
||||
continue
|
||||
} else {
|
||||
close()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}.also {
|
||||
pollerJob = it
|
||||
}
|
||||
} ?: also {
|
||||
startStopQueue.close()
|
||||
pollerJob ?.cancel()
|
||||
startStopScope.cancel()
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun start(scope: CoroutineScope) {
|
||||
startStopQueue.offer(scope)
|
||||
}
|
||||
|
||||
override fun close() {
|
||||
startStopQueue.offer(null)
|
||||
}
|
||||
}
|
@ -13,49 +13,6 @@ interface UpdatesFilter {
|
||||
val allowedUpdates: List<String>
|
||||
}
|
||||
|
||||
@Deprecated(
|
||||
"It is builder function for SimpleUpdatesFilter",
|
||||
ReplaceWith(
|
||||
"SimpleUpdatesFilter",
|
||||
"com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.SimpleUpdatesFilter"
|
||||
)
|
||||
)
|
||||
fun UpdatesFilter(
|
||||
messageCallback: UpdateReceiver<MessageUpdate>? = null,
|
||||
messageMediaGroupCallback: UpdateReceiver<MessageMediaGroupUpdate>? = null,
|
||||
editedMessageCallback: UpdateReceiver<EditMessageUpdate>? = null,
|
||||
editedMessageMediaGroupCallback: UpdateReceiver<EditMessageMediaGroupUpdate>? = null,
|
||||
channelPostCallback: UpdateReceiver<ChannelPostUpdate>? = null,
|
||||
channelPostMediaGroupCallback: UpdateReceiver<ChannelPostMediaGroupUpdate>? = null,
|
||||
editedChannelPostCallback: UpdateReceiver<EditChannelPostUpdate>? = null,
|
||||
editedChannelPostMediaGroupCallback: UpdateReceiver<EditChannelPostMediaGroupUpdate>? = null,
|
||||
chosenInlineResultCallback: UpdateReceiver<ChosenInlineResultUpdate>? = null,
|
||||
inlineQueryCallback: UpdateReceiver<InlineQueryUpdate>? = null,
|
||||
callbackQueryCallback: UpdateReceiver<CallbackQueryUpdate>? = null,
|
||||
shippingQueryCallback: UpdateReceiver<ShippingQueryUpdate>? = null,
|
||||
preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
||||
pollUpdateCallback: UpdateReceiver<PollUpdate>? = null,
|
||||
pollAnswerUpdateCallback: UpdateReceiver<PollAnswerUpdate>? = null,
|
||||
unknownUpdateTypeCallback: UpdateReceiver<UnknownUpdateType>? = null
|
||||
) = SimpleUpdatesFilter(
|
||||
messageCallback,
|
||||
messageMediaGroupCallback,
|
||||
editedMessageCallback,
|
||||
editedMessageMediaGroupCallback,
|
||||
channelPostCallback,
|
||||
channelPostMediaGroupCallback,
|
||||
editedChannelPostCallback,
|
||||
editedChannelPostMediaGroupCallback,
|
||||
chosenInlineResultCallback,
|
||||
inlineQueryCallback,
|
||||
callbackQueryCallback,
|
||||
shippingQueryCallback,
|
||||
preCheckoutQueryCallback,
|
||||
pollUpdateCallback,
|
||||
pollAnswerUpdateCallback,
|
||||
unknownUpdateTypeCallback
|
||||
)
|
||||
|
||||
data class SimpleUpdatesFilter(
|
||||
private val messageCallback: UpdateReceiver<MessageUpdate>? = null,
|
||||
private val messageMediaGroupCallback: UpdateReceiver<MessageMediaGroupUpdate>? = null,
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.utils
|
||||
|
||||
import kotlin.Experimental.Level
|
||||
|
||||
@Experimental(Level.WARNING)
|
||||
@RequiresOptIn(
|
||||
"It is possible, that bevahiour of this thing will be changed later",
|
||||
RequiresOptIn.Level.WARNING
|
||||
)
|
||||
annotation class PreviewFeature
|
||||
|
@ -3,16 +3,16 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.json.*
|
||||
|
||||
val nonstrictJsonFormat = Json {
|
||||
internal val nonstrictJsonFormat = Json {
|
||||
isLenient = true
|
||||
ignoreUnknownKeys = true
|
||||
serializeSpecialFloatingPointValues = true
|
||||
useArrayPolymorphism = true
|
||||
}
|
||||
|
||||
inline fun <T: Any> T.toJsonWithoutNulls(serializer: SerializationStrategy<T>): JsonObject = toJson(serializer).withoutNulls()
|
||||
fun <T: Any> T.toJsonWithoutNulls(serializer: SerializationStrategy<T>): JsonObject = toJson(serializer).withoutNulls()
|
||||
|
||||
inline fun <T: Any> T.toJson(serializer: SerializationStrategy<T>): JsonObject = nonstrictJsonFormat.toJson(
|
||||
fun <T: Any> T.toJson(serializer: SerializationStrategy<T>): JsonObject = nonstrictJsonFormat.toJson(
|
||||
serializer,
|
||||
this
|
||||
).jsonObject
|
||||
|
@ -7,7 +7,6 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.extended.
|
||||
|
||||
private const val internalLinkBeginning = "https://t.me"
|
||||
|
||||
@PreviewFeature
|
||||
fun makeLinkToMessage(
|
||||
username: String,
|
||||
messageId: MessageIdentifier
|
||||
@ -16,7 +15,6 @@ fun makeLinkToMessage(
|
||||
private val linkIdRedundantPartRegex = Regex("^-100")
|
||||
private val usernameBeginSymbolRegex = Regex("^@")
|
||||
|
||||
@PreviewFeature
|
||||
fun makeLinkToMessage(
|
||||
chat: ExtendedChat,
|
||||
messageId: MessageIdentifier
|
||||
|
@ -1,118 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.utils.extensions
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.UpdatesPoller
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.KtorUpdatesPoller
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdatesFilter
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
@Deprecated(
|
||||
"Replaced",
|
||||
ReplaceWith(
|
||||
"UpdateReceiver",
|
||||
"com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdateReceiver"
|
||||
)
|
||||
)
|
||||
typealias UpdateReceiver<T> = com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdateReceiver<T>
|
||||
|
||||
@Deprecated("Replaced into TelegramBotAPI-extensions-api")
|
||||
fun RequestsExecutor.startGettingOfUpdates(
|
||||
timeoutMillis: Long = 30 * 1000,
|
||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
|
||||
allowedUpdates: List<String>? = null,
|
||||
block: UpdateReceiver<Update>
|
||||
): UpdatesPoller {
|
||||
return KtorUpdatesPoller(
|
||||
this,
|
||||
timeoutMillis.toInt() / 1000,
|
||||
allowedUpdates = allowedUpdates ?: ALL_UPDATES_LIST,
|
||||
updatesReceiver = block
|
||||
).also {
|
||||
it.start(scope)
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Replaced into TelegramBotAPI-extensions-api")
|
||||
fun RequestsExecutor.startGettingOfUpdates(
|
||||
messageCallback: UpdateReceiver<MessageUpdate>? = null,
|
||||
messageMediaGroupCallback: UpdateReceiver<MessageMediaGroupUpdate>? = null,
|
||||
editedMessageCallback: UpdateReceiver<EditMessageUpdate>? = null,
|
||||
editedMessageMediaGroupCallback: UpdateReceiver<EditMessageMediaGroupUpdate>? = null,
|
||||
channelPostCallback: UpdateReceiver<ChannelPostUpdate>? = null,
|
||||
channelPostMediaGroupCallback: UpdateReceiver<ChannelPostMediaGroupUpdate>? = null,
|
||||
editedChannelPostCallback: UpdateReceiver<EditChannelPostUpdate>? = null,
|
||||
editedChannelPostMediaGroupCallback: UpdateReceiver<EditChannelPostMediaGroupUpdate>? = null,
|
||||
chosenInlineResultCallback: UpdateReceiver<ChosenInlineResultUpdate>? = null,
|
||||
inlineQueryCallback: UpdateReceiver<InlineQueryUpdate>? = null,
|
||||
callbackQueryCallback: UpdateReceiver<CallbackQueryUpdate>? = null,
|
||||
shippingQueryCallback: UpdateReceiver<ShippingQueryUpdate>? = null,
|
||||
preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
||||
pollCallback: UpdateReceiver<PollUpdate>? = null,
|
||||
pollAnswerCallback: UpdateReceiver<PollAnswerUpdate>? = null,
|
||||
timeoutMillis: Long = 30 * 1000,
|
||||
scope: CoroutineScope = GlobalScope
|
||||
): UpdatesPoller {
|
||||
val filter = UpdatesFilter(
|
||||
messageCallback,
|
||||
messageMediaGroupCallback,
|
||||
editedMessageCallback,
|
||||
editedMessageMediaGroupCallback,
|
||||
channelPostCallback,
|
||||
channelPostMediaGroupCallback,
|
||||
editedChannelPostCallback,
|
||||
editedChannelPostMediaGroupCallback,
|
||||
chosenInlineResultCallback,
|
||||
inlineQueryCallback,
|
||||
callbackQueryCallback,
|
||||
shippingQueryCallback,
|
||||
preCheckoutQueryCallback,
|
||||
pollCallback,
|
||||
pollAnswerCallback
|
||||
)
|
||||
return startGettingOfUpdates(
|
||||
timeoutMillis,
|
||||
scope,
|
||||
filter.allowedUpdates,
|
||||
filter.asUpdateReceiver
|
||||
)
|
||||
}
|
||||
|
||||
@Deprecated("Replaced into TelegramBotAPI-extensions-api")
|
||||
fun RequestsExecutor.startGettingOfUpdates(
|
||||
messageCallback: UpdateReceiver<MessageUpdate>? = null,
|
||||
mediaGroupCallback: UpdateReceiver<MediaGroupUpdate>? = null,
|
||||
editedMessageCallback: UpdateReceiver<EditMessageUpdate>? = null,
|
||||
channelPostCallback: UpdateReceiver<ChannelPostUpdate>? = null,
|
||||
editedChannelPostCallback: UpdateReceiver<EditChannelPostUpdate>? = null,
|
||||
chosenInlineResultCallback: UpdateReceiver<ChosenInlineResultUpdate>? = null,
|
||||
inlineQueryCallback: UpdateReceiver<InlineQueryUpdate>? = null,
|
||||
callbackQueryCallback: UpdateReceiver<CallbackQueryUpdate>? = null,
|
||||
shippingQueryCallback: UpdateReceiver<ShippingQueryUpdate>? = null,
|
||||
preCheckoutQueryCallback: UpdateReceiver<PreCheckoutQueryUpdate>? = null,
|
||||
pollCallback: UpdateReceiver<PollUpdate>? = null,
|
||||
pollAnswerCallback: UpdateReceiver<PollAnswerUpdate>? = null,
|
||||
timeoutMillis: Long = 30 * 1000,
|
||||
scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
||||
): UpdatesPoller = startGettingOfUpdates(
|
||||
messageCallback = messageCallback,
|
||||
messageMediaGroupCallback = mediaGroupCallback,
|
||||
editedMessageCallback = editedMessageCallback,
|
||||
editedMessageMediaGroupCallback = mediaGroupCallback,
|
||||
channelPostCallback = channelPostCallback,
|
||||
channelPostMediaGroupCallback = mediaGroupCallback,
|
||||
editedChannelPostCallback = editedChannelPostCallback,
|
||||
editedChannelPostMediaGroupCallback = mediaGroupCallback,
|
||||
chosenInlineResultCallback = chosenInlineResultCallback,
|
||||
inlineQueryCallback = inlineQueryCallback,
|
||||
callbackQueryCallback = callbackQueryCallback,
|
||||
shippingQueryCallback = shippingQueryCallback,
|
||||
preCheckoutQueryCallback = preCheckoutQueryCallback,
|
||||
pollCallback = pollCallback,
|
||||
pollAnswerCallback = pollAnswerCallback,
|
||||
timeoutMillis = timeoutMillis,
|
||||
scope = scope
|
||||
)
|
@ -0,0 +1,12 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI
|
||||
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.JsonConfiguration
|
||||
|
||||
val TestsJsonFormat = Json(JsonConfiguration.Stable)
|
||||
val NonstrictTestsJsonFormat = Json {
|
||||
isLenient = true
|
||||
ignoreUnknownKeys = true
|
||||
serializeSpecialFloatingPointValues = true
|
||||
useArrayPolymorphism = true
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.TestsJsonFormat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.actions.*
|
||||
import kotlinx.serialization.ImplicitReflectionSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
@ -33,10 +34,10 @@ class BotActionTests {
|
||||
}
|
||||
|
||||
private fun checkBotActionSerializeDeserialize(example: Example) {
|
||||
val stringified = Json.plain.stringify(Example.serializer(), example)
|
||||
val stringified = TestsJsonFormat.stringify(Example.serializer(), example)
|
||||
assertEquals("{\"botAction\":\"${example.botAction.actionName}\"}", stringified)
|
||||
|
||||
val deserialized = Json.plain.parse(Example.serializer(), stringified)
|
||||
val deserialized = TestsJsonFormat.parse(Example.serializer(), stringified)
|
||||
|
||||
assertEquals(example, deserialized)
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.NonstrictTestsJsonFormat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.TestsJsonFormat
|
||||
import kotlinx.serialization.ImplicitReflectionSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
@ -55,25 +56,25 @@ class ChatIdentifierTests {
|
||||
)
|
||||
|
||||
Example(chatIdentifierChatId.toChatId()).let { withChatId ->
|
||||
val stringified = nonstrictJsonFormat.stringify(Example.serializer(), withChatId)
|
||||
val stringified = NonstrictTestsJsonFormat.stringify(Example.serializer(), withChatId)
|
||||
assertEquals(stringified, "{\"identifier\":$chatIdentifierChatId}")
|
||||
val deserialized = nonstrictJsonFormat.parse(Example.serializer(), stringified)
|
||||
val deserialized = NonstrictTestsJsonFormat.parse(Example.serializer(), stringified)
|
||||
assertEquals(withChatId, deserialized)
|
||||
}
|
||||
|
||||
Example(testUsername.toUsername()).let { withUsername ->
|
||||
val stringified = nonstrictJsonFormat.stringify(Example.serializer(), withUsername)
|
||||
val stringified = NonstrictTestsJsonFormat.stringify(Example.serializer(), withUsername)
|
||||
assertEquals(stringified, "{\"identifier\":\"$testUsername\"}")
|
||||
val deserialized = nonstrictJsonFormat.parse(Example.serializer(), stringified)
|
||||
val deserialized = NonstrictTestsJsonFormat.parse(Example.serializer(), stringified)
|
||||
assertEquals(withUsername, deserialized)
|
||||
}
|
||||
|
||||
// Replace @ by empty string, because from time to time we can retrieve from Telegram system
|
||||
// username without starting @ symbol
|
||||
Example(testUsername.toUsername()).let { withUsername ->
|
||||
val stringified = nonstrictJsonFormat.stringify(Example.serializer(), withUsername).replace("@", "")
|
||||
val stringified = NonstrictTestsJsonFormat.stringify(Example.serializer(), withUsername).replace("@", "")
|
||||
assertEquals("{\"identifier\":\"${testUsername.replace("@", "")}\"}", stringified)
|
||||
val deserialized = nonstrictJsonFormat.parse(Example.serializer(), stringified)
|
||||
val deserialized = NonstrictTestsJsonFormat.parse(Example.serializer(), stringified)
|
||||
assertEquals(withUsername, deserialized)
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.TestsJsonFormat
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
|
||||
import kotlinx.serialization.ImplicitReflectionSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
@ -18,10 +19,10 @@ class ParseModeTests {
|
||||
fun `Markdown parse mode correctly serializing and deserializing`() {
|
||||
val example = Example(Markdown)
|
||||
|
||||
val stringified = Json.plain.stringify(Example.serializer(), example)
|
||||
val stringified = TestsJsonFormat.stringify(Example.serializer(), example)
|
||||
assertEquals("{\"mode\":\"Markdown\"}", stringified)
|
||||
|
||||
val deserialized = Json.plain.parse(Example.serializer(), stringified)
|
||||
val deserialized = TestsJsonFormat.parse(Example.serializer(), stringified)
|
||||
assertEquals(example, deserialized)
|
||||
}
|
||||
|
||||
@ -29,10 +30,10 @@ class ParseModeTests {
|
||||
fun `HTML parse mode correctly serializing and deserializing`() {
|
||||
val example = Example(HTML)
|
||||
|
||||
val stringified = Json.plain.stringify(Example.serializer(), example)
|
||||
val stringified = TestsJsonFormat.stringify(Example.serializer(), example)
|
||||
assertEquals("{\"mode\":\"HTML\"}", stringified)
|
||||
|
||||
val deserialized = Json.plain.parse(Example.serializer(), stringified)
|
||||
val deserialized = TestsJsonFormat.parse(Example.serializer(), stringified)
|
||||
assertEquals(example, deserialized)
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,15 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.NonstrictTestsJsonFormat
|
||||
import com.soywiz.klock.DateTime
|
||||
import kotlinx.serialization.ImplicitReflectionSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
private val dateTimeMillis = System.currentTimeMillis()
|
||||
private val dateTimeUnix = TimeUnit.MILLISECONDS.toSeconds(dateTimeMillis)
|
||||
private val dateTime = DateTime(TimeUnit.SECONDS.toMillis(dateTimeUnix))
|
||||
private val dateTimeUnix = DateTime.nowUnixLong()
|
||||
private val dateTimeMillis = dateTimeUnix * 1000
|
||||
private val dateTime = DateTime(dateTimeMillis)
|
||||
|
||||
@ImplicitReflectionSerializer
|
||||
class TelegramDateTests {
|
||||
@ -22,10 +21,10 @@ class TelegramDateTests {
|
||||
fun `Serializtion of TelegramDate is working correctly`() {
|
||||
val example = Example(TelegramDate(dateTimeUnix))
|
||||
|
||||
val stringified = Json.plain.stringify(Example.serializer(), example)
|
||||
val stringified = NonstrictTestsJsonFormat.stringify(Example.serializer(), example)
|
||||
assertEquals("{\"dateTime\":$dateTimeUnix}", stringified)
|
||||
|
||||
val deserialized = Json.plain.parse(Example.serializer(), stringified)
|
||||
val deserialized = NonstrictTestsJsonFormat.parse(Example.serializer(), stringified)
|
||||
assertEquals(example, deserialized)
|
||||
|
||||
assertEquals(dateTime, deserialized.dateTime.asDate)
|
||||
|
@ -1,78 +0,0 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.updateshandlers
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.bot.Ktor.KtorRequestsExecutor
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ALL_UPDATES_LIST
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.TelegramAPIUrlsKeeper
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.engine.HttpClientEngine
|
||||
import io.ktor.client.engine.cio.CIO
|
||||
import io.ktor.client.engine.cio.endpoint
|
||||
import io.ktor.util.KtorExperimentalAPI
|
||||
|
||||
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
|
||||
@KtorExperimentalAPI
|
||||
fun KtorUpdatesPoller(
|
||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||
timeoutSeconds: Int? = null,
|
||||
oneTimeUpdatesLimit: Int? = null,
|
||||
allowedUpdates: List<String> = ALL_UPDATES_LIST,
|
||||
exceptionsHandler: (Exception) -> Boolean = { true },
|
||||
updatesReceiver: UpdateReceiver<Update>
|
||||
): KtorUpdatesPoller {
|
||||
val executor = KtorRequestsExecutor(
|
||||
telegramAPIUrlsKeeper,
|
||||
HttpClient(
|
||||
CIO.create {
|
||||
endpoint {
|
||||
timeoutSeconds ?.times(1000) ?.also { timeOutMillis ->
|
||||
keepAliveTime = timeOutMillis.toLong()
|
||||
}
|
||||
connectTimeout = 1000
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
return KtorUpdatesPoller(
|
||||
executor,
|
||||
timeoutSeconds,
|
||||
oneTimeUpdatesLimit,
|
||||
allowedUpdates,
|
||||
exceptionsHandler,
|
||||
updatesReceiver
|
||||
)
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated due to more simple way to get updates using TelegramBotAPI-extensions-api")
|
||||
@KtorExperimentalAPI
|
||||
fun KtorUpdatesPoller(
|
||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||
timeoutSeconds: Int? = null,
|
||||
oneTimeUpdatesLimit: Int? = null,
|
||||
allowedUpdates: List<String> = ALL_UPDATES_LIST,
|
||||
exceptionsHandler: (Exception) -> Boolean = { true },
|
||||
clientEngine: HttpClientEngine = CIO.create {
|
||||
endpoint {
|
||||
timeoutSeconds ?.times(1000) ?.also { timeOutMillis ->
|
||||
keepAliveTime = timeOutMillis.toLong()
|
||||
}
|
||||
connectTimeout = 1000
|
||||
}
|
||||
},
|
||||
updatesReceiver: UpdateReceiver<Update>
|
||||
): KtorUpdatesPoller {
|
||||
val executor = KtorRequestsExecutor(
|
||||
telegramAPIUrlsKeeper,
|
||||
HttpClient(clientEngine)
|
||||
)
|
||||
|
||||
return KtorUpdatesPoller(
|
||||
executor,
|
||||
timeoutSeconds,
|
||||
oneTimeUpdatesLimit,
|
||||
allowedUpdates,
|
||||
exceptionsHandler,
|
||||
updatesReceiver
|
||||
)
|
||||
}
|
@ -8,9 +8,11 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.update.MediaGroupUpdates
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.RawUpdate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.BaseMessageUpdate
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.update.abstracts.Update
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdateReceiver
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.UpdatesFilter
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.updateshandlers.webhook.WebhookPrivateKeyConfig
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.convertWithMediaGroupUpdates
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.nonstrictJsonFormat
|
||||
import io.ktor.application.call
|
||||
import io.ktor.request.receiveText
|
||||
import io.ktor.response.respond
|
||||
@ -73,8 +75,8 @@ suspend fun RequestsExecutor.setWebhook(
|
||||
module {
|
||||
routing {
|
||||
post(listenRoute) {
|
||||
val asJson = Json.nonstrict.parseJson(call.receiveText())
|
||||
val update = Json.nonstrict.fromJson(
|
||||
val asJson = nonstrictJsonFormat.parseJson(call.receiveText())
|
||||
val update = nonstrictJsonFormat.fromJson(
|
||||
RawUpdate.serializer(),
|
||||
asJson
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user