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

add new type of chats ids

This commit is contained in:
InsanusMokrassar 2022-11-10 15:56:38 +06:00
parent 236e47478f
commit 1ec4507891
45 changed files with 262 additions and 211 deletions

View File

@ -166,7 +166,7 @@ suspend fun TelegramBot.startLiveLocation(
*/ */
suspend fun TelegramBot.startLiveLocation( suspend fun TelegramBot.startLiveLocation(
scope: CoroutineScope, scope: CoroutineScope,
chatId: ChatId, chatId: IdChatIdentifier,
location: StaticLocation, location: StaticLocation,
liveTimeMillis: Long = defaultLivePeriodDelayMillis, liveTimeMillis: Long = defaultLivePeriodDelayMillis,
initHorizontalAccuracy: Meters? = null, initHorizontalAccuracy: Meters? = null,

View File

@ -34,7 +34,7 @@ suspend fun TelegramBot.stopPoll(
* as a builder for that * as a builder for that
*/ */
suspend fun TelegramBot.stopPoll( suspend fun TelegramBot.stopPoll(
chatId: ChatId, chatId: IdChatIdentifier,
message: Message, message: Message,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chatId, message.messageId, replyMarkup) ) = stopPoll(chatId, message.messageId, replyMarkup)

View File

@ -2,11 +2,11 @@ package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetChatMenuButton import dev.inmo.tgbotapi.requests.chat.get.GetChatMenuButton
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.chat.PrivateChat import dev.inmo.tgbotapi.types.chat.PrivateChat
suspend fun TelegramBot.getChatMenuButton( suspend fun TelegramBot.getChatMenuButton(
chatId: ChatId chatId: IdChatIdentifier
) = execute(GetChatMenuButton(chatId)) ) = execute(GetChatMenuButton(chatId))
suspend fun TelegramBot.getChatMenuButton( suspend fun TelegramBot.getChatMenuButton(

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.BanChatMember import dev.inmo.tgbotapi.requests.chat.members.BanChatMember
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.UserId
@ -24,7 +24,7 @@ suspend fun TelegramBot.banChatMember(
) = banChatMember(chat.id, userId, untilDate, revokeMessages) ) = banChatMember(chat.id, userId, untilDate, revokeMessages)
suspend fun TelegramBot.banChatMember( suspend fun TelegramBot.banChatMember(
chatId: ChatId, chatId: IdChatIdentifier,
user: User, user: User,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
revokeMessages: Boolean? = null revokeMessages: Boolean? = null

View File

@ -2,22 +2,22 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.BanChatSenderChat import dev.inmo.tgbotapi.requests.chat.members.BanChatSenderChat
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.PublicChat
suspend fun TelegramBot.banChatSenderChat( suspend fun TelegramBot.banChatSenderChat(
chatId: ChatIdentifier, chatId: ChatIdentifier,
senderChatId: ChatId senderChatId: IdChatIdentifier
) = execute(BanChatSenderChat(chatId, senderChatId)) ) = execute(BanChatSenderChat(chatId, senderChatId))
suspend fun TelegramBot.banChatSenderChat( suspend fun TelegramBot.banChatSenderChat(
chat: PublicChat, chat: PublicChat,
senderChatId: ChatId senderChatId: IdChatIdentifier
) = banChatSenderChat(chat.id, senderChatId) ) = banChatSenderChat(chat.id, senderChatId)
suspend fun TelegramBot.banChatSenderChat( suspend fun TelegramBot.banChatSenderChat(
chatId: ChatId, chatId: IdChatIdentifier,
senderChat: PublicChat senderChat: PublicChat
) = banChatSenderChat(chatId, senderChat.id) ) = banChatSenderChat(chatId, senderChat.id)

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.GetChatMember import dev.inmo.tgbotapi.requests.chat.members.GetChatMember
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.PublicChat
@ -19,7 +19,7 @@ suspend fun TelegramBot.getChatMember(
) = getChatMember(chat.id, userId) ) = getChatMember(chat.id, userId)
suspend fun TelegramBot.getChatMember( suspend fun TelegramBot.getChatMember(
chatId: ChatId, chatId: IdChatIdentifier,
user: User user: User
) = getChatMember(chatId, user.id) ) = getChatMember(chatId, user.id)

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.UserId
@ -80,7 +80,7 @@ suspend fun TelegramBot.promoteChatMember(
) )
suspend fun TelegramBot.promoteChatMember( suspend fun TelegramBot.promoteChatMember(
chatId: ChatId, chatId: IdChatIdentifier,
user: User, user: User,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
isAnonymous: Boolean? = null, isAnonymous: Boolean? = null,

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.RestrictChatMember import dev.inmo.tgbotapi.requests.chat.members.RestrictChatMember
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.UserId
@ -25,7 +25,7 @@ suspend fun TelegramBot.restrictChatMember(
) = restrictChatMember(chat.id, userId, untilDate, permissions) ) = restrictChatMember(chat.id, userId, untilDate, permissions)
suspend fun TelegramBot.restrictChatMember( suspend fun TelegramBot.restrictChatMember(
chatId: ChatId, chatId: IdChatIdentifier,
user: User, user: User,
untilDate: TelegramDate? = null, untilDate: TelegramDate? = null,
permissions: ChatPermissions = ChatPermissions() permissions: ChatPermissions = ChatPermissions()

View File

@ -2,13 +2,13 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.SetChatAdministratorCustomTitle import dev.inmo.tgbotapi.requests.chat.members.SetChatAdministratorCustomTitle
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.chat.User
suspend fun TelegramBot.setChatAdministratorCustomTitle( suspend fun TelegramBot.setChatAdministratorCustomTitle(
chatId: ChatId, chatId: IdChatIdentifier,
userId: UserId, userId: UserId,
customTitle: String customTitle: String
) = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle)) ) = execute(SetChatAdministratorCustomTitle(chatId, userId, customTitle))
@ -20,7 +20,7 @@ suspend fun TelegramBot.setChatAdministratorCustomTitle(
) = setChatAdministratorCustomTitle(chat.id, userId, customTitle) ) = setChatAdministratorCustomTitle(chat.id, userId, customTitle)
suspend fun TelegramBot.setChatAdministratorCustomTitle( suspend fun TelegramBot.setChatAdministratorCustomTitle(
chatId: ChatId, chatId: IdChatIdentifier,
user: User, user: User,
customTitle: String customTitle: String
) = setChatAdministratorCustomTitle(chatId, user.id, customTitle) ) = setChatAdministratorCustomTitle(chatId, user.id, customTitle)

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.UnbanChatMember import dev.inmo.tgbotapi.requests.chat.members.UnbanChatMember
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.PublicChat
@ -21,7 +21,7 @@ suspend fun TelegramBot.unbanChatMember(
) = unbanChatMember(chat.id, userId, onlyIfBanned) ) = unbanChatMember(chat.id, userId, onlyIfBanned)
suspend fun TelegramBot.unbanChatMember( suspend fun TelegramBot.unbanChatMember(
chatId: ChatId, chatId: IdChatIdentifier,
user: User, user: User,
onlyIfBanned: Boolean? = null onlyIfBanned: Boolean? = null
) = unbanChatMember(chatId, user.id, onlyIfBanned) ) = unbanChatMember(chatId, user.id, onlyIfBanned)

View File

@ -2,22 +2,22 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.UnbanChatSenderChat import dev.inmo.tgbotapi.requests.chat.members.UnbanChatSenderChat
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.PublicChat
suspend fun TelegramBot.unbanChatSenderChat( suspend fun TelegramBot.unbanChatSenderChat(
chatId: ChatIdentifier, chatId: ChatIdentifier,
senderChatId: ChatId senderChatId: IdChatIdentifier
) = execute(UnbanChatSenderChat(chatId, senderChatId)) ) = execute(UnbanChatSenderChat(chatId, senderChatId))
suspend fun TelegramBot.unbanChatSenderChat( suspend fun TelegramBot.unbanChatSenderChat(
chat: PublicChat, chat: PublicChat,
senderChatId: ChatId senderChatId: IdChatIdentifier
) = unbanChatSenderChat(chat.id, senderChatId) ) = unbanChatSenderChat(chat.id, senderChatId)
suspend fun TelegramBot.unbanChatSenderChat( suspend fun TelegramBot.unbanChatSenderChat(
chatId: ChatId, chatId: IdChatIdentifier,
senderChat: PublicChat senderChat: PublicChat
) = unbanChatSenderChat(chatId, senderChat.id) ) = unbanChatSenderChat(chatId, senderChat.id)

View File

@ -2,12 +2,12 @@ package dev.inmo.tgbotapi.extensions.api.chat.modify
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.modify.SetChatMenuButton import dev.inmo.tgbotapi.requests.chat.modify.SetChatMenuButton
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.MenuButton import dev.inmo.tgbotapi.types.MenuButton
import dev.inmo.tgbotapi.types.chat.PrivateChat import dev.inmo.tgbotapi.types.chat.PrivateChat
suspend fun TelegramBot.setChatMenuButton( suspend fun TelegramBot.setChatMenuButton(
chatId: ChatId, chatId: IdChatIdentifier,
menuButton: MenuButton menuButton: MenuButton
) = execute(SetChatMenuButton(chatId, menuButton)) ) = execute(SetChatMenuButton(chatId, menuButton))

View File

@ -10,7 +10,7 @@ import dev.inmo.tgbotapi.types.message.content.GameContent
suspend fun TelegramBot.getGameScore( suspend fun TelegramBot.getGameScore(
userId: UserId, userId: UserId,
chatId: ChatId, chatId: IdChatIdentifier,
messageId: MessageId messageId: MessageId
) = execute( ) = execute(
GetGameHighScoresByChat(userId, chatId, messageId) GetGameHighScoresByChat(userId, chatId, messageId)
@ -18,7 +18,7 @@ suspend fun TelegramBot.getGameScore(
suspend fun TelegramBot.getGameScore( suspend fun TelegramBot.getGameScore(
user: CommonUser, user: CommonUser,
chatId: ChatId, chatId: IdChatIdentifier,
messageId: MessageId messageId: MessageId
) = getGameScore( ) = getGameScore(
user.id, chatId, messageId user.id, chatId, messageId

View File

@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.types.message.content.GameContent
suspend fun TelegramBot.setGameScore( suspend fun TelegramBot.setGameScore(
userId: UserId, userId: UserId,
score: Long, score: Long,
chatId: ChatId, chatId: IdChatIdentifier,
messageId: MessageId, messageId: MessageId,
force: Boolean = false, force: Boolean = false,
disableEditMessage: Boolean = false disableEditMessage: Boolean = false
@ -22,7 +22,7 @@ suspend fun TelegramBot.setGameScore(
suspend fun TelegramBot.setGameScore( suspend fun TelegramBot.setGameScore(
user: CommonUser, user: CommonUser,
score: Long, score: Long,
chatId: ChatId, chatId: IdChatIdentifier,
messageId: MessageId, messageId: MessageId,
force: Boolean = false, force: Boolean = false,
disableEditMessage: Boolean = false disableEditMessage: Boolean = false

View File

@ -42,7 +42,7 @@ import kotlin.jvm.JvmName
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
phoneNumber: String, phoneNumber: String,
firstName: String, firstName: String,
@ -70,7 +70,7 @@ suspend inline fun TelegramBot.reply(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
contact: Contact, contact: Contact,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -97,7 +97,7 @@ suspend inline fun TelegramBot.reply(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.replyWithDice( suspend inline fun TelegramBot.replyWithDice(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
animationType: DiceAnimationType? = null, animationType: DiceAnimationType? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -112,7 +112,7 @@ suspend inline fun TelegramBot.replyWithDice(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
animationType: DiceAnimationType, animationType: DiceAnimationType,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -130,7 +130,7 @@ suspend inline fun TelegramBot.reply(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
latitude: Double, latitude: Double,
longitude: Double, longitude: Double,
@ -156,7 +156,7 @@ suspend inline fun TelegramBot.reply(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
location: StaticLocation, location: StaticLocation,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -183,7 +183,7 @@ suspend inline fun TelegramBot.reply(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
text: String, text: String,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
@ -211,7 +211,7 @@ suspend inline fun TelegramBot.reply(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
entities: TextSourcesList, entities: TextSourcesList,
disableWebPagePreview: Boolean? = null, disableWebPagePreview: Boolean? = null,
@ -237,7 +237,7 @@ suspend inline fun TelegramBot.reply(
* as a builder for that * as a builder for that
*/ */
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
separator: TextSource? = null, separator: TextSource? = null,
disableWebPagePreview: Boolean? = null, disableWebPagePreview: Boolean? = null,
@ -254,7 +254,7 @@ suspend fun TelegramBot.reply(
* as a builder for that * as a builder for that
*/ */
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
separator: String, separator: String,
disableWebPagePreview: Boolean? = null, disableWebPagePreview: Boolean? = null,
@ -274,7 +274,7 @@ suspend fun TelegramBot.reply(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
latitude: Double, latitude: Double,
longitude: Double, longitude: Double,
@ -308,7 +308,7 @@ suspend inline fun TelegramBot.reply(
) )
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
location: StaticLocation, location: StaticLocation,
title: String, title: String,
@ -341,7 +341,7 @@ suspend inline fun TelegramBot.reply(
) )
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
venue: Venue, venue: Venue,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -364,7 +364,7 @@ suspend inline fun TelegramBot.reply(
// Game // Game
suspend inline fun TelegramBot.replyWithGame( suspend inline fun TelegramBot.replyWithGame(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
gameShortName: String, gameShortName: String,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -377,7 +377,7 @@ suspend inline fun TelegramBot.replyWithGame(
) )
suspend inline fun TelegramBot.replyWithGame( suspend inline fun TelegramBot.replyWithGame(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
game: Game, game: Game,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -390,7 +390,7 @@ suspend inline fun TelegramBot.replyWithGame(
) )
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
game: Game, game: Game,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -404,7 +404,7 @@ suspend inline fun TelegramBot.reply(
// Animation // Animation
suspend inline fun TelegramBot.replyWithAnimation( suspend inline fun TelegramBot.replyWithAnimation(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
animation: InputFile, animation: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
@ -436,7 +436,7 @@ suspend inline fun TelegramBot.replyWithAnimation(
) )
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
animation: AnimationFile, animation: AnimationFile,
text: String? = null, text: String? = null,
@ -452,7 +452,7 @@ suspend inline fun TelegramBot.reply(
) = sendAnimation(toChatId, animation, text, parseMode, 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( suspend inline fun TelegramBot.replyWithAnimation(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
animation: InputFile, animation: InputFile,
entities: TextSourcesList, entities: TextSourcesList,
@ -482,7 +482,7 @@ suspend inline fun TelegramBot.replyWithAnimation(
) )
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
animation: AnimationFile, animation: AnimationFile,
entities: TextSourcesList, entities: TextSourcesList,
@ -500,7 +500,7 @@ suspend inline fun TelegramBot.reply(
// Audio // Audio
suspend inline fun TelegramBot.replyWithAudio( suspend inline fun TelegramBot.replyWithAudio(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
audio: InputFile, audio: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
@ -517,7 +517,7 @@ suspend inline fun TelegramBot.replyWithAudio(
) = sendAudio(toChatId, audio, thumb, text, parseMode, duration, performer, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendAudio(toChatId, audio, thumb, text, parseMode, duration, performer, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
audio: AudioFile, audio: AudioFile,
text: String? = null, text: String? = null,
@ -531,7 +531,7 @@ suspend inline fun TelegramBot.reply(
) = sendAudio(toChatId, audio, text, parseMode, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendAudio(toChatId, audio, text, parseMode, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithAudio( suspend inline fun TelegramBot.replyWithAudio(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
audio: InputFile, audio: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
@ -547,7 +547,7 @@ suspend inline fun TelegramBot.replyWithAudio(
) = sendAudio(toChatId, audio, thumb, entities, duration, performer, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendAudio(toChatId, audio, thumb, entities, duration, performer, title, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
audio: AudioFile, audio: AudioFile,
entities: TextSourcesList, entities: TextSourcesList,
@ -563,7 +563,7 @@ suspend inline fun TelegramBot.reply(
// Documents // Documents
suspend inline fun TelegramBot.replyWithDocument( suspend inline fun TelegramBot.replyWithDocument(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
document: InputFile, document: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
@ -578,7 +578,7 @@ suspend inline fun TelegramBot.replyWithDocument(
) = sendDocument(toChatId, document, thumb, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) ) = sendDocument(toChatId, document, thumb, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
document: DocumentFile, document: DocumentFile,
text: String? = null, text: String? = null,
@ -592,7 +592,7 @@ suspend inline fun TelegramBot.reply(
) = sendDocument(toChatId, document, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) ) = sendDocument(toChatId, document, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
suspend inline fun TelegramBot.replyWithDocument( suspend inline fun TelegramBot.replyWithDocument(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
document: InputFile, document: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
@ -606,7 +606,7 @@ suspend inline fun TelegramBot.replyWithDocument(
) = sendDocument(toChatId, document, thumb, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) ) = sendDocument(toChatId, document, thumb, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
document: DocumentFile, document: DocumentFile,
entities: TextSourcesList, entities: TextSourcesList,
@ -623,7 +623,7 @@ suspend inline fun TelegramBot.reply(
@RiskFeature(rawSendingMediaGroupsWarning) @RiskFeature(rawSendingMediaGroupsWarning)
suspend inline fun TelegramBot.replyWithMediaGroup( suspend inline fun TelegramBot.replyWithMediaGroup(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
media: List<MediaGroupMemberTelegramMedia>, media: List<MediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -633,7 +633,7 @@ suspend inline fun TelegramBot.replyWithMediaGroup(
) = sendMediaGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) ) = sendMediaGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply)
suspend inline fun TelegramBot.replyWithPlaylist( suspend inline fun TelegramBot.replyWithPlaylist(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
media: List<AudioMediaGroupMemberTelegramMedia>, media: List<AudioMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -643,7 +643,7 @@ suspend inline fun TelegramBot.replyWithPlaylist(
) = sendPlaylist(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) ) = sendPlaylist(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply)
suspend inline fun TelegramBot.replyWithDocuments( suspend inline fun TelegramBot.replyWithDocuments(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
media: List<DocumentMediaGroupMemberTelegramMedia>, media: List<DocumentMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -653,7 +653,7 @@ suspend inline fun TelegramBot.replyWithDocuments(
) = sendDocumentsGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply) ) = sendDocumentsGroup(toChatId, media, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply)
suspend inline fun TelegramBot.replyWithGallery( suspend inline fun TelegramBot.replyWithGallery(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
media: List<VisualMediaGroupMemberTelegramMedia>, media: List<VisualMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -666,7 +666,7 @@ suspend inline fun TelegramBot.replyWithGallery(
// Photo // Photo
suspend inline fun TelegramBot.replyWithPhoto( suspend inline fun TelegramBot.replyWithPhoto(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
fileId: InputFile, fileId: InputFile,
text: String? = null, text: String? = null,
@ -679,7 +679,7 @@ suspend inline fun TelegramBot.replyWithPhoto(
) = sendPhoto(toChatId, fileId, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendPhoto(toChatId, fileId, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
photo: Photo, photo: Photo,
text: String? = null, text: String? = null,
@ -692,7 +692,7 @@ suspend inline fun TelegramBot.reply(
) = sendPhoto(toChatId, photo, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendPhoto(toChatId, photo, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
photoSize: PhotoSize, photoSize: PhotoSize,
text: String? = null, text: String? = null,
@ -706,7 +706,7 @@ suspend inline fun TelegramBot.reply(
suspend inline fun TelegramBot.replyWithPhoto( suspend inline fun TelegramBot.replyWithPhoto(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
fileId: InputFile, fileId: InputFile,
entities: TextSourcesList, entities: TextSourcesList,
@ -718,7 +718,7 @@ suspend inline fun TelegramBot.replyWithPhoto(
) = sendPhoto(toChatId, fileId, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendPhoto(toChatId, fileId, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
photo: Photo, photo: Photo,
entities: TextSourcesList, entities: TextSourcesList,
@ -730,7 +730,7 @@ suspend inline fun TelegramBot.reply(
) = sendPhoto(toChatId, photo, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendPhoto(toChatId, photo, entities, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
photoSize: PhotoSize, photoSize: PhotoSize,
entities: TextSourcesList, entities: TextSourcesList,
@ -745,7 +745,7 @@ suspend inline fun TelegramBot.reply(
// Sticker // Sticker
suspend inline fun TelegramBot.replyWithSticker( suspend inline fun TelegramBot.replyWithSticker(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
sticker: InputFile, sticker: InputFile,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -756,7 +756,7 @@ suspend inline fun TelegramBot.replyWithSticker(
) = sendSticker(toChatId, sticker, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendSticker(toChatId, sticker, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
sticker: Sticker, sticker: Sticker,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -770,7 +770,7 @@ suspend inline fun TelegramBot.reply(
// Videos // Videos
suspend inline fun TelegramBot.replyWithVideo( suspend inline fun TelegramBot.replyWithVideo(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
video: InputFile, video: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
@ -787,7 +787,7 @@ suspend inline fun TelegramBot.replyWithVideo(
) = sendVideo(toChatId, video, thumb, text, parseMode, 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( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
video: VideoFile, video: VideoFile,
text: String? = null, text: String? = null,
@ -800,7 +800,7 @@ suspend inline fun TelegramBot.reply(
) = sendVideo(toChatId, video, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendVideo(toChatId, video, text, parseMode, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithVideo( suspend inline fun TelegramBot.replyWithVideo(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
video: InputFile, video: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
@ -816,7 +816,7 @@ suspend inline fun TelegramBot.replyWithVideo(
) = sendVideo(toChatId, video, thumb, entities, 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( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
video: VideoFile, video: VideoFile,
entities: TextSourcesList, entities: TextSourcesList,
@ -831,7 +831,7 @@ suspend inline fun TelegramBot.reply(
// VideoNotes // VideoNotes
suspend inline fun TelegramBot.replyWithVideoNote( suspend inline fun TelegramBot.replyWithVideoNote(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
videoNote: InputFile, videoNote: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
@ -845,7 +845,7 @@ suspend inline fun TelegramBot.replyWithVideoNote(
) = sendVideoNote(toChatId, videoNote, thumb, duration, size, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendVideoNote(toChatId, videoNote, thumb, duration, size, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
videoNote: VideoNoteFile, videoNote: VideoNoteFile,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -859,7 +859,7 @@ suspend inline fun TelegramBot.reply(
// Voice // Voice
suspend inline fun TelegramBot.replyWithVoice( suspend inline fun TelegramBot.replyWithVoice(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
voice: InputFile, voice: InputFile,
text: String? = null, text: String? = null,
@ -873,7 +873,7 @@ suspend inline fun TelegramBot.replyWithVoice(
) = sendVoice(toChatId, voice, text, parseMode, duration, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendVoice(toChatId, voice, text, parseMode, duration, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
voice: VoiceFile, voice: VoiceFile,
text: String? = null, text: String? = null,
@ -887,7 +887,7 @@ suspend inline fun TelegramBot.reply(
suspend inline fun TelegramBot.replyWithVoice( suspend inline fun TelegramBot.replyWithVoice(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
voice: InputFile, voice: InputFile,
entities: TextSourcesList, entities: TextSourcesList,
@ -900,7 +900,7 @@ suspend inline fun TelegramBot.replyWithVoice(
) = sendVoice(toChatId, voice, entities, duration, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendVoice(toChatId, voice, entities, duration, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
voice: VoiceFile, voice: VoiceFile,
entities: TextSourcesList, entities: TextSourcesList,
@ -919,7 +919,7 @@ suspend inline fun TelegramBot.reply(
* as a builder for that * as a builder for that
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
title: String, title: String,
description: String, description: String,
@ -949,7 +949,7 @@ suspend inline fun TelegramBot.reply(
// Polls // Polls
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
question: String, question: String,
options: List<String>, options: List<String>,
@ -965,7 +965,7 @@ suspend inline fun TelegramBot.reply(
) = sendRegularPoll(toChatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendRegularPoll(toChatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
poll: RegularPoll, poll: RegularPoll,
isClosed: Boolean = false, isClosed: Boolean = false,
@ -982,7 +982,7 @@ suspend inline fun TelegramBot.reply(
) = sendRegularPoll(toChatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendRegularPoll(toChatId, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
question: String, question: String,
options: List<String>, options: List<String>,
@ -1000,7 +1000,7 @@ suspend inline fun TelegramBot.reply(
) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
quizPoll: QuizPoll, quizPoll: QuizPoll,
isClosed: Boolean = false, isClosed: Boolean = false,
@ -1019,7 +1019,7 @@ suspend inline fun TelegramBot.reply(
) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendQuizPoll(toChatId, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
question: String, question: String,
options: List<String>, options: List<String>,
@ -1036,7 +1036,7 @@ suspend inline fun TelegramBot.reply(
) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup) ) = sendQuizPoll(toChatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
quizPoll: QuizPoll, quizPoll: QuizPoll,
entities: TextSourcesList, entities: TextSourcesList,
@ -1055,7 +1055,7 @@ suspend inline fun TelegramBot.reply(
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
poll: Poll, poll: Poll,
isClosed: Boolean = false, isClosed: Boolean = false,
@ -1106,7 +1106,7 @@ suspend inline fun TelegramBot.reply(
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
fromChatId: ChatIdentifier, fromChatId: ChatIdentifier,
messageId: MessageId, messageId: MessageId,
@ -1132,7 +1132,7 @@ suspend inline fun TelegramBot.reply(
) )
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
fromChat: Chat, fromChat: Chat,
messageId: MessageId, messageId: MessageId,
@ -1146,7 +1146,7 @@ suspend inline fun TelegramBot.reply(
) = reply(toChatId, toMessageId, fromChat.id, messageId, text, parseMode, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) ) = reply(toChatId, toMessageId, fromChat.id, messageId, text, parseMode, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
copy: Message, copy: Message,
text: String? = null, text: String? = null,
@ -1159,7 +1159,7 @@ suspend inline fun TelegramBot.reply(
) = reply(toChatId, toMessageId, copy.chat.id, copy.messageId, text, parseMode, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) ) = reply(toChatId, toMessageId, copy.chat.id, copy.messageId, text, parseMode, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
content: MessageContent, content: MessageContent,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -1187,7 +1187,7 @@ suspend fun TelegramBot.reply(
* @see handleLiveLocation * @see handleLiveLocation
*/ */
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
locationsFlow: Flow<EditLiveLocationInfo>, locationsFlow: Flow<EditLiveLocationInfo>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis, liveTimeMillis: Long = defaultLivePeriodDelayMillis,
@ -1214,7 +1214,7 @@ suspend fun TelegramBot.reply(
@JvmName("replyLiveLocationWithLocationChatIdAndMessageId") @JvmName("replyLiveLocationWithLocationChatIdAndMessageId")
@JsName("replyLiveLocationWithLocationChatIdAndMessageId") @JsName("replyLiveLocationWithLocationChatIdAndMessageId")
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
locationsFlow: Flow<Location>, locationsFlow: Flow<Location>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis, liveTimeMillis: Long = defaultLivePeriodDelayMillis,
@ -1243,7 +1243,7 @@ suspend fun TelegramBot.reply(
@JvmName("replyLiveLocationWithLatLongChatIdAndMessageId") @JvmName("replyLiveLocationWithLatLongChatIdAndMessageId")
@JsName("replyLiveLocationWithLatLongChatIdAndMessageId") @JsName("replyLiveLocationWithLatLongChatIdAndMessageId")
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
locationsFlow: Flow<Pair<Double, Double>>, locationsFlow: Flow<Pair<Double, Double>>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis, liveTimeMillis: Long = defaultLivePeriodDelayMillis,
@ -1265,7 +1265,7 @@ suspend fun TelegramBot.reply(
} }
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
mediaFile: TelegramMediaFile, mediaFile: TelegramMediaFile,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = null,
@ -1369,7 +1369,7 @@ suspend fun TelegramBot.reply(
} }
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
content: TextedMediaContent, content: TextedMediaContent,
text: String?, text: String?,
@ -1457,7 +1457,7 @@ suspend fun TelegramBot.reply(
} }
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
toChatId: ChatId, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
content: TextedMediaContent, content: TextedMediaContent,
entities: List<TextSource>, entities: List<TextSource>,

View File

@ -9,7 +9,6 @@ import dev.inmo.tgbotapi.types.actions.*
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import kotlinx.coroutines.* import kotlinx.coroutines.*
import kotlin.contracts.* import kotlin.contracts.*
import kotlin.coroutines.coroutineContext
private const val refreshTime: MilliSeconds = (botActionActualityTime - 1) * 1000L private const val refreshTime: MilliSeconds = (botActionActualityTime - 1) * 1000L
typealias TelegramBotActionCallback<T> = suspend TelegramBot.() -> T typealias TelegramBotActionCallback<T> = suspend TelegramBot.() -> T
@ -37,7 +36,7 @@ suspend fun <T> TelegramBot.withAction(
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withAction( suspend fun <T> TelegramBot.withAction(
chatId: ChatId, chatId: IdChatIdentifier,
action: BotAction, action: BotAction,
block: TelegramBotActionCallback<T> block: TelegramBotActionCallback<T>
): T { ): T {
@ -67,77 +66,77 @@ suspend fun <T> TelegramBot.withAction(
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withTypingAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T { suspend fun <T> TelegramBot.withTypingAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract { contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE) callsInPlace(block, InvocationKind.EXACTLY_ONCE)
} }
return withAction(chatId, TypingAction, block) return withAction(chatId, TypingAction, block)
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadPhotoAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T { suspend fun <T> TelegramBot.withUploadPhotoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract { contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE) callsInPlace(block, InvocationKind.EXACTLY_ONCE)
} }
return withAction(chatId, UploadPhotoAction, block) return withAction(chatId, UploadPhotoAction, block)
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withRecordVideoAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T { suspend fun <T> TelegramBot.withRecordVideoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract { contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE) callsInPlace(block, InvocationKind.EXACTLY_ONCE)
} }
return withAction(chatId, RecordVideoAction, block) return withAction(chatId, RecordVideoAction, block)
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadVideoAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T { suspend fun <T> TelegramBot.withUploadVideoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract { contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE) callsInPlace(block, InvocationKind.EXACTLY_ONCE)
} }
return withAction(chatId, UploadVideoAction, block) return withAction(chatId, UploadVideoAction, block)
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withRecordVoiceAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T { suspend fun <T> TelegramBot.withRecordVoiceAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract { contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE) callsInPlace(block, InvocationKind.EXACTLY_ONCE)
} }
return withAction(chatId, RecordVoiceAction, block) return withAction(chatId, RecordVoiceAction, block)
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadVoiceAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T { suspend fun <T> TelegramBot.withUploadVoiceAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract { contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE) callsInPlace(block, InvocationKind.EXACTLY_ONCE)
} }
return withAction(chatId, UploadVoiceAction, block) return withAction(chatId, UploadVoiceAction, block)
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadDocumentAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T { suspend fun <T> TelegramBot.withUploadDocumentAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract { contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE) callsInPlace(block, InvocationKind.EXACTLY_ONCE)
} }
return withAction(chatId, UploadDocumentAction, block) return withAction(chatId, UploadDocumentAction, block)
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withFindLocationAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T { suspend fun <T> TelegramBot.withFindLocationAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract { contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE) callsInPlace(block, InvocationKind.EXACTLY_ONCE)
} }
return withAction(chatId, FindLocationAction, block) return withAction(chatId, FindLocationAction, block)
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T { suspend fun <T> TelegramBot.withRecordVideoNoteAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract { contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE) callsInPlace(block, InvocationKind.EXACTLY_ONCE)
} }
return withAction(chatId, RecordVideoNoteAction, block) return withAction(chatId, RecordVideoNoteAction, block)
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T { suspend fun <T> TelegramBot.withUploadVideoNoteAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract { contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE) callsInPlace(block, InvocationKind.EXACTLY_ONCE)
} }
return withAction(chatId, UploadVideoNoteAction, block) return withAction(chatId, UploadVideoNoteAction, block)
} }
@OptIn(ExperimentalContracts::class) @OptIn(ExperimentalContracts::class)
suspend fun <T> TelegramBot.withChooseStickerAction(chatId: ChatId, block: TelegramBotActionCallback<T>) : T { suspend fun <T> TelegramBot.withChooseStickerAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
contract { contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE) callsInPlace(block, InvocationKind.EXACTLY_ONCE)
} }

View File

@ -414,7 +414,7 @@ suspend fun TelegramBot.send(
* as a builder for that * as a builder for that
*/ */
suspend fun TelegramBot.send( suspend fun TelegramBot.send(
chatId: ChatId, chatId: IdChatIdentifier,
title: String, title: String,
description: String, description: String,
payload: String, payload: String,

View File

@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.files.VoiceFile import dev.inmo.tgbotapi.types.files.VoiceFile
import dev.inmo.tgbotapi.types.threadId
/** /**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -22,7 +23,7 @@ suspend fun TelegramBot.sendVoice(
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
duration: Long? = null, duration: Long? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -54,7 +55,7 @@ suspend fun TelegramBot.sendVoice(
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
duration: Long? = null, duration: Long? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -71,7 +72,7 @@ suspend fun TelegramBot.sendVoice(
voice: VoiceFile, voice: VoiceFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -90,7 +91,7 @@ suspend fun TelegramBot.sendVoice(
voice: VoiceFile, voice: VoiceFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -108,7 +109,7 @@ suspend inline fun TelegramBot.sendVoice(
voice: InputFile, voice: InputFile,
entities: TextSourcesList, entities: TextSourcesList,
duration: Long? = null, duration: Long? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -138,7 +139,7 @@ suspend inline fun TelegramBot.sendVoice(
voice: InputFile, voice: InputFile,
entities: TextSourcesList, entities: TextSourcesList,
duration: Long? = null, duration: Long? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -154,7 +155,7 @@ suspend inline fun TelegramBot.sendVoice(
chatId: ChatIdentifier, chatId: ChatIdentifier,
voice: VoiceFile, voice: VoiceFile,
entities: TextSourcesList, entities: TextSourcesList,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -171,7 +172,7 @@ suspend inline fun TelegramBot.sendVoice(
chat: Chat, chat: Chat,
voice: VoiceFile, voice: VoiceFile,
entities: TextSourcesList, entities: TextSourcesList,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,

View File

@ -13,7 +13,7 @@ import dev.inmo.tgbotapi.types.payments.abstracts.Currency
* as a builder for that * as a builder for that
*/ */
suspend fun TelegramBot.sendInvoice( suspend fun TelegramBot.sendInvoice(
chatId: ChatId, chatId: IdChatIdentifier,
title: String, title: String,
description: String, description: String,
payload: String, payload: String,
@ -31,7 +31,7 @@ suspend fun TelegramBot.sendInvoice(
shouldSendPhoneNumberToProvider: Boolean = false, shouldSendPhoneNumberToProvider: Boolean = false,
shouldSendEmailToProvider: Boolean = false, shouldSendEmailToProvider: Boolean = false,
priceDependOnShipAddress: Boolean = false, priceDependOnShipAddress: Boolean = false,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,

View File

@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.polls.*
import dev.inmo.tgbotapi.types.threadId
/** /**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -24,7 +25,7 @@ suspend fun TelegramBot.sendRegularPoll(
isClosed: Boolean = false, isClosed: Boolean = false,
allowMultipleAnswers: Boolean = false, allowMultipleAnswers: Boolean = false,
closeInfo: ScheduledCloseInfo? = null, closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -48,7 +49,7 @@ suspend fun TelegramBot.sendRegularPoll(
isAnonymous: Boolean = poll.isAnonymous, isAnonymous: Boolean = poll.isAnonymous,
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
closeInfo: ScheduledCloseInfo? = null, closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -68,7 +69,7 @@ suspend fun TelegramBot.sendRegularPoll(
isClosed: Boolean = false, isClosed: Boolean = false,
allowMultipleAnswers: Boolean = false, allowMultipleAnswers: Boolean = false,
closeInfo: ScheduledCloseInfo? = null, closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -91,7 +92,7 @@ suspend fun TelegramBot.sendRegularPoll(
isAnonymous: Boolean = poll.isAnonymous, isAnonymous: Boolean = poll.isAnonymous,
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
closeInfo: ScheduledCloseInfo? = null, closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -116,7 +117,7 @@ suspend fun TelegramBot.sendQuizPoll(
explanation: String? = null, explanation: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null, closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -142,7 +143,7 @@ suspend fun TelegramBot.sendQuizPoll(
explanation: String? = null, explanation: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null, closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -167,7 +168,7 @@ suspend fun TelegramBot.sendQuizPoll(
explanation: String? = null, explanation: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null, closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -192,7 +193,7 @@ suspend fun TelegramBot.sendQuizPoll(
explanation: String? = null, explanation: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null, closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -216,7 +217,7 @@ suspend inline fun TelegramBot.sendQuizPoll(
isClosed: Boolean = false, isClosed: Boolean = false,
entities: TextSourcesList, entities: TextSourcesList,
closeInfo: ScheduledCloseInfo? = null, closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -241,7 +242,7 @@ suspend inline fun TelegramBot.sendQuizPoll(
isClosed: Boolean = false, isClosed: Boolean = false,
entities: TextSourcesList, entities: TextSourcesList,
closeInfo: ScheduledCloseInfo? = null, closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -265,7 +266,7 @@ suspend inline fun TelegramBot.sendQuizPoll(
isAnonymous: Boolean = quizPoll.isAnonymous, isAnonymous: Boolean = quizPoll.isAnonymous,
entities: TextSourcesList, entities: TextSourcesList,
closeInfo: ScheduledCloseInfo? = null, closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
@ -289,7 +290,7 @@ suspend inline fun TelegramBot.sendQuizPoll(
isAnonymous: Boolean = quizPoll.isAnonymous, isAnonymous: Boolean = quizPoll.isAnonymous,
entities: TextSourcesList, entities: TextSourcesList,
closeInfo: ScheduledCloseInfo? = null, closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null, threadId: MessageThreadId? = chat.id.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,

View File

@ -2,9 +2,8 @@ package dev.inmo.tgbotapi.requests.chat.abstracts
import dev.inmo.tgbotapi.abstracts.types.ChatRequest import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.UserId
interface ChatSenderRequest : ChatRequest, SimpleRequest<Boolean> { interface ChatSenderRequest : ChatRequest, SimpleRequest<Boolean> {
val senderChatId: ChatId val senderChatId: IdChatIdentifier
} }

View File

@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.chat.get
import dev.inmo.tgbotapi.abstracts.types.ChatRequest import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.ChatIdWithThreadId
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.ExtendedChatSerializer import dev.inmo.tgbotapi.types.chat.ExtendedChatSerializer
import dev.inmo.tgbotapi.types.chat.ExtendedChat import dev.inmo.tgbotapi.types.chat.ExtendedChat
@ -14,8 +15,12 @@ data class GetChat(
override val chatId: ChatIdentifier override val chatId: ChatIdentifier
): ChatRequest, SimpleRequest<ExtendedChat> { ): ChatRequest, SimpleRequest<ExtendedChat> {
override fun method(): String = "getChat" override fun method(): String = "getChat"
override val resultDeserializer: DeserializationStrategy<ExtendedChat> @Transient
get() = ExtendedChatSerializer override val resultDeserializer: DeserializationStrategy<ExtendedChat> = if (chatId is ChatIdWithThreadId) {
ExtendedChatSerializer.BasedOnForumThread(chatId.threadId)
} else {
ExtendedChatSerializer
}
override val requestSerializer: SerializationStrategy<*> override val requestSerializer: SerializationStrategy<*>
get() = serializer() get() = serializer()
} }

View File

@ -13,7 +13,7 @@ data class BanChatSenderChat(
@SerialName(chatIdField) @SerialName(chatIdField)
override val chatId: ChatIdentifier, override val chatId: ChatIdentifier,
@SerialName(senderChatIdField) @SerialName(senderChatIdField)
override val senderChatId: ChatId override val senderChatId: IdChatIdentifier
) : ChatSenderRequest { ) : ChatSenderRequest {
override fun method(): String = "banChatSenderChat" override fun method(): String = "banChatSenderChat"
override val resultDeserializer: DeserializationStrategy<Boolean> override val resultDeserializer: DeserializationStrategy<Boolean>

View File

@ -13,7 +13,7 @@ data class UnbanChatSenderChat(
@SerialName(chatIdField) @SerialName(chatIdField)
override val chatId: ChatIdentifier, override val chatId: ChatIdentifier,
@SerialName(senderChatIdField) @SerialName(senderChatIdField)
override val senderChatId: ChatId override val senderChatId: IdChatIdentifier
) : ChatSenderRequest { ) : ChatSenderRequest {
override fun method(): String = "unbanChatSenderChat" override fun method(): String = "unbanChatSenderChat"
override val resultDeserializer: DeserializationStrategy<Boolean> override val resultDeserializer: DeserializationStrategy<Boolean>

View File

@ -10,7 +10,7 @@ data class GetGameHighScoresByChat (
@SerialName(userIdField) @SerialName(userIdField)
override val userId: UserId, override val userId: UserId,
@SerialName(chatIdField) @SerialName(chatIdField)
override val chatId: ChatId, override val chatId: IdChatIdentifier,
@SerialName(messageIdField) @SerialName(messageIdField)
override val messageId: MessageId override val messageId: MessageId
) : GetGameHighScores, MessageAction { ) : GetGameHighScores, MessageAction {

View File

@ -12,7 +12,7 @@ data class SetGameScoreByChatId (
@SerialName(scoreField) @SerialName(scoreField)
override val score: Long, override val score: Long,
@SerialName(chatIdField) @SerialName(chatIdField)
override val chatId: ChatId, override val chatId: IdChatIdentifier,
@SerialName(messageIdField) @SerialName(messageIdField)
override val messageId: MessageId, override val messageId: MessageId,
@SerialName(forceField) @SerialName(forceField)

View File

@ -22,7 +22,7 @@ private val invoiceMessageSerializer: DeserializationStrategy<ContentMessage<Inv
@Serializable @Serializable
data class SendInvoice( data class SendInvoice(
@SerialName(chatIdField) @SerialName(chatIdField)
override val chatId: ChatId, override val chatId: IdChatIdentifier,
@SerialName(titleField) @SerialName(titleField)
override val title: String, override val title: String,
@SerialName(descriptionField) @SerialName(descriptionField)
@ -59,7 +59,7 @@ data class SendInvoice(
@SerialName(priceDependOnShipAddressField) @SerialName(priceDependOnShipAddressField)
override val priceDependOnShipAddress: Boolean = false, override val priceDependOnShipAddress: Boolean = false,
@SerialName(messageThreadIdField) @SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = null, override val threadId: MessageThreadId? = chatId.threadId,
@SerialName(disableNotificationField) @SerialName(disableNotificationField)
override val disableNotification: Boolean = false, override val disableNotification: Boolean = false,
@SerialName(protectContentField) @SerialName(protectContentField)

View File

@ -10,19 +10,44 @@ import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.JsonPrimitive import kotlinx.serialization.json.JsonPrimitive
import kotlinx.serialization.json.longOrNull import kotlinx.serialization.json.longOrNull
import kotlin.jvm.JvmInline
const val internalLinkBeginning = "https://t.me" const val internalLinkBeginning = "https://t.me"
@Serializable(ChatIdentifierSerializer::class) @Serializable(ChatIdentifierSerializer::class)
sealed class ChatIdentifier sealed interface ChatIdentifier
/** /**
* Also used as User Identifier * Also used as User Identifier
*/ */
@Serializable(ChatIdentifierSerializer::class) @Serializable(ChatIdentifierSerializer::class)
data class ChatId( sealed interface IdChatIdentifier : ChatIdentifier {
val chatId: Identifier abstract val chatId: Identifier
) : ChatIdentifier() val threadId: MessageThreadId?
get() = null
companion object {
operator fun invoke(chatId: Identifier) = ChatId(chatId)
}
}
@Serializable(ChatIdentifierSerializer::class)
@JvmInline
value class ChatId(override val chatId: Identifier) : IdChatIdentifier
@Serializable(ChatIdentifierSerializer::class)
@JvmInline
value class ChatIdWithThreadId(val chatIdWithThreadId: Pair<Identifier, MessageThreadId>) : IdChatIdentifier {
override val chatId: Identifier
get() = chatIdWithThreadId.first
override val threadId: MessageThreadId
get() = chatIdWithThreadId.second
constructor(chatId: Identifier, threadId: MessageThreadId): this(chatId to threadId)
}
val ChatIdentifier.threadId: MessageThreadId?
get() = (this as? IdChatIdentifier) ?.threadId
/** /**
* https://core.telegram.org/bots/api#formatting-options * https://core.telegram.org/bots/api#formatting-options
@ -39,16 +64,16 @@ val UserId.userLink: String
val User.link: String val User.link: String
get() = id.userLink get() = id.userLink
typealias UserId = ChatId typealias UserId = IdChatIdentifier
fun Identifier.toChatId(): ChatId = ChatId(this) fun Identifier.toChatId(): IdChatIdentifier = ChatId(this)
fun Int.toChatId(): ChatId = toLong().toChatId() fun Int.toChatId(): IdChatIdentifier = toLong().toChatId()
fun Byte.toChatId(): ChatId = toLong().toChatId() fun Byte.toChatId(): IdChatIdentifier = toLong().toChatId()
@Serializable(ChatIdentifierSerializer::class) @Serializable(ChatIdentifierSerializer::class)
data class Username( data class Username(
val username: String val username: String
) : ChatIdentifier() { ) : ChatIdentifier {
val usernameWithoutAt val usernameWithoutAt
get() = username.dropWhile { it == '@' } get() = username.dropWhile { it == '@' }
@ -80,7 +105,7 @@ object ChatIdentifierSerializer : KSerializer<ChatIdentifier> {
override fun serialize(encoder: Encoder, value: ChatIdentifier) { override fun serialize(encoder: Encoder, value: ChatIdentifier) {
when (value) { when (value) {
is ChatId -> encoder.encodeLong(value.chatId) is IdChatIdentifier -> encoder.encodeLong(value.chatId)
is Username -> encoder.encodeString(value.username) is Username -> encoder.encodeString(value.username)
} }
} }

View File

@ -14,7 +14,7 @@ data class RetryAfterError(
} }
data class MigrateChatId( data class MigrateChatId(
val newChatId: ChatId val newChatId: IdChatIdentifier
) : RequestError() ) : RequestError()

View File

@ -6,7 +6,7 @@ import kotlinx.serialization.*
@Serializable @Serializable
data class ResponseParametersRaw( data class ResponseParametersRaw(
@SerialName("migrate_to_chat_id") @SerialName("migrate_to_chat_id")
private val migrateToChatId: ChatId? = null, private val migrateToChatId: IdChatIdentifier? = null,
@SerialName("retry_after") @SerialName("retry_after")
private val retryAfter: Seconds? = null private val retryAfter: Seconds? = null
) { ) {

View File

@ -49,5 +49,5 @@ sealed interface AbleToAddInAttachmentMenuChat : Chat {
@Serializable(PreviewChatSerializer::class) @Serializable(PreviewChatSerializer::class)
@ClassCastsIncluded @ClassCastsIncluded
sealed interface Chat { sealed interface Chat {
val id: ChatId val id: IdChatIdentifier
} }

View File

@ -93,9 +93,9 @@ object PreviewChatSerializer : KSerializer<Chat> {
} }
@RiskFeature @RiskFeature
object ExtendedChatSerializer : KSerializer<ExtendedChat> { sealed class ExtendedChatSerializer : KSerializer<ExtendedChat> {
@OptIn(InternalSerializationApi::class) @OptIn(InternalSerializationApi::class)
override val descriptor: SerialDescriptor = buildSerialDescriptor("PreviewChatSerializer", PolymorphicKind.OPEN) override val descriptor: SerialDescriptor = buildSerialDescriptor("ExtendedChatSerializer", PolymorphicKind.OPEN)
override fun deserialize(decoder: Decoder): ExtendedChat { override fun deserialize(decoder: Decoder): ExtendedChat {
val decodedJson = JsonObject.serializer().deserialize(decoder) val decodedJson = JsonObject.serializer().deserialize(decoder)
@ -131,6 +131,22 @@ object ExtendedChatSerializer : KSerializer<ExtendedChat> {
is UnknownExtendedChat -> JsonObject.serializer().serialize(encoder, value.rawJson) is UnknownExtendedChat -> JsonObject.serializer().serialize(encoder, value.rawJson)
} }
} }
class BasedOnForumThread(private val threadId: MessageThreadId) : ExtendedChatSerializer() {
override fun deserialize(decoder: Decoder): ExtendedChat {
return super.deserialize(decoder).let {
if (it is ExtendedForumChatImpl) {
it.copy(
id = (it.id as? ChatIdWithThreadId) ?: ChatIdWithThreadId(it.id.chatId, threadId)
)
} else {
it
}
}
}
}
companion object : ExtendedChatSerializer()
} }
@RiskFeature @RiskFeature

View File

@ -10,7 +10,7 @@ import kotlinx.serialization.json.JsonObject
@Serializable @Serializable
data class ExtendedChannelChatImpl( data class ExtendedChannelChatImpl(
@SerialName(idField) @SerialName(idField)
override val id: ChatId, override val id: IdChatIdentifier,
@SerialName(titleField) @SerialName(titleField)
override val title: String, override val title: String,
@SerialName(usernameField) @SerialName(usernameField)
@ -27,13 +27,13 @@ data class ExtendedChannelChatImpl(
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
override val pinnedMessage: Message? = null, override val pinnedMessage: Message? = null,
@SerialName(linkedChatIdField) @SerialName(linkedChatIdField)
override val linkedGroupChatId: ChatId? = null override val linkedGroupChatId: IdChatIdentifier? = null
) : ExtendedChannelChat ) : ExtendedChannelChat
@Serializable @Serializable
data class ExtendedGroupChatImpl( data class ExtendedGroupChatImpl(
@SerialName(idField) @SerialName(idField)
override val id: ChatId, override val id: IdChatIdentifier,
@SerialName(titleField) @SerialName(titleField)
override val title: String, override val title: String,
@SerialName(photoField) @SerialName(photoField)
@ -52,7 +52,7 @@ data class ExtendedGroupChatImpl(
@Serializable @Serializable
data class ExtendedPrivateChatImpl( data class ExtendedPrivateChatImpl(
@SerialName(idField) @SerialName(idField)
override val id: ChatId, override val id: IdChatIdentifier,
@SerialName(photoField) @SerialName(photoField)
override val chatPhoto: ChatPhoto? = null, override val chatPhoto: ChatPhoto? = null,
@SerialName(usernameField) @SerialName(usernameField)
@ -78,7 +78,7 @@ typealias ExtendedUser = ExtendedPrivateChatImpl
@Serializable @Serializable
data class ExtendedSupergroupChatImpl( data class ExtendedSupergroupChatImpl(
@SerialName(idField) @SerialName(idField)
override val id: ChatId, override val id: IdChatIdentifier,
@SerialName(titleField) @SerialName(titleField)
override val title: String, override val title: String,
@SerialName(usernameField) @SerialName(usernameField)
@ -103,7 +103,7 @@ data class ExtendedSupergroupChatImpl(
@SerialName(canSetStickerSetField) @SerialName(canSetStickerSetField)
override val canSetStickerSet: Boolean = false, override val canSetStickerSet: Boolean = false,
@SerialName(linkedChatIdField) @SerialName(linkedChatIdField)
override val linkedChannelChatId: ChatId? = null, override val linkedChannelChatId: IdChatIdentifier? = null,
@SerialName(locationField) @SerialName(locationField)
override val location: ChatLocation? = null, override val location: ChatLocation? = null,
@SerialName(joinToSendMessagesField) @SerialName(joinToSendMessagesField)
@ -115,7 +115,7 @@ data class ExtendedSupergroupChatImpl(
@Serializable @Serializable
data class ExtendedForumChatImpl( data class ExtendedForumChatImpl(
@SerialName(idField) @SerialName(idField)
override val id: ChatId, override val id: IdChatIdentifier,
@SerialName(titleField) @SerialName(titleField)
override val title: String, override val title: String,
@SerialName(usernameField) @SerialName(usernameField)
@ -140,7 +140,7 @@ data class ExtendedForumChatImpl(
@SerialName(canSetStickerSetField) @SerialName(canSetStickerSetField)
override val canSetStickerSet: Boolean = false, override val canSetStickerSet: Boolean = false,
@SerialName(linkedChatIdField) @SerialName(linkedChatIdField)
override val linkedChannelChatId: ChatId? = null, override val linkedChannelChatId: IdChatIdentifier? = null,
@SerialName(locationField) @SerialName(locationField)
override val location: ChatLocation? = null, override val location: ChatLocation? = null,
@SerialName(joinToSendMessagesField) @SerialName(joinToSendMessagesField)
@ -170,7 +170,7 @@ data class ExtendedBot(
} }
data class UnknownExtendedChat( data class UnknownExtendedChat(
override val id: ChatId, override val id: IdChatIdentifier,
val raw: String, val raw: String,
val rawJson: JsonObject val rawJson: JsonObject
) : ExtendedChat { ) : ExtendedChat {

View File

@ -7,7 +7,7 @@ import kotlinx.serialization.Serializable
@Serializable(ExtendedChatSerializer::class) @Serializable(ExtendedChatSerializer::class)
sealed interface ExtendedChannelChat : ChannelChat, ExtendedPublicChat, ExtendedChatWithUsername { sealed interface ExtendedChannelChat : ChannelChat, ExtendedPublicChat, ExtendedChatWithUsername {
val linkedGroupChatId: ChatId? val linkedGroupChatId: IdChatIdentifier?
} }
@Serializable(ExtendedChatSerializer::class) @Serializable(ExtendedChatSerializer::class)
@ -38,7 +38,7 @@ sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat, Ext
val slowModeDelay: Long? val slowModeDelay: Long?
val stickerSetName: StickerSetName? val stickerSetName: StickerSetName?
val canSetStickerSet: Boolean val canSetStickerSet: Boolean
val linkedChannelChatId: ChatId? val linkedChannelChatId: IdChatIdentifier?
val location: ChatLocation? val location: ChatLocation?
/** /**
@ -53,7 +53,7 @@ sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat, Ext
} }
@Serializable(ExtendedChatSerializer::class) @Serializable(ExtendedChatSerializer::class)
sealed interface ExtendedForumChat : ExtendedSupergroupChat sealed interface ExtendedForumChat : ExtendedSupergroupChat, ForumChat
@Serializable(ExtendedChatSerializer::class) @Serializable(ExtendedChatSerializer::class)
sealed interface ExtendedChat : Chat { sealed interface ExtendedChat : Chat {

View File

@ -10,7 +10,7 @@ import kotlinx.serialization.Serializable
@Serializable @Serializable
data class GroupChatImpl( data class GroupChatImpl(
@SerialName(idField) @SerialName(idField)
override val id: ChatId, override val id: IdChatIdentifier,
@SerialName(titleField) @SerialName(titleField)
override val title: String override val title: String
) : GroupChat ) : GroupChat
@ -18,7 +18,7 @@ data class GroupChatImpl(
@Serializable @Serializable
data class PrivateChatImpl( data class PrivateChatImpl(
@SerialName(idField) @SerialName(idField)
override val id: ChatId, override val id: IdChatIdentifier,
@SerialName(usernameField) @SerialName(usernameField)
override val username: Username? = null, override val username: Username? = null,
@SerialName(firstNameField) @SerialName(firstNameField)
@ -30,7 +30,7 @@ data class PrivateChatImpl(
@Serializable @Serializable
data class SupergroupChatImpl( data class SupergroupChatImpl(
@SerialName(idField) @SerialName(idField)
override val id: ChatId, override val id: IdChatIdentifier,
@SerialName(titleField) @SerialName(titleField)
override val title: String, override val title: String,
@SerialName(usernameField) @SerialName(usernameField)
@ -40,7 +40,7 @@ data class SupergroupChatImpl(
@Serializable @Serializable
data class ForumChatImpl( data class ForumChatImpl(
@SerialName(idField) @SerialName(idField)
override val id: ChatId, override val id: IdChatIdentifier,
@SerialName(titleField) @SerialName(titleField)
override val title: String, override val title: String,
@SerialName(usernameField) @SerialName(usernameField)
@ -50,7 +50,7 @@ data class ForumChatImpl(
@Serializable @Serializable
data class ChannelChatImpl( data class ChannelChatImpl(
@SerialName(idField) @SerialName(idField)
override val id: ChatId, override val id: IdChatIdentifier,
@SerialName(titleField) @SerialName(titleField)
override val title: String, override val title: String,
@SerialName(usernameField) @SerialName(usernameField)

View File

@ -1,10 +1,10 @@
package dev.inmo.tgbotapi.types.chat package dev.inmo.tgbotapi.types.chat
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonObject
data class UnknownChatType( data class UnknownChatType(
override val id: ChatId, override val id: IdChatIdentifier,
val raw: String, val raw: String,
val rawJson: JsonObject val rawJson: JsonObject
) : Chat ) : Chat

View File

@ -1,8 +1,8 @@
package dev.inmo.tgbotapi.types.message.ChatEvents package dev.inmo.tgbotapi.types.message.ChatEvents
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.GroupEvent
class GroupChatCreated( class GroupChatCreated(
val migratedTo: ChatId? val migratedTo: IdChatIdentifier?
): GroupEvent ): GroupEvent

View File

@ -1,11 +1,11 @@
package dev.inmo.tgbotapi.types.message.ChatEvents package dev.inmo.tgbotapi.types.message.ChatEvents
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent
/** /**
* This event is sent when a group is converted to a supergroup. * This event is sent when a group is converted to a supergroup.
*/ */
data class MigratedToSupergroup( data class MigratedToSupergroup(
val migratedFrom: ChatId val migratedFrom: IdChatIdentifier
): SupergroupEvent ): SupergroupEvent

View File

@ -1,8 +1,8 @@
package dev.inmo.tgbotapi.types.message.ChatEvents package dev.inmo.tgbotapi.types.message.ChatEvents
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.SupergroupEvent
class SupergroupChatCreated( class SupergroupChatCreated(
val migratedFrom: ChatId? val migratedFrom: IdChatIdentifier?
): SupergroupEvent ): SupergroupEvent

View File

@ -81,8 +81,8 @@ internal data class RawMessage(
private val group_chat_created: Boolean = false, private val group_chat_created: Boolean = false,
private val supergroup_chat_created: Boolean = false, private val supergroup_chat_created: Boolean = false,
private val channel_chat_created: Boolean = false, private val channel_chat_created: Boolean = false,
private val migrate_to_chat_id: ChatId? = null, private val migrate_to_chat_id: IdChatIdentifier? = null,
private val migrate_from_chat_id: ChatId? = null, private val migrate_from_chat_id: IdChatIdentifier? = null,
private val pinned_message: RawMessage? = null, private val pinned_message: RawMessage? = null,
private val invoice: Invoice? = null, private val invoice: Invoice? = null,
private val dice: Dice? = null, private val dice: Dice? = null,
@ -286,9 +286,17 @@ internal data class RawMessage(
media_group_id media_group_id
) )
is ForumChat -> if (messageThreadId != null) { is ForumChat -> if (messageThreadId != null) {
val chatId = ChatIdWithThreadId(
chat.id.chatId,
messageThreadId
)
val actualForumChat = when (chat) {
is ExtendedForumChatImpl -> chat.copy(id = chatId)
is ForumChatImpl -> chat.copy(id = chatId)
}
when (sender_chat) { when (sender_chat) {
is ChannelChat -> FromChannelForumContentMessageImpl( is ChannelChat -> FromChannelForumContentMessageImpl(
chat, actualForumChat,
sender_chat, sender_chat,
messageId, messageId,
messageThreadId, messageThreadId,
@ -304,7 +312,7 @@ internal data class RawMessage(
media_group_id media_group_id
) )
is GroupChat -> AnonymousForumContentMessageImpl( is GroupChat -> AnonymousForumContentMessageImpl(
chat, actualForumChat,
messageId, messageId,
messageThreadId, messageThreadId,
date.asDate, date.asDate,
@ -319,7 +327,7 @@ internal data class RawMessage(
media_group_id media_group_id
) )
null -> CommonForumContentMessageImpl( null -> CommonForumContentMessageImpl(
chat, actualForumChat,
messageId, messageId,
messageThreadId, messageThreadId,
from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"), from ?: error("It is expected that in messages from non anonymous users and channels user must be specified"),

View File

@ -1,19 +1,18 @@
package dev.inmo.tgbotapi.utils.extensions package dev.inmo.tgbotapi.utils.extensions
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.utils.extensions.ChatIdWithThreadId.ByPair
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlin.Pair import kotlin.Pair
import kotlin.jvm.JvmInline import kotlin.jvm.JvmInline
/** /**
* Union to keep both [ChatId] and optionally [MessageThreadId] as an identifier of target for messages sending and * Union to keep both [IdChatIdentifier] and optionally [MessageThreadId] as an identifier of target for messages sending and
* other information * other information
*/ */
sealed interface ChatIdWithThreadId { sealed interface ChatIdWithThreadId {
val chatId: ChatId val chatId: IdChatIdentifier
val threadId: MessageThreadId? val threadId: MessageThreadId?
/** /**
@ -23,14 +22,14 @@ sealed interface ChatIdWithThreadId {
value class ByMessage( value class ByMessage(
val sourceMessage: Message val sourceMessage: Message
) : ChatIdWithThreadId { ) : ChatIdWithThreadId {
override val chatId: ChatId override val chatId: IdChatIdentifier
get() = sourceMessage.chat.id get() = sourceMessage.chat.id
override val threadId: MessageThreadId? override val threadId: MessageThreadId?
get() = sourceMessage.threadIdOrNull get() = sourceMessage.threadIdOrNull
} }
/** /**
* [Serializable] variant of [ChatIdWithThreadId] based on [Pair] of target [ChatId] and [MessageThreadId] * [Serializable] variant of [ChatIdWithThreadId] based on [Pair] of target [IdChatIdentifier] and [MessageThreadId]
* *
* @see invoke * @see invoke
* @see serializable * @see serializable
@ -38,9 +37,9 @@ sealed interface ChatIdWithThreadId {
@Serializable @Serializable
@JvmInline @JvmInline
value class ByPair( value class ByPair(
val pair: Pair<ChatId, MessageThreadId?> val pair: Pair<IdChatIdentifier, MessageThreadId?>
) : ChatIdWithThreadId { ) : ChatIdWithThreadId {
override val chatId: ChatId override val chatId: IdChatIdentifier
get() = pair.first get() = pair.first
override val threadId: MessageThreadId? override val threadId: MessageThreadId?
get() = pair.second get() = pair.second
@ -61,7 +60,7 @@ sealed interface ChatIdWithThreadId {
/** /**
* Creates [ByPair] variant of [ChatIdWithThreadId] using incoming [pair] * Creates [ByPair] variant of [ChatIdWithThreadId] using incoming [pair]
*/ */
inline fun serializable(pair: Pair<ChatId, MessageThreadId?>) = ByPair(pair) inline fun serializable(pair: Pair<IdChatIdentifier, MessageThreadId?>) = ByPair(pair)
} }
} }
/** /**

View File

@ -3,13 +3,11 @@ package dev.inmo.tgbotapi.types.message.ChatEvents
import dev.inmo.tgbotapi.TestsJsonFormat import dev.inmo.tgbotapi.TestsJsonFormat
import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate
import dev.inmo.tgbotapi.extensions.utils.asMigratedToSupergroup import dev.inmo.tgbotapi.extensions.utils.asMigratedToSupergroup
import dev.inmo.tgbotapi.extensions.utils.asSupergroupChatCreated
import dev.inmo.tgbotapi.extensions.utils.asSupergroupEventMessage import dev.inmo.tgbotapi.extensions.utils.asSupergroupEventMessage
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.update.abstracts.UpdateDeserializationStrategy import dev.inmo.tgbotapi.types.update.abstracts.UpdateDeserializationStrategy
import kotlin.test.Test import kotlin.test.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertIs
import kotlin.test.fail import kotlin.test.fail
@ -47,6 +45,6 @@ class MigratedToSupergroupTest {
val data = message.data.asSupergroupEventMessage() ?: fail("message should be of SupergroupEventMessage subtype") val data = message.data.asSupergroupEventMessage() ?: fail("message should be of SupergroupEventMessage subtype")
val event = data.chatEvent.asMigratedToSupergroup() ?: fail("event should be of SupergroupChatCreated subtype") val event = data.chatEvent.asMigratedToSupergroup() ?: fail("event should be of SupergroupChatCreated subtype")
assertEquals(ChatId(57005), event.migratedFrom) assertEquals(IdChatIdentifier(57005), event.migratedFrom)
} }
} }

View File

@ -160,10 +160,10 @@ inline val Message.supergroup_chat_created: Boolean
inline val Message.channel_chat_created: Boolean inline val Message.channel_chat_created: Boolean
get() = asChatEventMessage() ?.chatEvent is ChannelChatCreated get() = asChatEventMessage() ?.chatEvent is ChannelChatCreated
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.migrate_to_chat_id: ChatId? inline val Message.migrate_to_chat_id: IdChatIdentifier?
get() = asChatEventMessage() ?.chatEvent ?.asGroupChatCreated() ?.migratedTo get() = asChatEventMessage() ?.chatEvent ?.asGroupChatCreated() ?.migratedTo
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.migrate_from_chat_id: ChatId? inline val Message.migrate_from_chat_id: IdChatIdentifier?
get() = asChatEventMessage() ?.chatEvent ?.let { get() = asChatEventMessage() ?.chatEvent ?.let {
it ?.asSupergroupChatCreated() ?.migratedFrom ?: it ?.asMigratedToSupergroup() ?.migratedFrom it ?.asSupergroupChatCreated() ?.migratedFrom ?: it ?.asMigratedToSupergroup() ?.migratedFrom
} }

View File

@ -200,7 +200,7 @@ infix fun String.mention(parseMode: ParseMode): String = when (parseMode) {
is MarkdownV2 -> mentionMarkdownV2() is MarkdownV2 -> mentionMarkdownV2()
} }
infix fun Pair<String, ChatId>.mention(parseMode: ParseMode): String = when (parseMode) { infix fun Pair<String, IdChatIdentifier>.mention(parseMode: ParseMode): String = when (parseMode) {
is HTML -> first.textMentionHTML(second) is HTML -> first.textMentionHTML(second)
is Markdown -> first.textMentionMarkdown(second) is Markdown -> first.textMentionMarkdown(second)
is MarkdownV2 -> first.textMentionMarkdownV2(second) is MarkdownV2 -> first.textMentionMarkdownV2(second)

View File

@ -1,16 +1,16 @@
package dev.inmo.tgbotapi.extensions.utils.updates package dev.inmo.tgbotapi.extensions.utils.updates
import dev.inmo.tgbotapi.types.ChatId import dev.inmo.tgbotapi.types.IdChatIdentifier
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filter
/** /**
* [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId] * [Flow.filter] incoming [BaseMessageUpdate]s by their [IdChatIdentifier]
*/ */
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdatesByChatId(chatId: ChatId): Flow<T> = filter { it.data.chat.id == chatId } fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdatesByChatId(chatId: IdChatIdentifier): Flow<T> = filter { it.data.chat.id == chatId }
/** /**
* [Flow.filter] incoming [BaseMessageUpdate]s by their [ChatId] using [Chat.id] of [chat] * [Flow.filter] incoming [BaseMessageUpdate]s by their [IdChatIdentifier] using [Chat.id] of [chat]
*/ */
fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdatesByChat(chat: Chat): Flow<T> = filterBaseMessageUpdatesByChatId(chat.id) fun <T : BaseMessageUpdate> Flow<T>.filterBaseMessageUpdatesByChat(chat: Chat): Flow<T> = filterBaseMessageUpdatesByChatId(chat.id)