mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-29 13:38:43 +00:00
add send bot action extensions
This commit is contained in:
parent
f8ffd5fec3
commit
cc433d4091
@ -1,8 +1,10 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
package com.github.insanusmokrassar.TelegramBotAPI.requests.send
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendChatMessageRequest
|
import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendChatMessageRequest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.*
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.actions.BotAction
|
import com.github.insanusmokrassar.TelegramBotAPI.types.actions.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
import kotlinx.serialization.internal.BooleanSerializer
|
import kotlinx.serialization.internal.BooleanSerializer
|
||||||
|
|
||||||
@ -22,3 +24,99 @@ data class SendAction(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendBotAction(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
action: BotAction
|
||||||
|
) = execute(
|
||||||
|
SendAction(chatId, action)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendBotAction(
|
||||||
|
chat: Chat,
|
||||||
|
action: BotAction
|
||||||
|
) = sendBotAction(chat.id, action)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionTyping(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, TypingAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadPhoto(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadPhotoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordVideo(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, RecordVideoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadVideo(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadVideoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordAudio(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, RecordAudioAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadAudio(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadAudioAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadDocument(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadDocumentAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionFindLocation(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, FindLocationAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordVideoNote(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, RecordVideoNoteAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadVideoNote(
|
||||||
|
chatId: ChatIdentifier
|
||||||
|
) = sendBotAction(chatId, UploadVideoNoteAction)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionTyping(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, TypingAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadPhoto(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadPhotoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordVideo(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, RecordVideoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadVideo(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadVideoAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordAudio(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, RecordAudioAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadAudio(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadAudioAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadDocument(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadDocumentAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionFindLocation(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, FindLocationAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionRecordVideoNote(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, RecordVideoNoteAction)
|
||||||
|
|
||||||
|
suspend fun RequestsExecutor.sendActionUploadVideoNote(
|
||||||
|
chat: Chat
|
||||||
|
) = sendBotAction(chat, UploadVideoNoteAction)
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ internal object BotActionSerializer: KSerializer<BotAction> {
|
|||||||
UploadAudioAction.actionName -> UploadAudioAction
|
UploadAudioAction.actionName -> UploadAudioAction
|
||||||
UploadDocumentAction.actionName -> UploadDocumentAction
|
UploadDocumentAction.actionName -> UploadDocumentAction
|
||||||
FindLocationAction.actionName -> FindLocationAction
|
FindLocationAction.actionName -> FindLocationAction
|
||||||
|
RecordVideoNoteAction.actionName -> RecordVideoNoteAction
|
||||||
|
UploadVideoNoteAction.actionName -> UploadVideoNoteAction
|
||||||
else -> throw IllegalStateException("Unknown action type: $actionName")
|
else -> throw IllegalStateException("Unknown action type: $actionName")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,3 +73,13 @@ object UploadDocumentAction : BotAction() {
|
|||||||
object FindLocationAction : BotAction() {
|
object FindLocationAction : BotAction() {
|
||||||
override val actionName: String = "find_location"
|
override val actionName: String = "find_location"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Serializable(BotActionSerializer::class)
|
||||||
|
object RecordVideoNoteAction : BotAction() {
|
||||||
|
override val actionName: String = "record_video_note"
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable(BotActionSerializer::class)
|
||||||
|
object UploadVideoNoteAction : BotAction() {
|
||||||
|
override val actionName: String = "upload_video_note"
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user