1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-11-16 12:00:18 +00:00

Compare commits

..

8 Commits
5.0.0 ... 4.2.4

62 changed files with 213 additions and 961 deletions

View File

@@ -1,7 +1,5 @@
# TelegramBotAPI changelog
## 5.0.0
## 4.2.4
* `Core`:

View File

@@ -6,4 +6,4 @@ kotlin.incremental=true
kotlin.incremental.js=true
library_group=dev.inmo
library_version=5.0.0
library_version=4.2.4

View File

@@ -1,19 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
suspend fun TelegramBot.closeGeneralForumTopic(
chatId: ChatIdentifier
) = execute(
CloseGeneralForumTopic(chatId)
)
suspend fun TelegramBot.closeGeneralForumTopic(
chat: Chat
) = closeGeneralForumTopic(chat.id)

View File

@@ -11,8 +11,8 @@ import dev.inmo.tgbotapi.types.chat.Chat
suspend fun TelegramBot.editForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId,
name: String? = null,
iconEmojiId: CustomEmojiId? = null
name: String,
iconEmojiId: CustomEmojiId
) = execute(
EditForumTopic(
chatId,
@@ -25,12 +25,12 @@ suspend fun TelegramBot.editForumTopic(
suspend fun TelegramBot.editForumTopic(
chat: Chat,
messageThreadId: MessageThreadId,
name: String? = null,
iconEmojiId: CustomEmojiId? = null
name: String,
iconEmojiId: CustomEmojiId
) = editForumTopic(chat.id, messageThreadId, name, iconEmojiId)
suspend fun TelegramBot.editForumTopic(
chatIdentifier: ChatIdentifier,
forumTopic: ForumTopic,
iconEmojiId: CustomEmojiId? = forumTopic.iconEmojiId
iconEmojiId: CustomEmojiId = forumTopic.iconEmojiId ?: error("Icon emoji id in forum topic should be presented when edit forum topic basing on other forum topic object")
) = editForumTopic(chatIdentifier, forumTopic.messageThreadId, forumTopic.name, iconEmojiId)

View File

@@ -1,30 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.EditForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.EditGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.CustomEmojiId
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
suspend fun TelegramBot.editGeneralForumTopic(
chatId: ChatIdentifier,
name: String
) = execute(
EditGeneralForumTopic(
chatId,
name
)
)
suspend fun TelegramBot.editGeneralForumTopic(
chat: Chat,
name: String
) = editGeneralForumTopic(chat.id, name)
suspend fun TelegramBot.editGeneralForumTopic(
chatIdentifier: ChatIdentifier,
forumTopic: ForumTopic,
) = editGeneralForumTopic(chatIdentifier, forumTopic.name)

View File

@@ -1,20 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.HideGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
suspend fun TelegramBot.hideGeneralForumTopic(
chatId: ChatIdentifier
) = execute(
HideGeneralForumTopic(chatId)
)
suspend fun TelegramBot.hideGeneralForumTopic(
chat: Chat
) = hideGeneralForumTopic(chat.id)

View File

@@ -1,19 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.ReopenForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.ReopenGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
suspend fun TelegramBot.reopenGeneralForumTopic(
chatId: ChatIdentifier
) = execute(
ReopenGeneralForumTopic(chatId)
)
suspend fun TelegramBot.reopenGeneralForumTopic(
chat: Chat
) = reopenGeneralForumTopic(chat.id)

View File

@@ -1,21 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.CloseGeneralForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.HideGeneralForumTopic
import dev.inmo.tgbotapi.requests.chat.forum.UnhideGeneralForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
suspend fun TelegramBot.unhideGeneralForumTopic(
chatId: ChatIdentifier
) = execute(
UnhideGeneralForumTopic(chatId)
)
suspend fun TelegramBot.unhideGeneralForumTopic(
chat: Chat
) = unhideGeneralForumTopic(chat.id)

View File

@@ -379,7 +379,6 @@ suspend inline fun TelegramBot.replyWithAnimation(
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -393,7 +392,6 @@ suspend inline fun TelegramBot.replyWithAnimation(
thumb,
text,
parseMode,
spoilered,
duration,
width,
height,
@@ -410,7 +408,6 @@ suspend inline fun TelegramBot.reply(
animation: AnimationFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -418,13 +415,12 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(to.chat, animation, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(to.chat, animation, text, parseMode, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithAnimation(
to: Message,
animation: InputFile,
entities: TextSourcesList,
spoilered: Boolean = false,
thumb: InputFile? = null,
duration: Long? = null,
width: Int? = null,
@@ -438,7 +434,6 @@ suspend inline fun TelegramBot.replyWithAnimation(
animation,
thumb,
entities,
spoilered,
duration,
width,
height,
@@ -454,7 +449,6 @@ suspend inline fun TelegramBot.reply(
to: Message,
animation: AnimationFile,
entities: TextSourcesList,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -462,7 +456,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(to.chat, animation, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(to.chat, animation, entities, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Audio
@@ -614,70 +608,64 @@ suspend inline fun TelegramBot.replyWithPhoto(
fileId: InputFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, fileId, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(to.chat, fileId, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
photo: Photo,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, photo, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(to.chat, photo, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
photoSize: PhotoSize,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, photoSize, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(to.chat, photoSize, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithPhoto(
to: Message,
fileId: InputFile,
entities: TextSourcesList,
spoilered: Boolean = false,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, fileId, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(to.chat, fileId, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
photo: Photo,
entities: TextSourcesList,
spoilered: Boolean = false,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, photo, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(to.chat, photo, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
photoSize: PhotoSize,
entities: TextSourcesList,
spoilered: Boolean = false,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, photoSize, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(to.chat, photoSize, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Sticker
@@ -709,7 +697,6 @@ suspend inline fun TelegramBot.replyWithVideo(
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -717,26 +704,24 @@ suspend inline fun TelegramBot.replyWithVideo(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(to.chat, video, thumb, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(to.chat, video, thumb, text, parseMode, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
video: VideoFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(to.chat, video, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(to.chat, video, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithVideo(
to: Message,
video: InputFile,
thumb: InputFile? = null,
entities: TextSourcesList,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -744,18 +729,17 @@ suspend inline fun TelegramBot.replyWithVideo(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(to.chat, video, thumb, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(to.chat, video, thumb, entities, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
video: VideoFile,
entities: TextSourcesList,
spoilered: Boolean = false,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(to.chat, video, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(to.chat, video, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// VideoNotes

View File

@@ -410,7 +410,6 @@ suspend inline fun TelegramBot.replyWithAnimation(
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -425,7 +424,6 @@ suspend inline fun TelegramBot.replyWithAnimation(
thumb,
text,
parseMode,
spoilered,
duration,
width,
height,
@@ -443,7 +441,6 @@ suspend inline fun TelegramBot.reply(
animation: AnimationFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -452,14 +449,13 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(toChatId, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(toChatId, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithAnimation(
toChatId: IdChatIdentifier,
toMessageId: MessageId,
animation: InputFile,
entities: TextSourcesList,
spoilered: Boolean = false,
thumb: InputFile? = null,
duration: Long? = null,
width: Int? = null,
@@ -474,7 +470,6 @@ suspend inline fun TelegramBot.replyWithAnimation(
animation,
thumb,
entities,
spoilered,
duration,
width,
height,
@@ -491,7 +486,6 @@ suspend inline fun TelegramBot.reply(
toMessageId: MessageId,
animation: AnimationFile,
entities: TextSourcesList,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -500,7 +494,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(toChatId, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(toChatId, animation, entities, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
// Audio
@@ -677,13 +671,12 @@ suspend inline fun TelegramBot.replyWithPhoto(
fileId: InputFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(toChatId, fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(toChatId, fileId, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
toChatId: IdChatIdentifier,
@@ -691,13 +684,12 @@ suspend inline fun TelegramBot.reply(
photo: Photo,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(toChatId, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(toChatId, photo, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
toChatId: IdChatIdentifier,
@@ -705,13 +697,12 @@ suspend inline fun TelegramBot.reply(
photoSize: PhotoSize,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(toChatId, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(toChatId, photoSize, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithPhoto(
@@ -719,39 +710,36 @@ suspend inline fun TelegramBot.replyWithPhoto(
toMessageId: MessageId,
fileId: InputFile,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(toChatId, fileId, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(toChatId, fileId, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
toChatId: IdChatIdentifier,
toMessageId: MessageId,
photo: Photo,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(toChatId, photo, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(toChatId, photo, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
toChatId: IdChatIdentifier,
toMessageId: MessageId,
photoSize: PhotoSize,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(toChatId, photoSize, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(toChatId, photoSize, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
// Sticker
@@ -788,7 +776,6 @@ suspend inline fun TelegramBot.replyWithVideo(
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -797,7 +784,7 @@ suspend inline fun TelegramBot.replyWithVideo(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(toChatId, video, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(toChatId, video, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
toChatId: IdChatIdentifier,
@@ -805,13 +792,12 @@ suspend inline fun TelegramBot.reply(
video: VideoFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(toChatId, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(toChatId, video, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithVideo(
toChatId: IdChatIdentifier,
@@ -819,7 +805,6 @@ suspend inline fun TelegramBot.replyWithVideo(
video: InputFile,
thumb: InputFile? = null,
entities: TextSourcesList,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -828,20 +813,19 @@ suspend inline fun TelegramBot.replyWithVideo(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(toChatId, video, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(toChatId, video, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
toChatId: IdChatIdentifier,
toMessageId: MessageId,
video: VideoFile,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(toChatId, video, entities, spoilered, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(toChatId, video, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
// VideoNotes

View File

@@ -3,129 +3,104 @@ package dev.inmo.tgbotapi.extensions.api.send
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.send.SendAction
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.actions.*
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.threadId
suspend fun TelegramBot.sendBotAction(
chatId: ChatIdentifier,
action: BotAction,
threadId: MessageThreadId? = chatId.threadId
action: BotAction
) = execute(
SendAction(chatId, action, threadId)
SendAction(chatId, action)
)
suspend fun TelegramBot.sendBotAction(
chat: Chat,
action: BotAction,
threadId: MessageThreadId? = chat.id.threadId
) = sendBotAction(chat.id, action, threadId)
action: BotAction
) = sendBotAction(chat.id, action)
suspend fun TelegramBot.sendActionTyping(
chatId: ChatIdentifier,
threadId: MessageThreadId? = chatId.threadId
) = sendBotAction(chatId, TypingAction, threadId)
chatId: ChatIdentifier
) = sendBotAction(chatId, TypingAction)
suspend fun TelegramBot.sendActionUploadPhoto(
chatId: ChatIdentifier,
threadId: MessageThreadId? = chatId.threadId
) = sendBotAction(chatId, UploadPhotoAction, threadId)
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadPhotoAction)
suspend fun TelegramBot.sendActionRecordVideo(
chatId: ChatIdentifier,
threadId: MessageThreadId? = chatId.threadId
) = sendBotAction(chatId, RecordVideoAction, threadId)
chatId: ChatIdentifier
) = sendBotAction(chatId, RecordVideoAction)
suspend fun TelegramBot.sendActionUploadVideo(
chatId: ChatIdentifier,
threadId: MessageThreadId? = chatId.threadId
) = sendBotAction(chatId, UploadVideoAction, threadId)
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadVideoAction)
suspend fun TelegramBot.sendActionRecordVoice(
chatId: ChatIdentifier,
threadId: MessageThreadId? = chatId.threadId
) = sendBotAction(chatId, RecordVoiceAction, threadId)
chatId: ChatIdentifier
) = sendBotAction(chatId, RecordVoiceAction)
suspend fun TelegramBot.sendActionUploadVoice(
chatId: ChatIdentifier,
threadId: MessageThreadId? = chatId.threadId
) = sendBotAction(chatId, UploadVoiceAction, threadId)
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadVoiceAction)
suspend fun TelegramBot.sendActionUploadDocument(
chatId: ChatIdentifier,
threadId: MessageThreadId? = chatId.threadId
) = sendBotAction(chatId, UploadDocumentAction, threadId)
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadDocumentAction)
suspend fun TelegramBot.sendActionFindLocation(
chatId: ChatIdentifier,
threadId: MessageThreadId? = chatId.threadId
) = sendBotAction(chatId, FindLocationAction, threadId)
chatId: ChatIdentifier
) = sendBotAction(chatId, FindLocationAction)
suspend fun TelegramBot.sendActionRecordVideoNote(
chatId: ChatIdentifier,
threadId: MessageThreadId? = chatId.threadId
) = sendBotAction(chatId, RecordVideoNoteAction, threadId)
chatId: ChatIdentifier
) = sendBotAction(chatId, RecordVideoNoteAction)
suspend fun TelegramBot.sendActionUploadVideoNote(
chatId: ChatIdentifier,
threadId: MessageThreadId? = chatId.threadId
) = sendBotAction(chatId, UploadVideoNoteAction, threadId)
chatId: ChatIdentifier
) = sendBotAction(chatId, UploadVideoNoteAction)
suspend fun TelegramBot.sendActionTyping(
chat: Chat,
threadId: MessageThreadId? = chat.id.threadId
) = sendBotAction(chat, TypingAction, threadId)
chat: Chat
) = sendBotAction(chat, TypingAction)
suspend fun TelegramBot.sendActionUploadPhoto(
chat: Chat,
threadId: MessageThreadId? = chat.id.threadId
) = sendBotAction(chat, UploadPhotoAction, threadId)
chat: Chat
) = sendBotAction(chat, UploadPhotoAction)
suspend fun TelegramBot.sendActionRecordVideo(
chat: Chat,
threadId: MessageThreadId? = chat.id.threadId
) = sendBotAction(chat, RecordVideoAction, threadId)
chat: Chat
) = sendBotAction(chat, RecordVideoAction)
suspend fun TelegramBot.sendActionUploadVideo(
chat: Chat,
threadId: MessageThreadId? = chat.id.threadId
) = sendBotAction(chat, UploadVideoAction, threadId)
chat: Chat
) = sendBotAction(chat, UploadVideoAction)
suspend fun TelegramBot.sendActionRecordVoice(
chat: Chat,
threadId: MessageThreadId? = chat.id.threadId
) = sendBotAction(chat, RecordVoiceAction, threadId)
chat: Chat
) = sendBotAction(chat, RecordVoiceAction)
suspend fun TelegramBot.sendActionUploadVoice(
chat: Chat,
threadId: MessageThreadId? = chat.id.threadId
) = sendBotAction(chat, UploadVoiceAction, threadId)
chat: Chat
) = sendBotAction(chat, UploadVoiceAction)
suspend fun TelegramBot.sendActionUploadDocument(
chat: Chat,
threadId: MessageThreadId? = chat.id.threadId
) = sendBotAction(chat, UploadDocumentAction, threadId)
chat: Chat
) = sendBotAction(chat, UploadDocumentAction)
suspend fun TelegramBot.sendActionFindLocation(
chat: Chat,
threadId: MessageThreadId? = chat.id.threadId
) = sendBotAction(chat, FindLocationAction, threadId)
chat: Chat
) = sendBotAction(chat, FindLocationAction)
suspend fun TelegramBot.sendActionRecordVideoNote(
chat: Chat,
threadId: MessageThreadId? = chat.id.threadId
) = sendBotAction(chat, RecordVideoNoteAction, threadId)
chat: Chat
) = sendBotAction(chat, RecordVideoNoteAction)
suspend fun TelegramBot.sendActionUploadVideoNote(
chat: Chat,
threadId: MessageThreadId? = chat.id.threadId
) = sendBotAction(chat, UploadVideoNoteAction, threadId)
chat: Chat
) = sendBotAction(chat, UploadVideoNoteAction)
suspend fun TelegramBot.sendActionChooseStickerAction(
chat: Chat,
threadId: MessageThreadId? = chat.id.threadId
) = sendBotAction(chat, ChooseStickerAction, threadId)
chat: Chat
) = sendBotAction(chat, ChooseStickerAction)

View File

@@ -38,14 +38,13 @@ suspend fun <T> TelegramBot.withAction(
suspend fun <T> TelegramBot.withAction(
chatId: IdChatIdentifier,
action: BotAction,
threadId: MessageThreadId? = chatId.threadId,
block: TelegramBotActionCallback<T>
): T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(
SendAction(chatId, action, threadId),
SendAction(chatId, action),
block
)
}
@@ -54,7 +53,6 @@ suspend fun <T> TelegramBot.withAction(
suspend fun <T> TelegramBot.withAction(
chat: Chat,
action: BotAction,
threadId: MessageThreadId? = chat.id.threadId,
block: TelegramBotActionCallback<T>
): T {
contract {
@@ -63,164 +61,163 @@ suspend fun <T> TelegramBot.withAction(
return withAction(
chat.id,
action,
threadId,
block
)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withTypingAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withTypingAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chatId, TypingAction, threadId, block)
return withAction(chatId, TypingAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadPhotoAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withUploadPhotoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chatId, UploadPhotoAction, threadId, block)
return withAction(chatId, UploadPhotoAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withRecordVideoAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withRecordVideoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chatId, RecordVideoAction, threadId, block)
return withAction(chatId, RecordVideoAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadVideoAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withUploadVideoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chatId, UploadVideoAction, threadId, block)
return withAction(chatId, UploadVideoAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withRecordVoiceAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withRecordVoiceAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chatId, RecordVoiceAction, threadId, block)
return withAction(chatId, RecordVoiceAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadVoiceAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withUploadVoiceAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chatId, UploadVoiceAction, threadId, block)
return withAction(chatId, UploadVoiceAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadDocumentAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withUploadDocumentAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chatId, UploadDocumentAction, threadId, block)
return withAction(chatId, UploadDocumentAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withFindLocationAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withFindLocationAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chatId, FindLocationAction, threadId, block)
return withAction(chatId, FindLocationAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chatId, RecordVideoNoteAction, threadId, block)
return withAction(chatId, RecordVideoNoteAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chatId, UploadVideoNoteAction, threadId, block)
return withAction(chatId, UploadVideoNoteAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withChooseStickerAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withChooseStickerAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chatId, ChooseStickerAction, threadId, block)
return withAction(chatId, ChooseStickerAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withTypingAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withTypingAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chat, TypingAction, threadId, block)
return withAction(chat, TypingAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadPhotoAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withUploadPhotoAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chat, UploadPhotoAction, threadId, block)
return withAction(chat, UploadPhotoAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withRecordVideoAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withRecordVideoAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chat, RecordVideoAction, threadId, block)
return withAction(chat, RecordVideoAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadVideoAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withUploadVideoAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chat, UploadVideoAction, threadId, block)
return withAction(chat, UploadVideoAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withRecordVoiceAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withRecordVoiceAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chat, RecordVoiceAction, threadId, block)
return withAction(chat, RecordVoiceAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadVoiceAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withUploadVoiceAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chat, UploadVoiceAction, threadId, block)
return withAction(chat, UploadVoiceAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadDocumentAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withUploadDocumentAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chat, UploadDocumentAction, threadId, block)
return withAction(chat, UploadDocumentAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withFindLocationAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withFindLocationAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chat, FindLocationAction, threadId, block)
return withAction(chat, FindLocationAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chat, RecordVideoNoteAction, threadId, block)
return withAction(chat, RecordVideoNoteAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chat, UploadVideoNoteAction, threadId, block)
return withAction(chat, UploadVideoNoteAction, block)
}
@OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withChooseStickerAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
suspend fun <T> TelegramBot.withChooseStickerAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return withAction(chat, ChooseStickerAction, threadId, block)
return withAction(chat, ChooseStickerAction, block)
}

View File

@@ -56,7 +56,6 @@ suspend fun TelegramBot.send(
animation: AnimationFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -66,7 +65,7 @@ suspend fun TelegramBot.send(
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(chatId, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(chatId, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendAnimation] request
@@ -78,7 +77,6 @@ suspend fun TelegramBot.send(
animation: AnimationFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -88,7 +86,7 @@ suspend fun TelegramBot.send(
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(chat, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(chat, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendAnimation] request
@@ -99,7 +97,6 @@ suspend fun TelegramBot.send(
chatId: ChatIdentifier,
animation: AnimationFile,
entities: TextSourcesList,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -109,7 +106,7 @@ suspend fun TelegramBot.send(
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(chatId, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(chatId, animation, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendAnimation] request
@@ -120,7 +117,6 @@ suspend fun TelegramBot.send(
chat: Chat,
animation: AnimationFile,
entities: TextSourcesList,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -130,7 +126,7 @@ suspend fun TelegramBot.send(
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(chat, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(chat, animation, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendAudio] request
@@ -692,14 +688,13 @@ suspend fun TelegramBot.send(
photo: Photo,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chatId, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chatId, photo, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendPhoto] request
@@ -711,14 +706,13 @@ suspend fun TelegramBot.send(
photo: Photo,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat, photo, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendPhoto] request
@@ -730,14 +724,13 @@ suspend fun TelegramBot.send(
photoSize: PhotoSize,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chatId, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chatId, photoSize, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendPhoto] request
@@ -749,14 +742,13 @@ suspend fun TelegramBot.send(
photoSize: PhotoSize,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat, photoSize, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendPhoto] request
@@ -767,14 +759,13 @@ suspend inline fun TelegramBot.send(
chatId: ChatIdentifier,
photo: Photo,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chatId, photo, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chatId, photo, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendPhoto] request
@@ -785,14 +776,13 @@ suspend inline fun TelegramBot.send(
chat: Chat,
photo: Photo,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat, photo, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat, photo, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendPhoto] request
@@ -803,14 +793,13 @@ suspend inline fun TelegramBot.send(
chatId: ChatIdentifier,
photoSize: PhotoSize,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chatId, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chatId, photoSize, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendPhoto] request
@@ -821,14 +810,13 @@ suspend inline fun TelegramBot.send(
chat: Chat,
photoSize: PhotoSize,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat, photoSize, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendRegularPoll] request
@@ -1369,14 +1357,13 @@ suspend fun TelegramBot.send(
video: VideoFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chatId, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chatId, video, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendVideo] request
@@ -1388,14 +1375,13 @@ suspend fun TelegramBot.send(
video: VideoFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chat, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chat, video, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendVideo] request
@@ -1406,14 +1392,13 @@ suspend inline fun TelegramBot.send(
chatId: ChatIdentifier,
video: VideoFile,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chatId, video, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chatId, video, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendVideo] request
@@ -1424,14 +1409,13 @@ suspend inline fun TelegramBot.send(
chat: Chat,
video: VideoFile,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chat, video, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chat, video, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* Will execute [sendVideoNote] request

View File

@@ -23,7 +23,6 @@ suspend fun TelegramBot.sendAnimation(
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -40,7 +39,6 @@ suspend fun TelegramBot.sendAnimation(
thumb,
text,
parseMode,
spoilered,
duration,
width,
height,
@@ -62,7 +60,6 @@ suspend fun TelegramBot.sendAnimation(
animation: AnimationFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -73,7 +70,7 @@ suspend fun TelegramBot.sendAnimation(
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(
chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@@ -86,7 +83,6 @@ suspend fun TelegramBot.sendAnimation(
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -96,7 +92,7 @@ suspend fun TelegramBot.sendAnimation(
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(chat.id, animation, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(chat.id, animation, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@@ -107,7 +103,6 @@ suspend fun TelegramBot.sendAnimation(
animation: AnimationFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -117,7 +112,7 @@ suspend fun TelegramBot.sendAnimation(
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(chat.id, animation, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(chat.id, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@@ -129,7 +124,6 @@ suspend fun TelegramBot.sendAnimation(
animation: InputFile,
thumb: InputFile? = null,
entities: TextSourcesList,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -145,7 +139,6 @@ suspend fun TelegramBot.sendAnimation(
animation,
thumb,
entities,
spoilered,
duration,
width,
height,
@@ -166,7 +159,6 @@ suspend fun TelegramBot.sendAnimation(
chatId: ChatIdentifier,
animation: AnimationFile,
entities: TextSourcesList,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -177,7 +169,7 @@ suspend fun TelegramBot.sendAnimation(
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(
chatId, animation.fileId, animation.thumb ?.fileId, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, animation.fileId, animation.thumb ?.fileId, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@@ -189,7 +181,6 @@ suspend fun TelegramBot.sendAnimation(
animation: InputFile,
thumb: InputFile? = null,
entities: TextSourcesList,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -199,7 +190,7 @@ suspend fun TelegramBot.sendAnimation(
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(chat.id, animation, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(chat.id, animation, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@@ -209,7 +200,6 @@ suspend fun TelegramBot.sendAnimation(
chat: Chat,
animation: AnimationFile,
entities: TextSourcesList,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -219,4 +209,4 @@ suspend fun TelegramBot.sendAnimation(
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(chat.id, animation, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(chat.id, animation, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@@ -22,7 +22,6 @@ suspend fun TelegramBot.sendPhoto(
fileId: InputFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
@@ -35,7 +34,6 @@ suspend fun TelegramBot.sendPhoto(
fileId,
text,
parseMode,
spoilered,
threadId,
disableNotification,
protectContent,
@@ -54,14 +52,13 @@ suspend fun TelegramBot.sendPhoto(
fileId: InputFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat.id, fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat.id, fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@@ -72,14 +69,13 @@ suspend fun TelegramBot.sendPhoto(
photo: Photo,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@@ -90,14 +86,13 @@ suspend fun TelegramBot.sendPhoto(
photo: Photo,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat.id, photo, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat.id, photo, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@@ -108,14 +103,13 @@ suspend fun TelegramBot.sendPhoto(
photoSize: PhotoSize,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chatId, photoSize.fileId, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chatId, photoSize.fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@@ -126,14 +120,13 @@ suspend fun TelegramBot.sendPhoto(
photoSize: PhotoSize,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat.id, photoSize, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat.id, photoSize, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@@ -144,7 +137,6 @@ suspend inline fun TelegramBot.sendPhoto(
chatId: ChatIdentifier,
fileId: InputFile,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
@@ -156,7 +148,6 @@ suspend inline fun TelegramBot.sendPhoto(
chatId,
fileId,
entities,
spoilered,
threadId,
disableNotification,
protectContent,
@@ -174,14 +165,13 @@ suspend inline fun TelegramBot.sendPhoto(
chat: Chat,
fileId: InputFile,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat.id, fileId, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat.id, fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@@ -191,14 +181,13 @@ suspend inline fun TelegramBot.sendPhoto(
chatId: ChatIdentifier,
photo: Photo,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@@ -208,14 +197,13 @@ suspend inline fun TelegramBot.sendPhoto(
chat: Chat,
photo: Photo,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat.id, photo, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat.id, photo, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@@ -225,14 +213,13 @@ suspend inline fun TelegramBot.sendPhoto(
chatId: ChatIdentifier,
photoSize: PhotoSize,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chatId, photoSize.fileId, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chatId, photoSize.fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@@ -242,11 +229,10 @@ suspend inline fun TelegramBot.sendPhoto(
chat: Chat,
photoSize: PhotoSize,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat.id, photoSize, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat.id, photoSize, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@@ -23,7 +23,6 @@ suspend fun TelegramBot.sendVideo(
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -40,7 +39,6 @@ suspend fun TelegramBot.sendVideo(
thumb,
text,
parseMode,
spoilered,
duration,
width,
height,
@@ -63,14 +61,13 @@ suspend fun TelegramBot.sendVideo(
video: VideoFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@@ -82,7 +79,6 @@ suspend fun TelegramBot.sendVideo(
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -92,7 +88,7 @@ suspend fun TelegramBot.sendVideo(
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chat.id, video, thumb, text, parseMode, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chat.id, video, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@@ -104,14 +100,13 @@ suspend fun TelegramBot.sendVideo(
video: VideoFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chat.id, video, text, parseMode, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chat.id, video, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@@ -122,7 +117,6 @@ suspend inline fun TelegramBot.sendVideo(
video: InputFile,
thumb: InputFile? = null,
entities: TextSourcesList,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -138,7 +132,6 @@ suspend inline fun TelegramBot.sendVideo(
video,
thumb,
entities,
spoilered,
duration,
width,
height,
@@ -160,14 +153,13 @@ suspend inline fun TelegramBot.sendVideo(
chatId: ChatIdentifier,
video: VideoFile,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, entities, spoilered, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, entities, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@@ -178,7 +170,6 @@ suspend inline fun TelegramBot.sendVideo(
video: InputFile,
thumb: InputFile? = null,
entities: TextSourcesList,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -188,7 +179,7 @@ suspend inline fun TelegramBot.sendVideo(
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chat.id, video, thumb, entities, spoilered, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chat.id, video, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@@ -199,11 +190,10 @@ suspend inline fun TelegramBot.sendVideo(
chat: Chat,
video: VideoFile,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chat.id, video, entities, spoilered, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chat.id, video, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@@ -9,11 +9,7 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicEdited
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicHidden
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicUnhidden
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
@@ -155,19 +151,3 @@ suspend fun BehaviourContext.waitForumTopicReopened(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<ForumTopicReopened>(initRequest, errorFactory)
suspend fun BehaviourContext.waitForumTopicEdited(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<ForumTopicEdited>(initRequest, errorFactory)
suspend fun BehaviourContext.waitGeneralForumTopicHidden(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<GeneralForumTopicHidden>(initRequest, errorFactory)
suspend fun BehaviourContext.waitGeneralForumTopicUnhidden(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<GeneralForumTopicUnhidden>(initRequest, errorFactory)
suspend fun BehaviourContext.waitWriteAccessAllowed(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<WriteAccessAllowed>(initRequest, errorFactory)

View File

@@ -13,11 +13,7 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicEdited
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicHidden
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicUnhidden
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
import dev.inmo.tgbotapi.types.message.PrivateEventMessage
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
@@ -579,81 +575,3 @@ suspend fun <BC : BehaviourContext> BC.onForumTopicReopened(
markerFactory: MarkerFactory<in ChatEventMessage<ForumTopicReopened>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, SupergroupEventMessage<ForumTopicReopened>>
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onForumTopicEdited(
initialFilter: SimpleFilter<SupergroupEventMessage<ForumTopicEdited>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, SupergroupEventMessage<ForumTopicEdited>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<ForumTopicEdited>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, SupergroupEventMessage<ForumTopicEdited>>
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onGeneralForumTopicHidden(
initialFilter: SimpleFilter<SupergroupEventMessage<GeneralForumTopicHidden>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, SupergroupEventMessage<GeneralForumTopicHidden>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<GeneralForumTopicHidden>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, SupergroupEventMessage<GeneralForumTopicHidden>>
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onGeneralForumTopicUnhidden(
initialFilter: SimpleFilter<SupergroupEventMessage<GeneralForumTopicUnhidden>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, SupergroupEventMessage<GeneralForumTopicUnhidden>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<GeneralForumTopicUnhidden>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, SupergroupEventMessage<GeneralForumTopicUnhidden>>
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onWriteAccessAllowed(
initialFilter: SimpleFilter<SupergroupEventMessage<WriteAccessAllowed>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, SupergroupEventMessage<WriteAccessAllowed>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<WriteAccessAllowed>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, SupergroupEventMessage<WriteAccessAllowed>>
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)

View File

@@ -1,5 +0,0 @@
package dev.inmo.tgbotapi.abstracts
interface SpoilerableData {
val spoilered: Boolean
}

View File

@@ -1,18 +0,0 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable
data class CloseGeneralForumTopic (
@SerialName(chatIdField)
override val chatId: ChatIdentifier
): ModifyForumRequest, GeneralForumRequest<Boolean> {
override fun method(): String = "closeGeneralForumTopic"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -1,7 +1,11 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable
data class EditForumTopic (
@@ -10,12 +14,12 @@ data class EditForumTopic (
@SerialName(messageThreadIdField)
val messageThreadId: MessageThreadId,
@SerialName(nameField)
val name: String? = null,
val name: String,
@SerialName(iconCustomEmojiIdField)
val iconEmojiId: CustomEmojiId? = null,
val iconEmojiId: CustomEmojiId,
): ModifyForumRequest {
init {
if (name != null && name.length !in threadNameLength) {
if (name.length !in threadNameLength) {
throw IllegalArgumentException("Thread name must be in $threadNameLength range")
}
}

View File

@@ -1,22 +0,0 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.types.*
import kotlinx.serialization.*
@Serializable
data class EditGeneralForumTopic (
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
@SerialName(nameField)
val name: String
): ModifyForumRequest, GeneralForumRequest<Boolean> {
init {
if (name.length !in threadNameLength) {
throw IllegalArgumentException("Thread name must be in $threadNameLength range")
}
}
override fun method(): String = "editGeneralForumTopic"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -1,6 +0,0 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
sealed interface GeneralForumRequest<T : Any> : ForumRequest<T>, ChatRequest

View File

@@ -1,18 +0,0 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable
data class HideGeneralForumTopic (
@SerialName(chatIdField)
override val chatId: ChatIdentifier
): ModifyForumRequest, GeneralForumRequest<Boolean> {
override fun method(): String = "hideGeneralForumTopic"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -1,18 +0,0 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable
data class ReopenGeneralForumTopic (
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
): ModifyForumRequest, GeneralForumRequest<Boolean> {
override fun method(): String = "reopenGeneralForumTopic"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -1,18 +0,0 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable
data class UnhideGeneralForumTopic (
@SerialName(chatIdField)
override val chatId: ChatIdentifier
): ModifyForumRequest, GeneralForumRequest<Boolean> {
override fun method(): String = "unhideGeneralForumTopic"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -1,6 +1,5 @@
package dev.inmo.tgbotapi.requests.send
import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyMessageThreadRequest
import dev.inmo.tgbotapi.requests.send.abstracts.SendChatMessageRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.actions.BotAction
@@ -15,10 +14,8 @@ data class SendAction(
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
@SerialName(actionField)
val action: BotAction,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = chatId.threadId
): SendChatMessageRequest<Boolean>, OptionallyMessageThreadRequest {
val action: BotAction
): SendChatMessageRequest<Boolean> {
override fun method(): String = "sendChatAction"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()

View File

@@ -1,5 +0,0 @@
package dev.inmo.tgbotapi.requests.send.abstracts
import dev.inmo.tgbotapi.abstracts.SpoilerableData
interface OptionallyWithSpoilerRequest : SpoilerableData

View File

@@ -25,7 +25,6 @@ fun SendAnimation(
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -48,7 +47,6 @@ fun SendAnimation(
text,
parseMode,
null,
spoilered,
duration,
width,
height,
@@ -75,7 +73,6 @@ fun SendAnimation(
animation: InputFile,
thumb: InputFile? = null,
entities: TextSourcesList,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -98,7 +95,6 @@ fun SendAnimation(
entities.makeString(),
null,
entities.toRawMessageEntities(),
spoilered,
duration,
width,
height,
@@ -137,8 +133,6 @@ data class SendAnimationData internal constructor(
override val parseMode: ParseMode? = null,
@SerialName(captionEntitiesField)
private val rawEntities: List<RawMessageEntity>? = null,
@SerialName(hasSpoilerField)
override val spoilered: Boolean = false,
@SerialName(durationField)
override val duration: Long? = null,
@SerialName(widthField)
@@ -163,8 +157,7 @@ data class SendAnimationData internal constructor(
TextableSendMessageRequest<ContentMessage<AnimationContent>>,
ThumbedSendMessageRequest<ContentMessage<AnimationContent>>,
DuratedSendMessageRequest<ContentMessage<AnimationContent>>,
SizedSendMessageRequest<ContentMessage<AnimationContent>>,
OptionallyWithSpoilerRequest
SizedSendMessageRequest<ContentMessage<AnimationContent>>
{
override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null)

View File

@@ -23,7 +23,6 @@ fun SendPhoto(
photo: InputFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
@@ -37,7 +36,6 @@ fun SendPhoto(
text,
parseMode,
null,
spoilered,
threadId,
disableNotification,
protectContent,
@@ -57,7 +55,6 @@ fun SendPhoto(
chatId: ChatIdentifier,
photo: InputFile,
entities: TextSourcesList,
spoilered: Boolean = false,
threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false,
protectContent: Boolean = false,
@@ -71,7 +68,6 @@ fun SendPhoto(
entities.makeString(),
null,
entities.toRawMessageEntities(),
spoilered,
threadId,
disableNotification,
protectContent,
@@ -102,8 +98,6 @@ data class SendPhotoData internal constructor(
override val parseMode: ParseMode? = null,
@SerialName(captionEntitiesField)
private val rawEntities: List<RawMessageEntity>? = null,
@SerialName(hasSpoilerField)
override val spoilered: Boolean = false,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = chatId.threadId,
@SerialName(disableNotificationField)
@@ -119,8 +113,7 @@ data class SendPhotoData internal constructor(
) : DataRequest<ContentMessage<PhotoContent>>,
SendMessageRequest<ContentMessage<PhotoContent>>,
ReplyingMarkupSendMessageRequest<ContentMessage<PhotoContent>>,
TextableSendMessageRequest<ContentMessage<PhotoContent>>,
OptionallyWithSpoilerRequest
TextableSendMessageRequest<ContentMessage<PhotoContent>>
{
override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null)

View File

@@ -25,7 +25,6 @@ fun SendVideo(
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -49,7 +48,6 @@ fun SendVideo(
text,
parseMode,
null,
spoilered,
duration,
width,
height,
@@ -77,7 +75,6 @@ fun SendVideo(
video: InputFile,
thumb: InputFile? = null,
entities: TextSourcesList,
spoilered: Boolean = false,
duration: Long? = null,
width: Int? = null,
height: Int? = null,
@@ -101,7 +98,6 @@ fun SendVideo(
entities.makeString(),
null,
entities.toRawMessageEntities(),
spoilered,
duration,
width,
height,
@@ -141,8 +137,6 @@ data class SendVideoData internal constructor(
override val parseMode: ParseMode? = null,
@SerialName(captionEntitiesField)
private val rawEntities: List<RawMessageEntity>? = null,
@SerialName(hasSpoilerField)
override val spoilered: Boolean = false,
@SerialName(durationField)
override val duration: Long? = null,
@SerialName(widthField)
@@ -169,8 +163,7 @@ data class SendVideoData internal constructor(
TextableSendMessageRequest<ContentMessage<VideoContent>>,
ThumbedSendMessageRequest<ContentMessage<VideoContent>>,
DuratedSendMessageRequest<ContentMessage<VideoContent>>,
SizedSendMessageRequest<ContentMessage<VideoContent>>,
OptionallyWithSpoilerRequest
SizedSendMessageRequest<ContentMessage<VideoContent>>
{
override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null)

View File

@@ -228,7 +228,6 @@ const val allowsMultipleAnswersField = "allows_multiple_answers"
const val isAnonymousField = "is_anonymous"
const val canManageTopicsField = "can_manage_topics"
const val captionEntitiesField = "caption_entities"
const val hasSpoilerField = "has_spoiler"
const val loginUrlField = "login_url"
const val forwardTextField = "forward_text"
const val botUsernameField = "bot_username"
@@ -243,10 +242,8 @@ const val customTitleField = "custom_title"
const val optionIdsField = "option_ids"
const val ipAddressField = "ip_address"
const val linkedChatIdField = "linked_chat_id"
const val hasHiddenMembersField = "has_hidden_members"
const val joinToSendMessagesField = "join_to_send_messages"
const val joinByRequestField = "join_by_request"
const val hasAggressiveAntiSpamEnabledField = "has_aggressive_anti_spam_enabled"
const val horizontalAccuracyField = "horizontal_accuracy"
const val revokeMessagesField = "revoke_messages"
const val messageAutoDeleteTimeField = "message_auto_delete_time"
@@ -464,7 +461,6 @@ const val shouldSendEmailToProviderField = "send_email_to_provider"
const val resizeKeyboardField = "resize_keyboard"
const val oneTimeKeyboardField = "one_time_keyboard"
const val inputFieldPlaceholderField = "input_field_placeholder"
const val isPersistentField = "is_persistent"
const val priceDependOnShipAddressField = "is_flexible"

View File

@@ -13,9 +13,7 @@ data class ReplyKeyboardMarkup(
val oneTimeKeyboard: Boolean? = null,
@SerialName(inputFieldPlaceholderField)
val inputFieldPlaceholder: String? = null,
val selective: Boolean? = null,
@SerialName(isPersistentField)
val persistent: Boolean? = null
val selective: Boolean? = null
) : KeyboardMarkup {
init {
if (inputFieldPlaceholder != null && inputFieldPlaceholder.length !in inputFieldPlaceholderLimit) {

View File

@@ -27,9 +27,7 @@ data class ExtendedChannelChatImpl(
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
override val pinnedMessage: Message? = null,
@SerialName(linkedChatIdField)
override val linkedGroupChatId: IdChatIdentifier? = null,
@SerialName(hasHiddenMembersField)
override val membersHidden: Boolean = false
override val linkedGroupChatId: IdChatIdentifier? = null
) : ExtendedChannelChat
@Serializable
@@ -48,9 +46,7 @@ data class ExtendedGroupChatImpl(
override val inviteLink: String? = null,
@SerialName(pinnedMessageField)
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
override val pinnedMessage: Message? = null,
@SerialName(hasHiddenMembersField)
override val membersHidden: Boolean = false
override val pinnedMessage: Message? = null
) : ExtendedGroupChat
@Serializable
@@ -113,11 +109,7 @@ data class ExtendedSupergroupChatImpl(
@SerialName(joinToSendMessagesField)
override val requiresJoinForMessaging: Boolean = false,
@SerialName(joinByRequestField)
override val requireAdminApproveToJoin: Boolean = false,
@SerialName(hasAggressiveAntiSpamEnabledField)
override val isAggressiveAntiSpamEnabled: Boolean = false,
@SerialName(hasHiddenMembersField)
override val membersHidden: Boolean = false
override val requireAdminApproveToJoin: Boolean = false
) : ExtendedSupergroupChat
@Serializable
@@ -154,11 +146,7 @@ data class ExtendedForumChatImpl(
@SerialName(joinToSendMessagesField)
override val requiresJoinForMessaging: Boolean = false,
@SerialName(joinByRequestField)
override val requireAdminApproveToJoin: Boolean = false,
@SerialName(hasAggressiveAntiSpamEnabledField)
override val isAggressiveAntiSpamEnabled: Boolean = false,
@SerialName(hasHiddenMembersField)
override val membersHidden: Boolean = false
override val requireAdminApproveToJoin: Boolean = false
) : ExtendedForumChat
@Serializable

View File

@@ -31,7 +31,6 @@ sealed interface ExtendedPublicChat : ExtendedChat, PublicChat {
val inviteLink: String?
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
val pinnedMessage: Message?
val membersHidden: Boolean
}
@Serializable(ExtendedChatSerializer::class)
@@ -51,11 +50,6 @@ sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat, Ext
* This field represents field "join_by_request" from API
*/
val requireAdminApproveToJoin: Boolean
/**
* This field represents field "has_aggressive_anti_spam_enabled" from API
*/
val isAggressiveAntiSpamEnabled: Boolean
}
@Serializable(ExtendedChatSerializer::class)

View File

@@ -34,13 +34,11 @@ data class VideoFile(
@Suppress("NOTHING_TO_INLINE")
inline fun VideoFile.toTelegramMediaVideo(
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false
parseMode: ParseMode? = null
) = TelegramMediaVideo(
fileId,
text,
parseMode,
spoilered,
width,
height,
duration,
@@ -49,12 +47,10 @@ inline fun VideoFile.toTelegramMediaVideo(
@Suppress("NOTHING_TO_INLINE")
inline fun VideoFile.toTelegramMediaVideo(
textSources: TextSourcesList,
spoilered: Boolean = false
textSources: TextSourcesList
) = TelegramMediaVideo(
fileId,
textSources,
spoilered,
width,
height,
duration,

View File

@@ -20,4 +20,4 @@ sealed interface AudioMediaGroupMemberTelegramMedia: MediaGroupMemberTelegramMed
sealed interface DocumentMediaGroupMemberTelegramMedia: MediaGroupMemberTelegramMedia
@Serializable(MediaGroupMemberTelegramMediaSerializer::class)
sealed interface VisualMediaGroupMemberTelegramMedia : MediaGroupMemberTelegramMedia, SpoilerableTelegramMedia
sealed interface VisualMediaGroupMemberTelegramMedia : MediaGroupMemberTelegramMedia

View File

@@ -1,5 +0,0 @@
package dev.inmo.tgbotapi.types.media
import dev.inmo.tgbotapi.abstracts.SpoilerableData
sealed interface SpoilerableTelegramMedia : TelegramMedia, SpoilerableData

View File

@@ -18,17 +18,15 @@ fun TelegramMediaAnimation(
file: InputFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
width: Int? = null,
height: Int? = null,
duration: Long? = null,
thumb: InputFile? = null
) = TelegramMediaAnimation(file, text, parseMode, null, spoilered, width, height, duration, thumb)
) = TelegramMediaAnimation(file, text, parseMode, null, width, height, duration, thumb)
fun TelegramMediaAnimation(
file: InputFile,
entities: TextSourcesList,
spoilered: Boolean = false,
width: Int? = null,
height: Int? = null,
duration: Long? = null,
@@ -38,7 +36,6 @@ fun TelegramMediaAnimation(
entities.makeString(),
null,
entities.toRawMessageEntities(),
spoilered,
width,
height,
duration,
@@ -54,13 +51,11 @@ data class TelegramMediaAnimation internal constructor(
override val parseMode: ParseMode? = null,
@SerialName(captionEntitiesField)
private val rawEntities: List<RawMessageEntity>? = null,
@SerialName(hasSpoilerField)
override val spoilered: Boolean = false,
override val width: Int? = null,
override val height: Int? = null,
override val duration: Long? = null,
override val thumb: InputFile? = null
) : TelegramMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, TextedOutput, SpoilerableTelegramMedia {
) : TelegramMedia, SizedTelegramMedia, DuratedTelegramMedia, ThumbedTelegramMedia, TextedOutput {
override val type: String = "animation"
override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text ?: return@lazy null)

View File

@@ -18,15 +18,13 @@ internal const val photoTelegramMediaType = "photo"
fun TelegramMediaPhoto(
file: InputFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false
) = TelegramMediaPhoto(file, text, parseMode, null, spoilered)
parseMode: ParseMode? = null
) = TelegramMediaPhoto(file, text, parseMode, null)
fun TelegramMediaPhoto(
file: InputFile,
entities: TextSourcesList,
spoilered: Boolean = false
) = TelegramMediaPhoto(file, entities.makeString(), null, entities.toRawMessageEntities(), spoilered)
entities: TextSourcesList
) = TelegramMediaPhoto(file, entities.makeString(), null, entities.toRawMessageEntities())
@Serializable
data class TelegramMediaPhoto internal constructor(
@@ -36,9 +34,7 @@ data class TelegramMediaPhoto internal constructor(
@SerialName(parseModeField)
override val parseMode: ParseMode? = null,
@SerialName(captionEntitiesField)
private val rawEntities: List<RawMessageEntity>? = null,
@SerialName(hasSpoilerField)
override val spoilered: Boolean = false,
private val rawEntities: List<RawMessageEntity>? = null
) : TelegramMedia, VisualMediaGroupMemberTelegramMedia {
override val type: String = photoTelegramMediaType
override val textSources: TextSourcesList? by lazy {
@@ -54,20 +50,16 @@ data class TelegramMediaPhoto internal constructor(
fun PhotoSize.toTelegramMediaPhoto(
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false
parseMode: ParseMode? = null
): TelegramMediaPhoto = TelegramMediaPhoto(
fileId,
text,
parseMode,
spoilered
parseMode
)
fun PhotoSize.toTelegramMediaPhoto(
textSources: TextSourcesList = emptyList(),
spoilered: Boolean = false
textSources: TextSourcesList = emptyList()
): TelegramMediaPhoto = TelegramMediaPhoto(
fileId,
textSources,
spoilered
textSources
)

View File

@@ -18,22 +18,20 @@ fun TelegramMediaVideo(
file: InputFile,
text: String? = null,
parseMode: ParseMode? = null,
spoilered: Boolean = false,
width: Int? = null,
height: Int? = null,
duration: Long? = null,
thumb: InputFile? = null
) = TelegramMediaVideo(file, text, parseMode, null, spoilered, width, height, duration, thumb)
) = TelegramMediaVideo(file, text, parseMode, null, width, height, duration, thumb)
fun TelegramMediaVideo(
file: InputFile,
entities: TextSourcesList,
spoilered: Boolean = false,
width: Int? = null,
height: Int? = null,
duration: Long? = null,
thumb: InputFile? = null
) = TelegramMediaVideo(file, entities.makeString(), null, entities.toRawMessageEntities(), spoilered, width, height, duration, thumb)
) = TelegramMediaVideo(file, entities.makeString(), null, entities.toRawMessageEntities(), width, height, duration, thumb)
@Serializable
data class TelegramMediaVideo internal constructor (
@@ -44,8 +42,6 @@ data class TelegramMediaVideo internal constructor (
override val parseMode: ParseMode? = null,
@SerialName(captionEntitiesField)
private val rawEntities: List<RawMessageEntity>? = null,
@SerialName(hasSpoilerField)
override val spoilered: Boolean = false,
override val width: Int? = null,
override val height: Int? = null,
override val duration: Long? = null,

View File

@@ -1,18 +0,0 @@
package dev.inmo.tgbotapi.types.message.ChatEvents.forum
import dev.inmo.tgbotapi.types.CustomEmojiId
import dev.inmo.tgbotapi.types.iconColorField
import dev.inmo.tgbotapi.types.iconCustomEmojiIdField
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent
import dev.inmo.tgbotapi.types.nameField
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class ForumTopicEdited(
@SerialName(nameField)
val name: String,
@SerialName(iconCustomEmojiIdField)
val iconEmojiId: CustomEmojiId? = null
) : ForumEvent

View File

@@ -1,7 +0,0 @@
package dev.inmo.tgbotapi.types.message.ChatEvents.forum
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent
import kotlinx.serialization.Serializable
@Serializable
object GeneralForumTopicHidden : ForumEvent

View File

@@ -1,7 +0,0 @@
package dev.inmo.tgbotapi.types.message.ChatEvents.forum
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent
import kotlinx.serialization.Serializable
@Serializable
object GeneralForumTopicUnhidden : ForumEvent

View File

@@ -1,7 +0,0 @@
package dev.inmo.tgbotapi.types.message.ChatEvents.forum
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ForumEvent
import kotlinx.serialization.Serializable
@Serializable
object WriteAccessAllowed : ForumEvent

View File

@@ -14,11 +14,7 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicEdited
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicHidden
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicUnhidden
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
import dev.inmo.tgbotapi.types.message.abstracts.*
import dev.inmo.tgbotapi.types.message.content.*
@@ -62,7 +58,6 @@ internal data class RawMessage(
private val entities: RawMessageEntities? = null,
private val caption: String? = null,
private val caption_entities: RawMessageEntities? = null,
private val has_media_spoiler: Boolean? = null,
private val audio: AudioFile? = null,
private val document: DocumentFile? = null,
private val animation: AnimationFile? = null,
@@ -101,12 +96,8 @@ internal data class RawMessage(
// Forum
private val forum_topic_created: ForumTopicCreated? = null,
private val forum_topic_edited: ForumTopicEdited? = null,
private val forum_topic_closed: ForumTopicClosed? = null,
private val forum_topic_reopened: ForumTopicReopened? = null,
private val general_forum_topic_hidden: GeneralForumTopicHidden? = null,
private val general_forum_topic_unhidden: GeneralForumTopicUnhidden? = null,
private val write_access_allowed: WriteAccessAllowed? = null,
// AutoDelete Message time changed
private val message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged? = null,
@@ -138,15 +129,13 @@ internal data class RawMessage(
video != null -> VideoContent(
video,
caption,
adaptedCaptionEntities,
has_media_spoiler ?: false
adaptedCaptionEntities
)
animation != null -> AnimationContent(
animation,
document,
caption,
adaptedCaptionEntities,
has_media_spoiler ?: false
adaptedCaptionEntities
)
document != null -> DocumentContent(
document,
@@ -161,8 +150,7 @@ internal data class RawMessage(
photo != null -> PhotoContent(
photo.toList(),
caption,
adaptedCaptionEntities,
has_media_spoiler ?: false
adaptedCaptionEntities
)
sticker != null -> StickerContent(sticker)
dice != null -> DiceContent(dice)
@@ -225,10 +213,6 @@ internal data class RawMessage(
video_chat_scheduled != null -> video_chat_scheduled
message_auto_delete_timer_changed != null -> message_auto_delete_timer_changed
forum_topic_created != null -> forum_topic_created
forum_topic_edited != null -> forum_topic_edited
general_forum_topic_hidden != null -> general_forum_topic_hidden
general_forum_topic_unhidden != null -> general_forum_topic_unhidden
write_access_allowed != null -> write_access_allowed
forum_topic_closed != null -> forum_topic_closed
forum_topic_reopened != null -> forum_topic_reopened
video_chat_ended != null -> video_chat_ended

View File

@@ -1,6 +1,5 @@
package dev.inmo.tgbotapi.types.message.content
import dev.inmo.tgbotapi.abstracts.SpoilerableData
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.ChatIdentifier
@@ -24,7 +23,6 @@ sealed interface MessageContent: ResendableContent {
mediaGroupPartContentAdditionalBuilder: PolymorphicModuleBuilder<MediaGroupPartContent>.() -> Unit = {},
textedMediaContentAdditionalBuilder: PolymorphicModuleBuilder<TextedMediaContent>.() -> Unit = {},
mediaContentAdditionalBuilder: PolymorphicModuleBuilder<MediaContent>.() -> Unit = {},
spoilerableMediaContentAdditionalBuilder: PolymorphicModuleBuilder<SpoilerableMediaContent>.() -> Unit = {},
mediaCollectionContentAdditionalBuilder: PolymorphicModuleBuilder<MediaCollectionContent<*>>.() -> Unit = {},
additionalBuilder: PolymorphicModuleBuilder<MessageContent>.() -> Unit = {}
) = SerializersModule {
@@ -68,13 +66,6 @@ sealed interface MessageContent: ResendableContent {
mediaContentAdditionalBuilder()
}
polymorphic(SpoilerableMediaContent::class) {
subclass(VideoContent::class)
subclass(PhotoContent::class)
subclass(AnimationContent::class)
spoilerableMediaContentAdditionalBuilder()
}
polymorphic(TextedMediaContent::class) {
subclass(PhotoContent::class)
subclass(VoiceContent::class)
@@ -120,8 +111,6 @@ sealed interface MediaContent: MessageContent {
fun asTelegramMedia(): TelegramMedia
}
sealed interface SpoilerableMediaContent : MediaContent, SpoilerableData
@ClassCastsIncluded
sealed interface ResendableContent {
fun createResend(

View File

@@ -39,6 +39,6 @@ sealed interface MediaGroupPartContent : TextedMediaContent {
fun toMediaGroupMemberTelegramMedia(): MediaGroupMemberTelegramMedia
}
sealed interface VisualMediaGroupPartContent : MediaGroupPartContent, SpoilerableMediaContent {
sealed interface VisualMediaGroupPartContent : MediaGroupPartContent {
override fun toMediaGroupMemberTelegramMedia(): VisualMediaGroupMemberTelegramMedia
}

View File

@@ -18,9 +18,8 @@ data class AnimationContent(
override val media: AnimationFile,
val includedDocument: DocumentFile?,
override val text: String?,
override val textSources: TextSourcesList = emptyList(),
override val spoilered: Boolean = false
) : TextedMediaContent, SpoilerableMediaContent {
override val textSources: TextSourcesList = emptyList()
) : TextedMediaContent {
override fun createResend(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId?,
@@ -34,7 +33,6 @@ data class AnimationContent(
media.fileId,
media.thumb ?.fileId,
textSources,
spoilered,
media.duration,
media.width,
media.height,
@@ -49,7 +47,6 @@ data class AnimationContent(
override fun asTelegramMedia(): TelegramMediaAnimation = TelegramMediaAnimation(
media.fileId,
textSources,
spoilered,
media.width,
media.height,
media.duration,

View File

@@ -17,8 +17,7 @@ import kotlinx.serialization.Serializable
data class PhotoContent(
override val mediaCollection: Photo,
override val text: String? = null,
override val textSources: TextSourcesList = emptyList(),
override val spoilered: Boolean = false
override val textSources: TextSourcesList = emptyList()
) : MediaCollectionContent<PhotoSize>, VisualMediaGroupPartContent {
override val media: PhotoSize = mediaCollection.biggest() ?: throw IllegalStateException("Can't locate any photo size for this content")
@@ -34,7 +33,6 @@ data class PhotoContent(
chatId,
media.fileId,
textSources,
spoilered,
messageThreadId,
disableNotification,
protectContent,
@@ -45,5 +43,5 @@ data class PhotoContent(
override fun toMediaGroupMemberTelegramMedia(): TelegramMediaPhoto = asTelegramMedia()
override fun asTelegramMedia(): TelegramMediaPhoto = media.toTelegramMediaPhoto(textSources, spoilered)
override fun asTelegramMedia(): TelegramMediaPhoto = media.toTelegramMediaPhoto(textSources)
}

View File

@@ -17,8 +17,7 @@ import kotlinx.serialization.Serializable
data class VideoContent(
override val media: VideoFile,
override val text: String? = null,
override val textSources: TextSourcesList = emptyList(),
override val spoilered: Boolean = false
override val textSources: TextSourcesList = emptyList()
) : VisualMediaGroupPartContent {
override fun createResend(
chatId: ChatIdentifier,
@@ -33,7 +32,6 @@ data class VideoContent(
media.fileId,
media.thumb ?.fileId,
textSources,
spoilered,
media.duration,
media.width,
media.height,

View File

@@ -213,7 +213,6 @@ import dev.inmo.tgbotapi.types.media.DocumentMediaGroupMemberTelegramMedia
import dev.inmo.tgbotapi.types.media.DuratedTelegramMedia
import dev.inmo.tgbotapi.types.media.MediaGroupMemberTelegramMedia
import dev.inmo.tgbotapi.types.media.SizedTelegramMedia
import dev.inmo.tgbotapi.types.media.SpoilerableTelegramMedia
import dev.inmo.tgbotapi.types.media.TelegramMedia
import dev.inmo.tgbotapi.types.media.TelegramMediaAnimation
import dev.inmo.tgbotapi.types.media.TelegramMediaAudio
@@ -252,11 +251,7 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VideoChatEvent
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicEdited
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicHidden
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicUnhidden
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEnded
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatParticipantsInvited
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatScheduled
@@ -320,7 +315,6 @@ import dev.inmo.tgbotapi.types.message.content.MessageContent
import dev.inmo.tgbotapi.types.message.content.PhotoContent
import dev.inmo.tgbotapi.types.message.content.PollContent
import dev.inmo.tgbotapi.types.message.content.ResendableContent
import dev.inmo.tgbotapi.types.message.content.SpoilerableMediaContent
import dev.inmo.tgbotapi.types.message.content.StaticLocationContent
import dev.inmo.tgbotapi.types.message.content.StickerContent
import dev.inmo.tgbotapi.types.message.content.TextContent
@@ -2649,16 +2643,6 @@ public inline fun TelegramMedia.sizedTelegramMediaOrThrow(): SizedTelegramMedia
public inline fun <T> TelegramMedia.ifSizedTelegramMedia(block: (SizedTelegramMedia) -> T): T? =
sizedTelegramMediaOrNull() ?.let(block)
public inline fun TelegramMedia.spoilerableTelegramMediaOrNull(): SpoilerableTelegramMedia? = this
as? dev.inmo.tgbotapi.types.media.SpoilerableTelegramMedia
public inline fun TelegramMedia.spoilerableTelegramMediaOrThrow(): SpoilerableTelegramMedia = this
as dev.inmo.tgbotapi.types.media.SpoilerableTelegramMedia
public inline fun <T>
TelegramMedia.ifSpoilerableTelegramMedia(block: (SpoilerableTelegramMedia) -> T): T? =
spoilerableTelegramMediaOrNull() ?.let(block)
public inline fun TelegramMedia.telegramMediaAnimationOrNull(): TelegramMediaAnimation? = this as?
dev.inmo.tgbotapi.types.media.TelegramMediaAnimation
@@ -2939,15 +2923,6 @@ public inline fun ChatEvent.forumTopicCreatedOrThrow(): ForumTopicCreated = this
public inline fun <T> ChatEvent.ifForumTopicCreated(block: (ForumTopicCreated) -> T): T? =
forumTopicCreatedOrNull() ?.let(block)
public inline fun ChatEvent.forumTopicEditedOrNull(): ForumTopicEdited? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicEdited
public inline fun ChatEvent.forumTopicEditedOrThrow(): ForumTopicEdited = this as
dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicEdited
public inline fun <T> ChatEvent.ifForumTopicEdited(block: (ForumTopicEdited) -> T): T? =
forumTopicEditedOrNull() ?.let(block)
public inline fun ChatEvent.forumTopicReopenedOrNull(): ForumTopicReopened? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened
@@ -2957,34 +2932,6 @@ public inline fun ChatEvent.forumTopicReopenedOrThrow(): ForumTopicReopened = th
public inline fun <T> ChatEvent.ifForumTopicReopened(block: (ForumTopicReopened) -> T): T? =
forumTopicReopenedOrNull() ?.let(block)
public inline fun ChatEvent.generalForumTopicHiddenOrNull(): GeneralForumTopicHidden? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicHidden
public inline fun ChatEvent.generalForumTopicHiddenOrThrow(): GeneralForumTopicHidden = this as
dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicHidden
public inline fun <T> ChatEvent.ifGeneralForumTopicHidden(block: (GeneralForumTopicHidden) -> T): T?
= generalForumTopicHiddenOrNull() ?.let(block)
public inline fun ChatEvent.generalForumTopicUnhiddenOrNull(): GeneralForumTopicUnhidden? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicUnhidden
public inline fun ChatEvent.generalForumTopicUnhiddenOrThrow(): GeneralForumTopicUnhidden = this as
dev.inmo.tgbotapi.types.message.ChatEvents.forum.GeneralForumTopicUnhidden
public inline fun <T>
ChatEvent.ifGeneralForumTopicUnhidden(block: (GeneralForumTopicUnhidden) -> T): T? =
generalForumTopicUnhiddenOrNull() ?.let(block)
public inline fun ChatEvent.writeAccessAllowedOrNull(): WriteAccessAllowed? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed
public inline fun ChatEvent.writeAccessAllowedOrThrow(): WriteAccessAllowed = this as
dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed
public inline fun <T> ChatEvent.ifWriteAccessAllowed(block: (WriteAccessAllowed) -> T): T? =
writeAccessAllowedOrNull() ?.let(block)
public inline fun ChatEvent.videoChatEndedOrNull(): VideoChatEnded? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEnded
@@ -3569,16 +3516,6 @@ public inline fun ResendableContent.mediaContentOrThrow(): MediaContent = this a
public inline fun <T> ResendableContent.ifMediaContent(block: (MediaContent) -> T): T? =
mediaContentOrNull() ?.let(block)
public inline fun ResendableContent.spoilerableMediaContentOrNull(): SpoilerableMediaContent? = this
as? dev.inmo.tgbotapi.types.message.content.SpoilerableMediaContent
public inline fun ResendableContent.spoilerableMediaContentOrThrow(): SpoilerableMediaContent = this
as dev.inmo.tgbotapi.types.message.content.SpoilerableMediaContent
public inline fun <T>
ResendableContent.ifSpoilerableMediaContent(block: (SpoilerableMediaContent) -> T): T? =
spoilerableMediaContentOrNull() ?.let(block)
public inline fun ResendableContent.audioMediaGroupPartContentOrNull(): AudioMediaGroupPartContent?
= this as? dev.inmo.tgbotapi.types.message.content.AudioMediaGroupPartContent

View File

@@ -22,8 +22,7 @@ fun ReplyKeyboardBuilder.build(
oneTimeKeyboard: Boolean? = null,
inputFieldPlaceholder: String? = null,
selective: Boolean? = null,
persistent: Boolean? = null,
) = ReplyKeyboardMarkup(matrix, resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective, persistent)
) = ReplyKeyboardMarkup(matrix, resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective)
/**
* Row builder of [KeyboardButton]
@@ -44,9 +43,8 @@ inline fun replyKeyboard(
oneTimeKeyboard: Boolean? = null,
inputFieldPlaceholder: String? = null,
selective: Boolean? = null,
persistent: Boolean? = null,
block: ReplyKeyboardBuilder.() -> Unit
) = ReplyKeyboardBuilder().apply(block).build(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective, persistent)
) = ReplyKeyboardBuilder().apply(block).build(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective)
/**
* Factory-function for [ReplyKeyboardBuilder], but in difference with [replyKeyboard] this method will create single-row
@@ -57,9 +55,8 @@ inline fun flatReplyKeyboard(
oneTimeKeyboard: Boolean? = null,
inputFieldPlaceholder: String? = null,
selective: Boolean? = null,
persistent: Boolean? = null,
block: ReplyKeyboardRowBuilder.() -> Unit
) = replyKeyboard(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective, persistent) {
) = replyKeyboard(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) {
row<KeyboardButton>(block)
}

View File

@@ -9,13 +9,11 @@ fun ReplyKeyboardMarkup(
resizeKeyboard: Boolean? = null,
oneTimeKeyboard: Boolean? = null,
inputFieldPlaceholder: String? = null,
selective: Boolean? = null,
persistent: Boolean? = null
selective: Boolean? = null
): ReplyKeyboardMarkup = ReplyKeyboardMarkup(
flatMatrix { buttons.forEach { +it } },
resizeKeyboard,
oneTimeKeyboard,
inputFieldPlaceholder,
selective,
persistent
selective
)

View File

@@ -7,7 +7,6 @@ import dev.inmo.tgbotapi.bot.exceptions.*
import dev.inmo.tgbotapi.extensions.utils.updates.convertWithMediaGroupUpdates
import dev.inmo.tgbotapi.extensions.utils.updates.lastUpdateIdentifier
import dev.inmo.tgbotapi.requests.GetUpdates
import dev.inmo.tgbotapi.requests.webhook.DeleteWebhook
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
@@ -24,14 +23,7 @@ fun TelegramBot.longPollingFlow(
timeoutSeconds: Seconds = 30,
exceptionsHandler: (ExceptionHandler<Unit>)? = null,
allowedUpdates: List<String>? = ALL_UPDATES_LIST,
autoDisableWebhooks: Boolean = true
): Flow<Update> = channelFlow {
if (autoDisableWebhooks) {
runCatchingSafely {
execute(DeleteWebhook())
}
}
var lastUpdateIdentifier: UpdateIdentifier? = null
while (isActive) {
@@ -94,9 +86,8 @@ fun TelegramBot.startGettingOfUpdatesByLongPolling(
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
exceptionsHandler: (ExceptionHandler<Unit>)? = null,
allowedUpdates: List<String>? = ALL_UPDATES_LIST,
autoDisableWebhooks: Boolean = true,
updatesReceiver: UpdateReceiver<Update>
): Job = longPollingFlow(timeoutSeconds, exceptionsHandler, allowedUpdates, autoDisableWebhooks).subscribeSafely(
): Job = longPollingFlow(timeoutSeconds, exceptionsHandler, allowedUpdates).subscribeSafely(
scope,
exceptionsHandler ?: defaultSafelyExceptionHandler,
updatesReceiver
@@ -110,8 +101,7 @@ fun TelegramBot.createAccumulatedUpdatesRetrieverFlow(
avoidInlineQueries: Boolean = false,
avoidCallbackQueries: Boolean = false,
exceptionsHandler: ExceptionHandler<Unit>? = null,
allowedUpdates: List<String>? = ALL_UPDATES_LIST,
autoDisableWebhooks: Boolean = true,
allowedUpdates: List<String>? = ALL_UPDATES_LIST
): Flow<Update> = longPollingFlow(
timeoutSeconds = 0,
exceptionsHandler = {
@@ -121,8 +111,7 @@ fun TelegramBot.createAccumulatedUpdatesRetrieverFlow(
else -> exceptionsHandler ?.invoke(it)
}
},
allowedUpdates = allowedUpdates,
autoDisableWebhooks = autoDisableWebhooks
allowedUpdates = allowedUpdates
).filter {
!(it is InlineQueryUpdate && avoidInlineQueries || it is CallbackQueryUpdate && avoidCallbackQueries)
}
@@ -133,14 +122,12 @@ fun TelegramBot.retrieveAccumulatedUpdates(
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
exceptionsHandler: (ExceptionHandler<Unit>)? = null,
allowedUpdates: List<String>? = ALL_UPDATES_LIST,
autoDisableWebhooks: Boolean = true,
updatesReceiver: UpdateReceiver<Update>
): Job = createAccumulatedUpdatesRetrieverFlow(
avoidInlineQueries,
avoidCallbackQueries,
exceptionsHandler,
allowedUpdates,
autoDisableWebhooks
allowedUpdates
).subscribeSafelyWithoutExceptions(
scope.LinkedSupervisorScope()
) {
@@ -152,7 +139,6 @@ fun TelegramBot.retrieveAccumulatedUpdates(
avoidInlineQueries: Boolean = false,
avoidCallbackQueries: Boolean = false,
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
autoDisableWebhooks: Boolean = true,
exceptionsHandler: ExceptionHandler<Unit>? = null
) = retrieveAccumulatedUpdates(
avoidInlineQueries,
@@ -160,7 +146,6 @@ fun TelegramBot.retrieveAccumulatedUpdates(
scope,
exceptionsHandler,
flowsUpdatesFilter.allowedUpdates,
autoDisableWebhooks,
flowsUpdatesFilter.asUpdateReceiver
)
@@ -170,7 +155,6 @@ suspend fun TelegramBot.flushAccumulatedUpdates(
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
allowedUpdates: List<String>? = ALL_UPDATES_LIST,
exceptionsHandler: ExceptionHandler<Unit>? = null,
autoDisableWebhooks: Boolean = true,
updatesReceiver: UpdateReceiver<Update> = {}
) = retrieveAccumulatedUpdates(
avoidInlineQueries,
@@ -178,7 +162,6 @@ suspend fun TelegramBot.flushAccumulatedUpdates(
scope,
exceptionsHandler,
allowedUpdates,
autoDisableWebhooks,
updatesReceiver
).join()
@@ -190,10 +173,9 @@ fun TelegramBot.longPolling(
updatesFilter: UpdatesFilter,
timeoutSeconds: Seconds = 30,
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
autoDisableWebhooks: Boolean = true,
exceptionsHandler: ExceptionHandler<Unit>? = null
): Job = updatesFilter.run {
startGettingOfUpdatesByLongPolling(timeoutSeconds, scope, exceptionsHandler, allowedUpdates, autoDisableWebhooks, asUpdateReceiver)
startGettingOfUpdatesByLongPolling(timeoutSeconds, scope, exceptionsHandler, allowedUpdates, asUpdateReceiver)
}
/**
@@ -207,21 +189,18 @@ fun TelegramBot.longPolling(
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
exceptionsHandler: ExceptionHandler<Unit>? = null,
flowsUpdatesFilterUpdatesKeeperCount: Int = 100,
autoDisableWebhooks: Boolean = true,
flowUpdatesPreset: FlowsUpdatesFilter.() -> Unit
): Job = longPolling(FlowsUpdatesFilter(flowsUpdatesFilterUpdatesKeeperCount).apply(flowUpdatesPreset), timeoutSeconds, scope, autoDisableWebhooks, exceptionsHandler)
): Job = longPolling(FlowsUpdatesFilter(flowsUpdatesFilterUpdatesKeeperCount).apply(flowUpdatesPreset), timeoutSeconds, scope, exceptionsHandler)
fun RequestsExecutor.startGettingOfUpdatesByLongPolling(
updatesFilter: UpdatesFilter,
timeoutSeconds: Seconds = 30,
exceptionsHandler: ExceptionHandler<Unit>? = null,
scope: CoroutineScope = CoroutineScope(Dispatchers.Default),
autoDisableWebhooks: Boolean = true,
scope: CoroutineScope = CoroutineScope(Dispatchers.Default)
): Job = startGettingOfUpdatesByLongPolling(
timeoutSeconds,
scope,
exceptionsHandler,
updatesFilter.allowedUpdates,
autoDisableWebhooks,
updatesFilter.asUpdateReceiver
)

View File

@@ -6,5 +6,3 @@ typealias EventHandler = WebApp.() -> Unit
typealias ViewportChangedEventHandler = WebApp.(ViewportChangedData) -> Unit
typealias InvoiceClosedEventHandler = WebApp.(InvoiceClosedInfo) -> Unit
typealias PopupClosedEventHandler = WebApp.(String?) -> Unit
typealias QRTextReceivedEventHandler = WebApp.(String) -> Boolean
typealias TextReceivedEventHandler = WebApp.(String) -> Unit

View File

@@ -8,6 +8,4 @@ sealed class EventType(val typeName: String) {
object SettingsButtonClicked : EventType("settingsButtonClicked")
object InvoiceClosed : EventType("invoiceClosed")
object PopupClosed : EventType("popupClosed")
object QRTextReceived : EventType("qrTextReceived")
object ClipboardTextReceived : EventType("clipboardTextReceived")
}

View File

@@ -1,16 +0,0 @@
package dev.inmo.tgbotapi.webapps
import kotlin.js.json
external interface OpenLinkParams {
@JsName("try_instant_view")
val tryInstantView: Boolean
}
fun OpenLinkParams(
tryInstantView: Boolean
) = json(
*listOfNotNull(
"try_instant_view" to tryInstantView
).toTypedArray()
).unsafeCast<OpenLinkParams>()

View File

@@ -1,3 +0,0 @@
package dev.inmo.tgbotapi.webapps
typealias QRTextReceivedCallback = (String) -> Boolean

View File

@@ -1,3 +0,0 @@
package dev.inmo.tgbotapi.webapps
typealias TextReceivedCallback = (String) -> Unit

View File

@@ -8,8 +8,6 @@ import dev.inmo.tgbotapi.webapps.popup.*
external class WebApp {
val version: String
val platform: String
val initData: String
val initDataUnsafe: WebAppInitData
@@ -35,9 +33,6 @@ external class WebApp {
fun showPopup(params: PopupParams, callback: ClosePopupCallback? = definedExternally)
fun showAlert(message: String, callback: AlertCallback? = definedExternally)
fun showConfirm(message: String, callback: ConfirmCallback? = definedExternally)
fun showScanQrPopup(params: ScanQrPopupParams, callback: QRTextReceivedCallback? = definedExternally)
fun closeScanQrPopup()
fun readTextFromClipboard(callback: TextReceivedCallback? = definedExternally)
@JsName("MainButton")
val mainButton: MainButton
@@ -55,10 +50,6 @@ external class WebApp {
internal fun onEventWithInvoiceClosedInfo(type: String, callback: (InvoiceClosedInfo) -> Unit)
@JsName("onEvent")
internal fun onEventWithPopupClosedInfo(type: String, callback: (String?) -> Unit)
@JsName("onEvent")
internal fun onEventWithQRTextInfo(type: String, callback: (String) -> Boolean)
@JsName("onEvent")
internal fun onEventWithTextInfo(type: String, callback: (String) -> Unit)
fun offEvent(type: String, callback: () -> Unit)
@JsName("offEvent")
@@ -133,30 +124,6 @@ fun WebApp.onEvent(type: EventType.PopupClosed, eventHandler: PopupClosedEventHa
)
}
/**
* @return The callback which should be used in case you want to turn off events handling
*/
fun WebApp.onEvent(type: EventType.QRTextReceived, eventHandler: QRTextReceivedEventHandler) = { it: String ->
eventHandler(js("this").unsafeCast<WebApp>(), it)
}.also {
onEventWithQRTextInfo(
type.typeName,
callback = it
)
}
/**
* @return The callback which should be used in case you want to turn off events handling
*/
fun WebApp.onEvent(type: EventType.ClipboardTextReceived, eventHandler: TextReceivedEventHandler) = { it: String ->
eventHandler(js("this").unsafeCast<WebApp>(), it)
}.also {
onEventWithTextInfo(
type.typeName,
callback = it
)
}
/**
* @return The callback which should be used in case you want to turn off events handling
*/
@@ -185,14 +152,6 @@ fun WebApp.onInvoiceClosed(eventHandler: InvoiceClosedEventHandler) = onEvent(Ev
* @return The callback which should be used in case you want to turn off events handling
*/
fun WebApp.onPopupClosed(eventHandler: PopupClosedEventHandler) = onEvent(EventType.PopupClosed, eventHandler)
/**
* @return The callback which should be used in case you want to turn off events handling
*/
fun WebApp.onQRTextReceived(eventHandler: QRTextReceivedEventHandler) = onEvent(EventType.QRTextReceived, eventHandler)
/**
* @return The callback which should be used in case you want to turn off events handling
*/
fun WebApp.onClipboardTextReceived(eventHandler: TextReceivedEventHandler) = onEvent(EventType.ClipboardTextReceived, eventHandler)
fun WebApp.isInitDataSafe(botToken: String) = TelegramAPIUrlsKeeper(botToken).checkWebAppData(
initData,

View File

@@ -1,16 +0,0 @@
package dev.inmo.tgbotapi.webapps.popup
import kotlin.js.json
external interface ScanQrPopupParams {
val text: String?
}
fun ScanQrPopupParams(
text: String? = null
) = json(
*listOfNotNull(
("text" to text).takeIf { text != null }
).toTypedArray()
).unsafeCast<ScanQrPopupParams>()