mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-08-18 15:19:09 +00:00
Add Bot API 10.2 Communities support
New communities domain: Community + CommunityId, CommunityChatAdded and CommunityChatRemoved service messages (CommonEvent) wired through RawMessage, ChatFullInfo/ExtendedChat.community (including ExtendedBot), plus onCommunityChatAdded/onCommunityChatRemoved triggers and wait expectations. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -946,4 +946,6 @@ const val temperatureField = "temperature"
|
||||
const val backgroundColorField = "background_color"
|
||||
const val keepOriginalDetailsField = "keep_original_details"
|
||||
|
||||
const val communityField = "community"
|
||||
|
||||
const val codecField = "codec"
|
||||
|
||||
@@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessIntro
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessLocation
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessOpeningHours
|
||||
import dev.inmo.tgbotapi.types.colors.ColorId
|
||||
import dev.inmo.tgbotapi.types.communities.Community
|
||||
import dev.inmo.tgbotapi.types.files.AudioFile
|
||||
import dev.inmo.tgbotapi.types.gifts.AcceptedGiftTypes
|
||||
import dev.inmo.tgbotapi.types.gifts.unique.UniqueGiftColors
|
||||
@@ -71,7 +72,9 @@ data class ExtendedChannelChatImpl(
|
||||
@SerialName(uniqueGiftColorsField)
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null,
|
||||
@SerialName(guardBotField)
|
||||
override val guardBot: User? = null
|
||||
override val guardBot: User? = null,
|
||||
@SerialName(communityField)
|
||||
override val community: Community? = null
|
||||
) : ExtendedChannelChat
|
||||
|
||||
@Serializable
|
||||
@@ -120,7 +123,9 @@ data class ExtendedGroupChatImpl(
|
||||
@SerialName(uniqueGiftColorsField)
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null,
|
||||
@SerialName(guardBotField)
|
||||
override val guardBot: User? = null
|
||||
override val guardBot: User? = null,
|
||||
@SerialName(communityField)
|
||||
override val community: Community? = null
|
||||
) : ExtendedGroupChat
|
||||
|
||||
@Serializable
|
||||
@@ -322,7 +327,9 @@ data class ExtendedSupergroupChatImpl(
|
||||
@SerialName(uniqueGiftColorsField)
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null,
|
||||
@SerialName(guardBotField)
|
||||
override val guardBot: User? = null
|
||||
override val guardBot: User? = null,
|
||||
@SerialName(communityField)
|
||||
override val community: Community? = null
|
||||
) : ExtendedSupergroupChat
|
||||
|
||||
@Serializable
|
||||
@@ -398,7 +405,9 @@ data class ExtendedForumChatImpl(
|
||||
@SerialName(uniqueGiftColorsField)
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null,
|
||||
@SerialName(guardBotField)
|
||||
override val guardBot: User? = null
|
||||
override val guardBot: User? = null,
|
||||
@SerialName(communityField)
|
||||
override val community: Community? = null
|
||||
) : ExtendedForumChat
|
||||
|
||||
@Serializable
|
||||
@@ -477,7 +486,9 @@ data class ExtendedChannelDirectMessagesChatImpl(
|
||||
@SerialName(uniqueGiftColorsField)
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null,
|
||||
@SerialName(guardBotField)
|
||||
override val guardBot: User? = null
|
||||
override val guardBot: User? = null,
|
||||
@SerialName(communityField)
|
||||
override val community: Community? = null
|
||||
) : ExtendedChannelDirectMessagesChat {
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
@SerialName(isDirectMessagesField)
|
||||
@@ -533,6 +544,8 @@ data class ExtendedBot(
|
||||
override val uniqueGiftColors: UniqueGiftColors? = null,
|
||||
@SerialName(canManageBotsField)
|
||||
val canManageBots: Boolean = false,
|
||||
@SerialName(communityField)
|
||||
override val community: Community? = null,
|
||||
) : Bot(), ExtendedChat {
|
||||
@SerialName(isBotField)
|
||||
private val isBot = true
|
||||
|
||||
@@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessIntro
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessLocation
|
||||
import dev.inmo.tgbotapi.types.business_connection.BusinessOpeningHours
|
||||
import dev.inmo.tgbotapi.types.colors.ColorId
|
||||
import dev.inmo.tgbotapi.types.communities.Community
|
||||
import dev.inmo.tgbotapi.types.files.AudioFile
|
||||
import dev.inmo.tgbotapi.types.gifts.AcceptedGiftTypes
|
||||
import dev.inmo.tgbotapi.types.gifts.unique.UniqueGiftColors
|
||||
@@ -35,6 +36,14 @@ sealed interface ExtendedChat : Chat {
|
||||
val guardBot: User?
|
||||
get() = null
|
||||
|
||||
/**
|
||||
* The Community to which the chat belongs
|
||||
*
|
||||
* @see <a href="https://core.telegram.org/bots/api#chatfullinfo">ChatFullInfo.community</a>
|
||||
*/
|
||||
val community: Community?
|
||||
get() = null
|
||||
|
||||
@Deprecated(
|
||||
message = "Telegram Bot API v9.0 introduced the new field, `acceptedGiftTypes`, to allow granular" +
|
||||
" control over which types of gifts user, bot, or chat can accept.",
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package dev.inmo.tgbotapi.types.communities
|
||||
|
||||
import dev.inmo.tgbotapi.types.idField
|
||||
import dev.inmo.tgbotapi.types.nameField
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Represents a community (a group of chats)
|
||||
*/
|
||||
@Serializable
|
||||
data class Community(
|
||||
@SerialName(idField)
|
||||
val id: CommunityId,
|
||||
@SerialName(nameField)
|
||||
val name: String
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.inmo.tgbotapi.types.communities
|
||||
|
||||
import dev.inmo.tgbotapi.types.communityField
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Service message about a chat being added to a community
|
||||
*/
|
||||
@Serializable
|
||||
data class CommunityChatAdded(
|
||||
@SerialName(communityField)
|
||||
val community: Community
|
||||
) : CommonEvent
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.inmo.tgbotapi.types.communities
|
||||
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* Service message about a chat being removed from a community. Currently holds no information
|
||||
*/
|
||||
@Serializable
|
||||
object CommunityChatRemoved : CommonEvent
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.tgbotapi.types.communities
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.jvm.JvmInline
|
||||
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class CommunityId(
|
||||
val long: Long
|
||||
) {
|
||||
override fun toString(): String {
|
||||
return long.toString()
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import dev.inmo.tgbotapi.types.checklists.Checklist
|
||||
import dev.inmo.tgbotapi.types.checklists.ChecklistTaskId
|
||||
import dev.inmo.tgbotapi.types.checklists.ChecklistTasksAdded
|
||||
import dev.inmo.tgbotapi.types.checklists.ChecklistTasksDone
|
||||
import dev.inmo.tgbotapi.types.communities.CommunityChatAdded
|
||||
import dev.inmo.tgbotapi.types.communities.CommunityChatRemoved
|
||||
import dev.inmo.tgbotapi.types.dice.Dice
|
||||
import dev.inmo.tgbotapi.types.files.*
|
||||
import dev.inmo.tgbotapi.types.files.Sticker
|
||||
@@ -206,6 +208,10 @@ internal data class RawMessage(
|
||||
private val checklist_tasks_done: ChecklistTasksDone? = null,
|
||||
private val checklist_tasks_added: ChecklistTasksAdded? = null,
|
||||
|
||||
// Communities
|
||||
private val community_chat_added: CommunityChatAdded? = null,
|
||||
private val community_chat_removed: CommunityChatRemoved? = null,
|
||||
|
||||
// Channel direct messages
|
||||
private val direct_message_price_changed: DirectMessagesConfigurationChanged? = null,
|
||||
private val is_paid_post: Boolean = false,
|
||||
@@ -371,6 +377,8 @@ internal data class RawMessage(
|
||||
gift_upgrade_sent != null -> gift_upgrade_sent
|
||||
checklist_tasks_done != null -> checklist_tasks_done
|
||||
checklist_tasks_added != null -> checklist_tasks_added
|
||||
community_chat_added != null -> community_chat_added
|
||||
community_chat_removed != null -> community_chat_removed
|
||||
direct_message_price_changed != null -> direct_message_price_changed
|
||||
suggested_post_approved != null -> suggested_post_approved
|
||||
suggested_post_approval_failed != null -> suggested_post_approval_failed
|
||||
|
||||
Reference in New Issue
Block a user