tgbotapi/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChat.kt

133 lines
3.5 KiB
Kotlin
Raw Normal View History

package dev.inmo.tgbotapi.extensions.api.chat.get
2020-02-15 09:33:04 +00:00
2020-10-04 11:06:30 +00:00
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetChat
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.chat.abstracts.*
import dev.inmo.tgbotapi.types.chat.abstracts.extended.*
import dev.inmo.tgbotapi.types.chat.extended.*
import dev.inmo.tgbotapi.utils.PreviewFeature
2020-02-15 09:33:04 +00:00
suspend fun TelegramBot.getChat(
2020-02-15 09:33:04 +00:00
chatId: ChatIdentifier
) = execute(GetChat(chatId))
suspend fun TelegramBot.getChat(
2020-02-15 09:33:04 +00:00
chat: Chat
) = getChat(chat.id)
2020-06-02 07:54:30 +00:00
/**
2020-10-04 11:06:30 +00:00
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
2020-06-02 07:54:30 +00:00
* [ExtendedPublicChat] with unsafe operator "as"
*
* @throws ClassCastException
*/
@PreviewFeature
suspend fun TelegramBot.getChat(
2020-06-02 07:54:30 +00:00
chat: PublicChat
) = getChat(chat.id) as ExtendedPublicChat
/**
2020-10-04 11:06:30 +00:00
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
2020-06-02 07:54:30 +00:00
* [ExtendedChannelChat] with unsafe operator "as"
*
* @throws ClassCastException
*/
@PreviewFeature
suspend fun TelegramBot.getChat(
2020-06-02 07:54:30 +00:00
chat: ChannelChat
) = getChat(chat.id) as ExtendedChannelChat
/**
2020-10-04 11:06:30 +00:00
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
2020-06-02 07:54:30 +00:00
* [ExtendedChannelChatImpl] with unsafe operator "as"
*
* @throws ClassCastException
*/
@PreviewFeature
suspend fun TelegramBot.getChat(
2020-06-02 07:54:30 +00:00
chat: ChannelChatImpl
) = getChat(chat.id) as ExtendedChannelChatImpl
/**
2020-10-04 11:06:30 +00:00
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
2020-06-02 07:54:30 +00:00
* [ExtendedGroupChat] with unsafe operator "as"
*
* @throws ClassCastException
*/
@PreviewFeature
suspend fun TelegramBot.getChat(
2020-06-02 07:54:30 +00:00
chat: GroupChat
) = getChat(chat.id) as ExtendedGroupChat
/**
2020-10-04 11:06:30 +00:00
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
2020-06-02 07:54:30 +00:00
* [ExtendedGroupChatImpl] with unsafe operator "as"
*
* @throws ClassCastException
*/
@PreviewFeature
suspend fun TelegramBot.getChat(
2020-06-02 07:54:30 +00:00
chat: GroupChatImpl
) = getChat(chat.id) as ExtendedGroupChatImpl
/**
2020-10-04 11:06:30 +00:00
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
2020-06-02 07:54:30 +00:00
* [ExtendedSupergroupChat] with unsafe operator "as"
*
* @throws ClassCastException
*/
@PreviewFeature
suspend fun TelegramBot.getChat(
2020-06-02 07:54:30 +00:00
chat: SupergroupChat
) = getChat(chat.id) as ExtendedSupergroupChat
/**
2020-10-04 11:06:30 +00:00
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
2020-06-02 07:54:30 +00:00
* [ExtendedSupergroupChatImpl] with unsafe operator "as"
*
* @throws ClassCastException
*/
@PreviewFeature
suspend fun TelegramBot.getChat(
2020-06-02 07:54:30 +00:00
chat: SupergroupChatImpl
) = getChat(chat.id) as ExtendedSupergroupChatImpl
/**
2020-10-04 11:06:30 +00:00
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
2020-06-02 07:54:30 +00:00
* [ExtendedPrivateChat] with unsafe operator "as"
*
* @throws ClassCastException
*/
@PreviewFeature
suspend fun TelegramBot.getChat(
2020-06-02 07:54:30 +00:00
chat: PrivateChat
) = getChat(chat.id) as ExtendedPrivateChat
/**
2020-10-04 11:06:30 +00:00
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
2020-06-02 07:54:30 +00:00
* [ExtendedPrivateChatImpl] with unsafe operator "as"
*
* @throws ClassCastException
*/
@PreviewFeature
suspend fun TelegramBot.getChat(
2020-06-02 07:54:30 +00:00
chat: PrivateChatImpl
) = getChat(chat.id) as ExtendedPrivateChatImpl
/**
2020-10-04 11:06:30 +00:00
* Will cast incoming [dev.inmo.tgbotapi.types.chat.abstracts.extended.ExtendedChat] to a
2020-06-02 07:54:30 +00:00
* [ExtendedUser] with unsafe operator "as"
*
* @throws ClassCastException
*/
@PreviewFeature
suspend fun TelegramBot.getChat(
2020-06-02 07:54:30 +00:00
chat: CommonUser
) = getChat(chat.id) as ExtendedUser