1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-06-15 06:15:27 +00:00
tgbotapi/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/buttons/reply/ReplyKeyboardButtonsShortcuts.kt

219 lines
5.4 KiB
Kotlin
Raw Normal View History

2022-09-28 14:38:16 +00:00
package dev.inmo.tgbotapi.types.buttons.reply
import dev.inmo.tgbotapi.types.buttons.*
import dev.inmo.tgbotapi.types.chat.member.ChatCommonAdministratorRights
2024-01-10 17:05:44 +00:00
import dev.inmo.tgbotapi.types.keyboardButtonRequestUserLimit
2023-02-05 14:46:12 +00:00
import dev.inmo.tgbotapi.types.request.RequestId
2022-09-28 14:38:16 +00:00
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
2024-01-10 17:05:44 +00:00
import kotlin.math.max
2022-09-28 14:38:16 +00:00
/**
* Creates [SimpleKeyboardButton]
2022-09-28 14:38:16 +00:00
*/
inline fun simpleReplyButton(
text: String
) = SimpleKeyboardButton(text)
/**
* Creates [RequestContactKeyboardButton]
2022-09-28 14:38:16 +00:00
*/
inline fun requestContactReplyButton(
text: String
) = RequestContactKeyboardButton(text)
/**
* Creates [RequestLocationKeyboardButton]
2022-09-28 14:38:16 +00:00
*/
inline fun requestLocationReplyButton(
text: String
) = RequestLocationKeyboardButton(text)
/**
* Creates [RequestPollKeyboardButton]
2022-09-28 14:38:16 +00:00
*/
inline fun requestPollReplyButton(
text: String,
pollType: KeyboardButtonPollType
) = RequestPollKeyboardButton(text, pollType)
/**
* Creates [WebAppKeyboardButton]
2022-09-28 14:38:16 +00:00
*/
inline fun webAppReplyButton(
text: String,
webApp: WebAppInfo
) = WebAppKeyboardButton(text, webApp)
/**
* Creates [WebAppKeyboardButton]
2022-09-28 14:38:16 +00:00
*/
inline fun webAppReplyButton(
text: String,
url: String
) = webAppReplyButton(text, WebAppInfo(url))
/**
* Creates [RequestUserKeyboardButton]
*/
2024-01-10 17:05:44 +00:00
inline fun requestUsersReplyButton(
text: String,
2024-01-03 10:28:56 +00:00
requestUser: KeyboardButtonRequestUsers
) = RequestUserKeyboardButton(
text,
requestUser
)
/**
2024-01-03 10:28:56 +00:00
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Bot]
*/
2024-01-10 17:05:44 +00:00
inline fun requestBotsReplyButton(
text: String,
requestId: RequestId,
maxCount: Int = keyboardButtonRequestUserLimit.first
) = requestUsersReplyButton(
text,
KeyboardButtonRequestUsers.Bot(requestId, maxCount)
)
/**
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Common]
*/
inline fun requestUsersReplyButton(
text: String,
requestId: RequestId,
premiumUser: Boolean? = null,
maxCount: Int = keyboardButtonRequestUserLimit.first
) = requestUsersReplyButton(
text,
2024-01-10 17:05:44 +00:00
KeyboardButtonRequestUsers.Common(requestId, premiumUser, maxCount)
)
/**
2024-01-03 10:28:56 +00:00
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Common]
*/
inline fun requestUserReplyButton(
text: String,
requestId: RequestId,
2024-01-10 17:05:44 +00:00
premiumUser: Boolean? = null,
maxCount: Int = keyboardButtonRequestUserLimit.first
) = requestUsersReplyButton(
text,
requestId,
premiumUser,
maxCount
)
/**
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Any]
*/
inline fun requestUsersOrBotsReplyButton(
text: String,
requestId: RequestId,
premiumUser: Boolean? = null,
maxCount: Int = keyboardButtonRequestUserLimit.first
) = requestUsersReplyButton(
text,
2024-01-10 17:05:44 +00:00
KeyboardButtonRequestUsers.Any(requestId, premiumUser, maxCount)
)
/**
2024-01-03 10:28:56 +00:00
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Any]
*/
inline fun requestUserOrBotReplyButton(
text: String,
requestId: RequestId
2024-03-16 13:45:23 +00:00
) = requestUsersReplyButton(
text,
2024-01-03 10:28:56 +00:00
KeyboardButtonRequestUsers.Any(requestId)
)
/**
* Creates [RequestChatKeyboardButton]
*/
inline fun requestChatReplyButton(
text: String,
requestChat: KeyboardButtonRequestChat
) = RequestChatKeyboardButton(
text,
requestChat
)
/**
* Creates [RequestChatKeyboardButton] with [KeyboardButtonRequestChat]
*/
inline fun requestChatReplyButton(
text: String,
requestId: RequestId,
isChannel: Boolean? = null,
isForum: Boolean? = null,
2023-02-05 17:26:41 +00:00
isPublic: Boolean? = null,
isOwnedBy: Boolean? = null,
userRightsInChat: ChatCommonAdministratorRights? = null,
botRightsInChat: ChatCommonAdministratorRights? = null,
botIsMember: Boolean = false
) = requestChatReplyButton(
text,
KeyboardButtonRequestChat(
2023-02-05 17:26:41 +00:00
requestId = requestId,
isChannel = isChannel,
isForum = isForum,
isPublic = isPublic,
isOwnedBy = isOwnedBy,
userRightsInChat = userRightsInChat,
botRightsInChat = botRightsInChat,
botIsMember = botIsMember
)
)
/**
* Creates [RequestChatKeyboardButton] with [KeyboardButtonRequestChat.Channel]
*/
inline fun requestChannelReplyButton(
text: String,
requestId: RequestId,
isPublic: Boolean? = null,
isOwnedBy: Boolean? = null,
userRightsInChat: ChatCommonAdministratorRights? = null,
botRightsInChat: ChatCommonAdministratorRights? = null,
botIsMember: Boolean = false
) = requestChatReplyButton(
text,
KeyboardButtonRequestChat.Channel(
requestId = requestId,
isPublic = isPublic,
isOwnedBy = isOwnedBy,
userRightsInChat = userRightsInChat,
botRightsInChat = botRightsInChat,
botIsMember = botIsMember
)
)
/**
* Creates [RequestChatKeyboardButton] with [KeyboardButtonRequestChat.Group]
*/
inline fun requestChannelReplyButton(
text: String,
requestId: RequestId,
isForum: Boolean? = null,
isPublic: Boolean? = null,
isOwnedBy: Boolean? = null,
userRightsInChat: ChatCommonAdministratorRights? = null,
botRightsInChat: ChatCommonAdministratorRights? = null,
botIsMember: Boolean? = null
) = requestChatReplyButton(
text,
KeyboardButtonRequestChat.Group(
requestId = requestId,
isForum = isForum,
isPublic = isPublic,
isOwnedBy = isOwnedBy,
userRightsInChat = userRightsInChat,
botRightsInChat = botRightsInChat,
botIsMember = botIsMember
)
)