mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
improvements in KeyboardButtonRequestChat
This commit is contained in:
parent
aca076381b
commit
2a3ffd707e
@ -13,6 +13,10 @@ import dev.inmo.tgbotapi.types.userAdministratorRightsField
|
|||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Channel
|
||||||
|
* @see Group
|
||||||
|
*/
|
||||||
@Serializable
|
@Serializable
|
||||||
data class KeyboardButtonRequestChat(
|
data class KeyboardButtonRequestChat(
|
||||||
@SerialName(requestIdField)
|
@SerialName(requestIdField)
|
||||||
@ -31,5 +35,44 @@ data class KeyboardButtonRequestChat(
|
|||||||
val botRightsInChat: ChatAdministratorRights? = null,
|
val botRightsInChat: ChatAdministratorRights? = null,
|
||||||
@SerialName(botIsMemberField)
|
@SerialName(botIsMemberField)
|
||||||
val botIsMember: Boolean? = null
|
val botIsMember: Boolean? = null
|
||||||
|
) {
|
||||||
|
companion object {
|
||||||
|
fun Channel(
|
||||||
|
requestId: RequestId,
|
||||||
|
isPublic: Boolean? = null,
|
||||||
|
isOwnedBy: Boolean? = null,
|
||||||
|
userRightsInChat: ChatAdministratorRights? = null,
|
||||||
|
botRightsInChat: ChatAdministratorRights? = null,
|
||||||
|
botIsMember: Boolean? = null
|
||||||
|
) = KeyboardButtonRequestChat(
|
||||||
|
requestId = requestId,
|
||||||
|
isChannel = true,
|
||||||
|
isForum = null,
|
||||||
|
isPublic = isPublic,
|
||||||
|
isOwnedBy = isOwnedBy,
|
||||||
|
userRightsInChat = userRightsInChat,
|
||||||
|
botRightsInChat = botRightsInChat,
|
||||||
|
botIsMember = botIsMember
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun Group(
|
||||||
|
requestId: RequestId,
|
||||||
|
isForum: Boolean? = null,
|
||||||
|
isPublic: Boolean? = null,
|
||||||
|
isOwnedBy: Boolean? = null,
|
||||||
|
userRightsInChat: ChatAdministratorRights? = null,
|
||||||
|
botRightsInChat: ChatAdministratorRights? = null,
|
||||||
|
botIsMember: Boolean? = null
|
||||||
|
) = KeyboardButtonRequestChat(
|
||||||
|
requestId = requestId,
|
||||||
|
isChannel = false,
|
||||||
|
isForum = isForum,
|
||||||
|
isPublic = isPublic,
|
||||||
|
isOwnedBy = isOwnedBy,
|
||||||
|
userRightsInChat = userRightsInChat,
|
||||||
|
botRightsInChat = botRightsInChat,
|
||||||
|
botIsMember = botIsMember
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -172,3 +172,58 @@ inline fun requestChatReplyButton(
|
|||||||
botIsMember = botIsMember
|
botIsMember = botIsMember
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [RequestChatKeyboardButton] with [KeyboardButtonRequestChat.Channel]
|
||||||
|
*
|
||||||
|
* @see replyKeyboard
|
||||||
|
* @see ReplyKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun requestChannelReplyButton(
|
||||||
|
text: String,
|
||||||
|
requestId: RequestId,
|
||||||
|
isPublic: Boolean? = null,
|
||||||
|
isOwnedBy: Boolean? = null,
|
||||||
|
userRightsInChat: ChatAdministratorRights? = null,
|
||||||
|
botRightsInChat: ChatAdministratorRights? = null,
|
||||||
|
botIsMember: Boolean = false
|
||||||
|
) = requestChatReplyButton(
|
||||||
|
text,
|
||||||
|
KeyboardButtonRequestChat.Channel(
|
||||||
|
requestId = requestId,
|
||||||
|
isPublic = isPublic,
|
||||||
|
isOwnedBy = isOwnedBy,
|
||||||
|
userRightsInChat = userRightsInChat,
|
||||||
|
botRightsInChat = botRightsInChat,
|
||||||
|
botIsMember = botIsMember
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [RequestChatKeyboardButton] with [KeyboardButtonRequestChat.Group]
|
||||||
|
*
|
||||||
|
* @see replyKeyboard
|
||||||
|
* @see ReplyKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun requestChannelReplyButton(
|
||||||
|
text: String,
|
||||||
|
requestId: RequestId,
|
||||||
|
isForum: Boolean? = null,
|
||||||
|
isPublic: Boolean? = null,
|
||||||
|
isOwnedBy: Boolean? = null,
|
||||||
|
userRightsInChat: ChatAdministratorRights? = null,
|
||||||
|
botRightsInChat: ChatAdministratorRights? = null,
|
||||||
|
botIsMember: Boolean? = null
|
||||||
|
) = requestChatReplyButton(
|
||||||
|
text,
|
||||||
|
KeyboardButtonRequestChat.Group(
|
||||||
|
requestId = requestId,
|
||||||
|
isForum = isForum,
|
||||||
|
isPublic = isPublic,
|
||||||
|
isOwnedBy = isOwnedBy,
|
||||||
|
userRightsInChat = userRightsInChat,
|
||||||
|
botRightsInChat = botRightsInChat,
|
||||||
|
botIsMember = botIsMember
|
||||||
|
)
|
||||||
|
)
|
||||||
|
@ -249,3 +249,57 @@ inline fun ReplyKeyboardRowBuilder.requestChatButton(
|
|||||||
botIsMember = botIsMember
|
botIsMember = botIsMember
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [RequestChatKeyboardButton] with [KeyboardButtonRequestChat.Channel]
|
||||||
|
*
|
||||||
|
* @see replyKeyboard
|
||||||
|
* @see ReplyKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun ReplyKeyboardRowBuilder.requestChannelButton(
|
||||||
|
text: String,
|
||||||
|
requestId: RequestId,
|
||||||
|
isPublic: Boolean? = null,
|
||||||
|
isOwnedBy: Boolean? = null,
|
||||||
|
userRightsInChat: ChatAdministratorRights? = null,
|
||||||
|
botRightsInChat: ChatAdministratorRights? = null,
|
||||||
|
botIsMember: Boolean? = null
|
||||||
|
) = requestChatButton(
|
||||||
|
text,
|
||||||
|
KeyboardButtonRequestChat.Channel(
|
||||||
|
requestId = requestId,
|
||||||
|
isPublic = isPublic,
|
||||||
|
isOwnedBy = isOwnedBy,
|
||||||
|
userRightsInChat = userRightsInChat,
|
||||||
|
botRightsInChat = botRightsInChat,
|
||||||
|
botIsMember = botIsMember
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and put [RequestChatKeyboardButton] with [KeyboardButtonRequestChat.Group]
|
||||||
|
*
|
||||||
|
* @see replyKeyboard
|
||||||
|
* @see ReplyKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun ReplyKeyboardRowBuilder.requestGroupButton(
|
||||||
|
text: String,
|
||||||
|
requestId: RequestId,
|
||||||
|
isForum: Boolean? = null,
|
||||||
|
isPublic: Boolean? = null,
|
||||||
|
isOwnedBy: Boolean? = null,
|
||||||
|
userRightsInChat: ChatAdministratorRights? = null,
|
||||||
|
botRightsInChat: ChatAdministratorRights? = null,
|
||||||
|
botIsMember: Boolean? = null
|
||||||
|
) = requestChatButton(
|
||||||
|
text,
|
||||||
|
KeyboardButtonRequestChat.Group(
|
||||||
|
requestId = requestId,
|
||||||
|
isForum = isForum,
|
||||||
|
isPublic = isPublic,
|
||||||
|
isOwnedBy = isOwnedBy,
|
||||||
|
userRightsInChat = userRightsInChat,
|
||||||
|
botRightsInChat = botRightsInChat,
|
||||||
|
botIsMember = botIsMember
|
||||||
|
)
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user