From 799eadd7a7ab21a1178747469d884619a2ef6584 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 6 Feb 2020 22:44:26 +0600 Subject: [PATCH] add send contact extensions --- .../requests/send/SendContact.kt | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendContact.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendContact.kt index 51dff056f3..054ddc68a9 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendContact.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/SendContact.kt @@ -1,9 +1,11 @@ package com.github.insanusmokrassar.TelegramBotAPI.requests.send +import com.github.insanusmokrassar.TelegramBotAPI.bot.RequestsExecutor import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.ReplyingMarkupSendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.requests.send.abstracts.SendMessageRequest import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.ContactContent @@ -66,3 +68,51 @@ fun Contact.toRequest( replyToMessageId, replyMarkup ) + +suspend fun RequestsExecutor.sendContact( + chatId: ChatIdentifier, + phoneNumber: String, + firstName: String, + lastName: String? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = execute( + SendContact( + chatId, phoneNumber, firstName, lastName, disableNotification, replyToMessageId, replyMarkup + ) +) + +suspend fun RequestsExecutor.sendContact( + chatId: ChatIdentifier, + contact: Contact, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = execute( + SendContact( + chatId, contact, disableNotification, replyToMessageId, replyMarkup + ) +) + +suspend fun RequestsExecutor.sendContact( + chat: Chat, + phoneNumber: String, + firstName: String, + lastName: String? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendContact( + chat.id, phoneNumber, firstName, lastName, disableNotification, replyToMessageId, replyMarkup +) + +suspend fun RequestsExecutor.sendContact( + chat: Chat, + contact: Contact, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendContact( + chat.id, contact, disableNotification, replyToMessageId, replyMarkup +)