mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 03:58:44 +00:00
add support of topics for actions
This commit is contained in:
parent
463d5252bd
commit
b064becb8a
@ -3,104 +3,129 @@ package dev.inmo.tgbotapi.extensions.api.send
|
|||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.send.SendAction
|
import dev.inmo.tgbotapi.requests.send.SendAction
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||||
import dev.inmo.tgbotapi.types.actions.*
|
import dev.inmo.tgbotapi.types.actions.*
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
import dev.inmo.tgbotapi.types.threadId
|
||||||
|
|
||||||
suspend fun TelegramBot.sendBotAction(
|
suspend fun TelegramBot.sendBotAction(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
action: BotAction
|
action: BotAction,
|
||||||
|
threadId: MessageThreadId? = chatId.threadId
|
||||||
) = execute(
|
) = execute(
|
||||||
SendAction(chatId, action)
|
SendAction(chatId, action, threadId)
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendBotAction(
|
suspend fun TelegramBot.sendBotAction(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
action: BotAction
|
action: BotAction,
|
||||||
) = sendBotAction(chat.id, action)
|
threadId: MessageThreadId? = chat.id.threadId
|
||||||
|
) = sendBotAction(chat.id, action, threadId)
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionTyping(
|
suspend fun TelegramBot.sendActionTyping(
|
||||||
chatId: ChatIdentifier
|
chatId: ChatIdentifier,
|
||||||
) = sendBotAction(chatId, TypingAction)
|
threadId: MessageThreadId? = chatId.threadId
|
||||||
|
) = sendBotAction(chatId, TypingAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionUploadPhoto(
|
suspend fun TelegramBot.sendActionUploadPhoto(
|
||||||
chatId: ChatIdentifier
|
chatId: ChatIdentifier,
|
||||||
) = sendBotAction(chatId, UploadPhotoAction)
|
threadId: MessageThreadId? = chatId.threadId
|
||||||
|
) = sendBotAction(chatId, UploadPhotoAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionRecordVideo(
|
suspend fun TelegramBot.sendActionRecordVideo(
|
||||||
chatId: ChatIdentifier
|
chatId: ChatIdentifier,
|
||||||
) = sendBotAction(chatId, RecordVideoAction)
|
threadId: MessageThreadId? = chatId.threadId
|
||||||
|
) = sendBotAction(chatId, RecordVideoAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionUploadVideo(
|
suspend fun TelegramBot.sendActionUploadVideo(
|
||||||
chatId: ChatIdentifier
|
chatId: ChatIdentifier,
|
||||||
) = sendBotAction(chatId, UploadVideoAction)
|
threadId: MessageThreadId? = chatId.threadId
|
||||||
|
) = sendBotAction(chatId, UploadVideoAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionRecordVoice(
|
suspend fun TelegramBot.sendActionRecordVoice(
|
||||||
chatId: ChatIdentifier
|
chatId: ChatIdentifier,
|
||||||
) = sendBotAction(chatId, RecordVoiceAction)
|
threadId: MessageThreadId? = chatId.threadId
|
||||||
|
) = sendBotAction(chatId, RecordVoiceAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionUploadVoice(
|
suspend fun TelegramBot.sendActionUploadVoice(
|
||||||
chatId: ChatIdentifier
|
chatId: ChatIdentifier,
|
||||||
) = sendBotAction(chatId, UploadVoiceAction)
|
threadId: MessageThreadId? = chatId.threadId
|
||||||
|
) = sendBotAction(chatId, UploadVoiceAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionUploadDocument(
|
suspend fun TelegramBot.sendActionUploadDocument(
|
||||||
chatId: ChatIdentifier
|
chatId: ChatIdentifier,
|
||||||
) = sendBotAction(chatId, UploadDocumentAction)
|
threadId: MessageThreadId? = chatId.threadId
|
||||||
|
) = sendBotAction(chatId, UploadDocumentAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionFindLocation(
|
suspend fun TelegramBot.sendActionFindLocation(
|
||||||
chatId: ChatIdentifier
|
chatId: ChatIdentifier,
|
||||||
) = sendBotAction(chatId, FindLocationAction)
|
threadId: MessageThreadId? = chatId.threadId
|
||||||
|
) = sendBotAction(chatId, FindLocationAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionRecordVideoNote(
|
suspend fun TelegramBot.sendActionRecordVideoNote(
|
||||||
chatId: ChatIdentifier
|
chatId: ChatIdentifier,
|
||||||
) = sendBotAction(chatId, RecordVideoNoteAction)
|
threadId: MessageThreadId? = chatId.threadId
|
||||||
|
) = sendBotAction(chatId, RecordVideoNoteAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionUploadVideoNote(
|
suspend fun TelegramBot.sendActionUploadVideoNote(
|
||||||
chatId: ChatIdentifier
|
chatId: ChatIdentifier,
|
||||||
) = sendBotAction(chatId, UploadVideoNoteAction)
|
threadId: MessageThreadId? = chatId.threadId
|
||||||
|
) = sendBotAction(chatId, UploadVideoNoteAction, threadId)
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionTyping(
|
suspend fun TelegramBot.sendActionTyping(
|
||||||
chat: Chat
|
chat: Chat,
|
||||||
) = sendBotAction(chat, TypingAction)
|
threadId: MessageThreadId? = chat.id.threadId
|
||||||
|
) = sendBotAction(chat, TypingAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionUploadPhoto(
|
suspend fun TelegramBot.sendActionUploadPhoto(
|
||||||
chat: Chat
|
chat: Chat,
|
||||||
) = sendBotAction(chat, UploadPhotoAction)
|
threadId: MessageThreadId? = chat.id.threadId
|
||||||
|
) = sendBotAction(chat, UploadPhotoAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionRecordVideo(
|
suspend fun TelegramBot.sendActionRecordVideo(
|
||||||
chat: Chat
|
chat: Chat,
|
||||||
) = sendBotAction(chat, RecordVideoAction)
|
threadId: MessageThreadId? = chat.id.threadId
|
||||||
|
) = sendBotAction(chat, RecordVideoAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionUploadVideo(
|
suspend fun TelegramBot.sendActionUploadVideo(
|
||||||
chat: Chat
|
chat: Chat,
|
||||||
) = sendBotAction(chat, UploadVideoAction)
|
threadId: MessageThreadId? = chat.id.threadId
|
||||||
|
) = sendBotAction(chat, UploadVideoAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionRecordVoice(
|
suspend fun TelegramBot.sendActionRecordVoice(
|
||||||
chat: Chat
|
chat: Chat,
|
||||||
) = sendBotAction(chat, RecordVoiceAction)
|
threadId: MessageThreadId? = chat.id.threadId
|
||||||
|
) = sendBotAction(chat, RecordVoiceAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionUploadVoice(
|
suspend fun TelegramBot.sendActionUploadVoice(
|
||||||
chat: Chat
|
chat: Chat,
|
||||||
) = sendBotAction(chat, UploadVoiceAction)
|
threadId: MessageThreadId? = chat.id.threadId
|
||||||
|
) = sendBotAction(chat, UploadVoiceAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionUploadDocument(
|
suspend fun TelegramBot.sendActionUploadDocument(
|
||||||
chat: Chat
|
chat: Chat,
|
||||||
) = sendBotAction(chat, UploadDocumentAction)
|
threadId: MessageThreadId? = chat.id.threadId
|
||||||
|
) = sendBotAction(chat, UploadDocumentAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionFindLocation(
|
suspend fun TelegramBot.sendActionFindLocation(
|
||||||
chat: Chat
|
chat: Chat,
|
||||||
) = sendBotAction(chat, FindLocationAction)
|
threadId: MessageThreadId? = chat.id.threadId
|
||||||
|
) = sendBotAction(chat, FindLocationAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionRecordVideoNote(
|
suspend fun TelegramBot.sendActionRecordVideoNote(
|
||||||
chat: Chat
|
chat: Chat,
|
||||||
) = sendBotAction(chat, RecordVideoNoteAction)
|
threadId: MessageThreadId? = chat.id.threadId
|
||||||
|
) = sendBotAction(chat, RecordVideoNoteAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionUploadVideoNote(
|
suspend fun TelegramBot.sendActionUploadVideoNote(
|
||||||
chat: Chat
|
chat: Chat,
|
||||||
) = sendBotAction(chat, UploadVideoNoteAction)
|
threadId: MessageThreadId? = chat.id.threadId
|
||||||
|
) = sendBotAction(chat, UploadVideoNoteAction, threadId)
|
||||||
|
|
||||||
suspend fun TelegramBot.sendActionChooseStickerAction(
|
suspend fun TelegramBot.sendActionChooseStickerAction(
|
||||||
chat: Chat
|
chat: Chat,
|
||||||
) = sendBotAction(chat, ChooseStickerAction)
|
threadId: MessageThreadId? = chat.id.threadId
|
||||||
|
) = sendBotAction(chat, ChooseStickerAction, threadId)
|
||||||
|
|
||||||
|
@ -38,13 +38,14 @@ suspend fun <T> TelegramBot.withAction(
|
|||||||
suspend fun <T> TelegramBot.withAction(
|
suspend fun <T> TelegramBot.withAction(
|
||||||
chatId: IdChatIdentifier,
|
chatId: IdChatIdentifier,
|
||||||
action: BotAction,
|
action: BotAction,
|
||||||
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
block: TelegramBotActionCallback<T>
|
block: TelegramBotActionCallback<T>
|
||||||
): T {
|
): T {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
return withAction(
|
return withAction(
|
||||||
SendAction(chatId, action),
|
SendAction(chatId, action, threadId),
|
||||||
block
|
block
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -53,6 +54,7 @@ suspend fun <T> TelegramBot.withAction(
|
|||||||
suspend fun <T> TelegramBot.withAction(
|
suspend fun <T> TelegramBot.withAction(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
action: BotAction,
|
action: BotAction,
|
||||||
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
block: TelegramBotActionCallback<T>
|
block: TelegramBotActionCallback<T>
|
||||||
): T {
|
): T {
|
||||||
contract {
|
contract {
|
||||||
@ -61,163 +63,164 @@ suspend fun <T> TelegramBot.withAction(
|
|||||||
return withAction(
|
return withAction(
|
||||||
chat.id,
|
chat.id,
|
||||||
action,
|
action,
|
||||||
|
threadId,
|
||||||
block
|
block
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withTypingAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withTypingAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,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, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withUploadPhotoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withUploadPhotoAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,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, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withRecordVideoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withRecordVideoAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,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, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withUploadVideoAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withUploadVideoAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,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, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withRecordVoiceAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withRecordVoiceAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,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, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withUploadVoiceAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withUploadVoiceAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,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, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withUploadDocumentAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withUploadDocumentAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,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, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withFindLocationAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withFindLocationAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,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, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,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, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,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, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withChooseStickerAction(chatId: IdChatIdentifier, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withChooseStickerAction(chatId: IdChatIdentifier, threadId: MessageThreadId? = chatId.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
return withAction(chatId, ChooseStickerAction, block)
|
return withAction(chatId, ChooseStickerAction, threadId, block)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withTypingAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withTypingAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
return withAction(chat, TypingAction, block)
|
return withAction(chat, TypingAction, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withUploadPhotoAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withUploadPhotoAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
return withAction(chat, UploadPhotoAction, block)
|
return withAction(chat, UploadPhotoAction, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withRecordVideoAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withRecordVideoAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
return withAction(chat, RecordVideoAction, block)
|
return withAction(chat, RecordVideoAction, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withUploadVideoAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withUploadVideoAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
return withAction(chat, UploadVideoAction, block)
|
return withAction(chat, UploadVideoAction, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withRecordVoiceAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withRecordVoiceAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
return withAction(chat, RecordVoiceAction, block)
|
return withAction(chat, RecordVoiceAction, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withUploadVoiceAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withUploadVoiceAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
return withAction(chat, UploadVoiceAction, block)
|
return withAction(chat, UploadVoiceAction, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withUploadDocumentAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withUploadDocumentAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
return withAction(chat, UploadDocumentAction, block)
|
return withAction(chat, UploadDocumentAction, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withFindLocationAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withFindLocationAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
return withAction(chat, FindLocationAction, block)
|
return withAction(chat, FindLocationAction, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withRecordVideoNoteAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
return withAction(chat, RecordVideoNoteAction, block)
|
return withAction(chat, RecordVideoNoteAction, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withUploadVideoNoteAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
return withAction(chat, UploadVideoNoteAction, block)
|
return withAction(chat, UploadVideoNoteAction, threadId, block)
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalContracts::class)
|
@OptIn(ExperimentalContracts::class)
|
||||||
suspend fun <T> TelegramBot.withChooseStickerAction(chat: Chat, block: TelegramBotActionCallback<T>) : T {
|
suspend fun <T> TelegramBot.withChooseStickerAction(chat: Chat, threadId: MessageThreadId? = chat.id.threadId,block: TelegramBotActionCallback<T>) : T {
|
||||||
contract {
|
contract {
|
||||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||||
}
|
}
|
||||||
return withAction(chat, ChooseStickerAction, block)
|
return withAction(chat, ChooseStickerAction, threadId, block)
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send
|
package dev.inmo.tgbotapi.requests.send
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyMessageThreadRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.SendChatMessageRequest
|
import dev.inmo.tgbotapi.requests.send.abstracts.SendChatMessageRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.actions.BotAction
|
import dev.inmo.tgbotapi.types.actions.BotAction
|
||||||
@ -14,8 +15,10 @@ data class SendAction(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(actionField)
|
@SerialName(actionField)
|
||||||
val action: BotAction
|
val action: BotAction,
|
||||||
): SendChatMessageRequest<Boolean> {
|
@SerialName(messageThreadIdField)
|
||||||
|
override val threadId: MessageThreadId? = chatId.threadId
|
||||||
|
): SendChatMessageRequest<Boolean>, OptionallyMessageThreadRequest {
|
||||||
override fun method(): String = "sendChatAction"
|
override fun method(): String = "sendChatAction"
|
||||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||||
get() = Boolean.serializer()
|
get() = Boolean.serializer()
|
||||||
|
Loading…
Reference in New Issue
Block a user