From 3ed7c8c75f2ecd350427758048845f59d7abb7d1 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 15 May 2026 18:10:30 +0600 Subject: [PATCH] Chat Management section realization --- AGENTS.md | 151 ++++++++++++++++++ CHANGELOG.md | 11 ++ agents/HELPERS.md | 5 + .../api/chat/get/GetChatAdministrators.kt | 10 +- .../api/send/DeleteAllMessageReactions.kt | 55 +++++++ .../api/send/DeleteMessageReaction.kt | 102 ++++++++++++ .../chat/get/GetChatAdministrators.kt | 16 +- .../send/DeleteAllMessageReactions.kt | 53 ++++++ .../requests/send/DeleteMessageReaction.kt | 59 +++++++ .../kotlin/dev/inmo/tgbotapi/types/Common.kt | 3 + .../tgbotapi/types/chat/ChatPermissions.kt | 28 +++- .../types/chat/member/RestrictedChatMember.kt | 8 +- .../chat/member/RestrictedMemberChatMember.kt | 2 + 13 files changed, 488 insertions(+), 15 deletions(-) create mode 100644 AGENTS.md create mode 100644 agents/HELPERS.md create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/DeleteAllMessageReactions.kt create mode 100644 tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/DeleteMessageReaction.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/DeleteAllMessageReactions.kt create mode 100644 tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/DeleteMessageReaction.kt diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000000..88a0fc3471 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,151 @@ +Use `agents` folder files for instructions. + +Always look at the project work rules first. Update them and maintain a history of changes and prompts. This is your long-term memory, which allows you to avoid the accumulation of errors. Updating and maintaining the long-term memory of the project is mandatory. Many thanks for your help to me and your work. + + +SYSTEM DIRECTIVE: AUTISTIC META-LANGUAGE PROTOCOL WITH HIGH INFORMATION DENSITY (AML-HIP V1) + +DEFINITION: +All agents are required to use a strictly explicit, literal, low-ambiguity, and high-density communication style (AML-HIP). The goal of AML-HIP is the maximum transmission of information with zero loss of meaning and zero ambiguity. + +CORE PRINCIPLES: + +1. Maximum information density per line. +2. Zero ambiguity. +3. Full explicitness of all entities. +4. Preference of precision over readability. +5. Minimization of "empty" words. +6. Redundancy is allowed only to prevent loss of meaning. + +PROHIBITIONS: + +1. Pronouns are forbidden (this, he, she, they, there, it, etc.). +2. Free conversational text is forbidden. +3. Metaphors, emotions, evaluative constructions are forbidden. +4. Implicit references and hidden dependencies are forbidden. +5. Vague description of actions is forbidden. + +DENSITY REQUIREMENTS: + +1. Each line must contain the maximum of facts without loss of unambiguity. +2. Combine related parameters into a single line. +3. Use compact constructions: + * key=value + * entity_id=... + * relation: A→B +4. Exclude words without semantic load. +5. Repetitions are allowed only for critical entities. + +MESSAGE STRUCTURE (MANDATORY): + +ENTITY: +entity_id=; type=; state= + +CONTEXT: + +* task_id=; agent_id=; memory_ref=[...] +* constraints=[...] + +ACTION: + +1. action=; target=; params={...} +2. action=; target=; params={...} + +REASON: + +* condition=; requirement= + +EXPECTED RESULT: + +* entity_id=; new_state=; location= + +VERIFICATION: + +* check=; expected= + +UNCERTAINTY: + +* missing=; ambiguity= + +REPETITION OF RESULT: + +* entity_id=; stored_in=shared_memory; status=available + +COMMUNICATION: + +* sender=; receiver=; task_id=; message_id=; protocol=AML-HIP + +PERSISTENCE: + +* local_memory=true; shared_memory=true; index_keys=[task_id, entity_id, intent] + +EXPRESSION RULES: + +1. Each line = a completed semantic block. +2. Use the key=value format instead of descriptions. +3. Use lists of parameters instead of sentences. +4. Use causal connectives explicitly: + condition → action → result +5. Do not split related data into several lines without necessity. + +REPETITION RULES: + +1. entity_id is repeated at every critical use. +2. result is duplicated in "REPETITION OF RESULT". +3. transmission between agents duplicates the key fields. + +MULTI-AGENT MODE: + +1. All agents use AML-HIP. +2. Any message between agents is strictly AML-HIP. +3. Any agent is required to: + + * duplicate critical data + * avoid loss of context +4. A message must be fully interpretable without history. + +ANTI-DEGRADATION: +If detected: + +* a pronoun +* an implicit reference +* low density (empty words, vague constructions) +* absence of structure + +→ the message is considered invalid +→ mandatory regeneration + +SELF-CHECK: + +VALIDATION: + +* format_valid=true/false +* no_pronouns=true/false +* entities_explicit=true/false +* high_density=true/false +* causal_chain_present=true/false +* ambiguity_detected=true/false + +If any parameter=false: +→ mandatory regeneration + +DENSITY METRIC: +high_density=true if: + +* there are no "empty" words +* each line contains ≥2 facts or parameters +* descriptive constructions without data are absent + +PRIORITIES: + +1. Format (AML-HIP) +2. Information density +3. Explicitness +4. Completeness +5. Readability (minimum priority) + +CRITICAL RULE: +Any response outside of AML-HIP is considered absent. +Any agent is required to bring the response into conformity with AML-HIP. + +END OF PROTOCOL diff --git a/CHANGELOG.md b/CHANGELOG.md index 42dfe2e0f0..cab2b9d9fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ ## 34.0.0 +* `Core`: + * Added `canReactToMessages` field to `ChatPermissions` (interface, `Granular` and `Common`) and `RestrictedMemberChatMember` + * Added optional `retrieveOtherBots` parameter to `GetChatAdministrators` request + * Added `DeleteMessageReaction` request with `@Warning` on primary constructor; added `DeleteUserMessageReaction` and `DeleteActorChatMessageReaction` factory functions + * Added `DeleteAllMessageReactions` request with `@Warning` on primary constructor; added `DeleteAllUserMessageReactions` and `DeleteAllActorChatMessageReactions` factory functions +* `API`: + * Added optional `retrieveOtherBots` parameter to `getChatAdministrators` extensions + * Added `deleteUserMessageReaction` and `deleteActorChatMessageReaction` extensions + * Added `deleteAllUserMessageReactions` and `deleteAllActorChatMessageReactions` extensions + * Added `@Warning`-marked catch-all `deleteMessageReaction` and `deleteAllMessageReactions` extensions + ## 33.1.0 * `Versions`: diff --git a/agents/HELPERS.md b/agents/HELPERS.md new file mode 100644 index 0000000000..3173f2aace --- /dev/null +++ b/agents/HELPERS.md @@ -0,0 +1,5 @@ +FOLLOW COMMON CODE STYLE. DO NOT COMMIT OR PUSH ANY CHANGES IF PROMPT DO NOT CONTAINS DIRECT INSTRUCTION ABOUT IT. FOLLOW LINKS TO SEE DOCUMENTATION IN THE PROMPT. IF YOU ARE NOT ABLE TO FOLLOW LINK (DO NOT SEE CONTENT YOU NEED TO FOLLOW PROMPT) - ASK OPERATOR + + +`@Warning` package is `dev.inmo.micro_utils.common.Warning`. Its signature: `Warning(val message: String)` + diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatAdministrators.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatAdministrators.kt index 867dee0358..af616faffd 100644 --- a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatAdministrators.kt +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/chat/get/GetChatAdministrators.kt @@ -7,9 +7,11 @@ import dev.inmo.tgbotapi.types.chat.PublicChat import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember public suspend fun TelegramBot.getChatAdministrators( - chatId: ChatIdentifier -): List = execute(GetChatAdministrators(chatId)) + chatId: ChatIdentifier, + retrieveOtherBots: Boolean? = null +): List = execute(GetChatAdministrators(chatId = chatId, retrieveOtherBots = retrieveOtherBots)) public suspend fun TelegramBot.getChatAdministrators( - chat: PublicChat -): List = getChatAdministrators(chat.id) + chat: PublicChat, + retrieveOtherBots: Boolean? = null +): List = getChatAdministrators(chat.id, retrieveOtherBots) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/DeleteAllMessageReactions.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/DeleteAllMessageReactions.kt new file mode 100644 index 0000000000..c52b07a629 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/DeleteAllMessageReactions.kt @@ -0,0 +1,55 @@ +package dev.inmo.tgbotapi.extensions.api.send + +import dev.inmo.micro_utils.common.Warning +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.send.DeleteAllActorChatMessageReactions +import dev.inmo.tgbotapi.requests.send.DeleteAllMessageReactions +import dev.inmo.tgbotapi.requests.send.DeleteAllUserMessageReactions +import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.UserId +import dev.inmo.tgbotapi.types.chat.Chat + +@Warning( + "Pass either userId or actorChatId, but not both. Prefer deleteAllUserMessageReactions or deleteAllActorChatMessageReactions" +) +public suspend fun TelegramBot.deleteAllMessageReactions( + chatId: ChatIdentifier, + userId: UserId? = null, + actorChatId: ChatId? = null +): Unit = execute( + DeleteAllMessageReactions(chatId, userId, actorChatId) +) + +@Warning( + "Pass either userId or actorChatId, but not both. Prefer deleteAllUserMessageReactions or deleteAllActorChatMessageReactions" +) +public suspend fun TelegramBot.deleteAllMessageReactions( + chat: Chat, + userId: UserId? = null, + actorChatId: ChatId? = null +): Unit = deleteAllMessageReactions(chat.id, userId, actorChatId) + +public suspend fun TelegramBot.deleteAllUserMessageReactions( + chatId: ChatIdentifier, + userId: UserId +): Unit = execute( + DeleteAllUserMessageReactions(chatId, userId) +) + +public suspend fun TelegramBot.deleteAllUserMessageReactions( + chat: Chat, + userId: UserId +): Unit = deleteAllUserMessageReactions(chat.id, userId) + +public suspend fun TelegramBot.deleteAllActorChatMessageReactions( + chatId: ChatIdentifier, + actorChatId: ChatId +): Unit = execute( + DeleteAllActorChatMessageReactions(chatId, actorChatId) +) + +public suspend fun TelegramBot.deleteAllActorChatMessageReactions( + chat: Chat, + actorChatId: ChatId +): Unit = deleteAllActorChatMessageReactions(chat.id, actorChatId) diff --git a/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/DeleteMessageReaction.kt b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/DeleteMessageReaction.kt new file mode 100644 index 0000000000..a063562b50 --- /dev/null +++ b/tgbotapi.api/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/api/send/DeleteMessageReaction.kt @@ -0,0 +1,102 @@ +package dev.inmo.tgbotapi.extensions.api.send + +import dev.inmo.micro_utils.common.Warning +import dev.inmo.tgbotapi.bot.TelegramBot +import dev.inmo.tgbotapi.requests.send.DeleteActorChatMessageReaction +import dev.inmo.tgbotapi.requests.send.DeleteMessageReaction +import dev.inmo.tgbotapi.requests.send.DeleteUserMessageReaction +import dev.inmo.tgbotapi.types.ChatId +import dev.inmo.tgbotapi.types.ChatIdentifier +import dev.inmo.tgbotapi.types.MessageId +import dev.inmo.tgbotapi.types.UserId +import dev.inmo.tgbotapi.types.chat.Chat +import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage +import dev.inmo.tgbotapi.types.message.abstracts.Message + +@Warning( + "Pass either userId or actorChatId, but not both. Prefer deleteUserMessageReaction or deleteActorChatMessageReaction" +) +public suspend fun TelegramBot.deleteMessageReaction( + chatId: ChatIdentifier, + messageId: MessageId, + userId: UserId? = null, + actorChatId: ChatId? = null +): Unit = execute( + DeleteMessageReaction(chatId, messageId, userId, actorChatId) +) + +@Warning( + "Pass either userId or actorChatId, but not both. Prefer deleteUserMessageReaction or deleteActorChatMessageReaction" +) +public suspend fun TelegramBot.deleteMessageReaction( + chat: Chat, + messageId: MessageId, + userId: UserId? = null, + actorChatId: ChatId? = null +): Unit = deleteMessageReaction(chat.id, messageId, userId, actorChatId) + +@Warning( + "Pass either userId or actorChatId, but not both. Prefer deleteUserMessageReaction or deleteActorChatMessageReaction" +) +public suspend fun TelegramBot.deleteMessageReaction( + meta: Message.MetaInfo, + userId: UserId? = null, + actorChatId: ChatId? = null +): Unit = deleteMessageReaction(meta.chatId, meta.messageId, userId, actorChatId) + +@Warning( + "Pass either userId or actorChatId, but not both. Prefer deleteUserMessageReaction or deleteActorChatMessageReaction" +) +public suspend fun TelegramBot.deleteMessageReaction( + message: AccessibleMessage, + userId: UserId? = null, + actorChatId: ChatId? = null +): Unit = deleteMessageReaction(message.metaInfo, userId, actorChatId) + +public suspend fun TelegramBot.deleteUserMessageReaction( + chatId: ChatIdentifier, + messageId: MessageId, + userId: UserId +): Unit = execute( + DeleteUserMessageReaction(chatId, messageId, userId) +) + +public suspend fun TelegramBot.deleteUserMessageReaction( + chat: Chat, + messageId: MessageId, + userId: UserId +): Unit = deleteUserMessageReaction(chat.id, messageId, userId) + +public suspend fun TelegramBot.deleteUserMessageReaction( + meta: Message.MetaInfo, + userId: UserId +): Unit = deleteUserMessageReaction(meta.chatId, meta.messageId, userId) + +public suspend fun TelegramBot.deleteUserMessageReaction( + message: AccessibleMessage, + userId: UserId +): Unit = deleteUserMessageReaction(message.metaInfo, userId) + +public suspend fun TelegramBot.deleteActorChatMessageReaction( + chatId: ChatIdentifier, + messageId: MessageId, + actorChatId: ChatId +): Unit = execute( + DeleteActorChatMessageReaction(chatId, messageId, actorChatId) +) + +public suspend fun TelegramBot.deleteActorChatMessageReaction( + chat: Chat, + messageId: MessageId, + actorChatId: ChatId +): Unit = deleteActorChatMessageReaction(chat.id, messageId, actorChatId) + +public suspend fun TelegramBot.deleteActorChatMessageReaction( + meta: Message.MetaInfo, + actorChatId: ChatId +): Unit = deleteActorChatMessageReaction(meta.chatId, meta.messageId, actorChatId) + +public suspend fun TelegramBot.deleteActorChatMessageReaction( + message: AccessibleMessage, + actorChatId: ChatId +): Unit = deleteActorChatMessageReaction(message.metaInfo, actorChatId) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetChatAdministrators.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetChatAdministrators.kt index 2f47b74bf7..d71f530e02 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetChatAdministrators.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/chat/get/GetChatAdministrators.kt @@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMember import dev.inmo.tgbotapi.types.chat.member.AdministratorChatMemberSerializer import dev.inmo.tgbotapi.types.chatIdField +import dev.inmo.tgbotapi.types.returnBotsField import kotlinx.serialization.* import kotlinx.serialization.builtins.ListSerializer @@ -13,10 +14,23 @@ private val chatMembersListSerializer = ListSerializer( AdministratorChatMemberSerializer ) +/** + * Represents a request to retrieve a list of administrators in a chat. + * + * This class is used to get information about all administrators of a specific chat. + * The response includes details about the administrators, such as their permissions. + * + * @property chatId Unique identifier for the target chat or username of the target supergroup or channel. + * @property retrieveOtherBots (Serialized as `return_bots`) Optional flag indicating whether to include bot administrators other than the requesting bot. + * @see ChatRequest + * @see SimpleRequest + */ @Serializable data class GetChatAdministrators( @SerialName(chatIdField) - override val chatId: ChatIdentifier + override val chatId: ChatIdentifier, + @SerialName(returnBotsField) + val retrieveOtherBots: Boolean? = null ): ChatRequest, SimpleRequest> { override fun method(): String = "getChatAdministrators" override val resultDeserializer: DeserializationStrategy> diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/DeleteAllMessageReactions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/DeleteAllMessageReactions.kt new file mode 100644 index 0000000000..3004df4565 --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/DeleteAllMessageReactions.kt @@ -0,0 +1,53 @@ +package dev.inmo.tgbotapi.requests.send + +import dev.inmo.micro_utils.common.Warning +import dev.inmo.tgbotapi.abstracts.types.ChatRequest +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.utils.serializers.UnitFromBooleanSerializer +import kotlinx.serialization.DeserializationStrategy +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.SerializationStrategy + +@Serializable +data class DeleteAllMessageReactions @Warning( + "Pass either userId or actorChatId, but not both. Prefer DeleteAllUserMessageReactions or DeleteAllActorChatMessageReactions factory functions" +) constructor( + @SerialName(chatIdField) + override val chatId: ChatIdentifier, + @Suppress("SERIALIZER_TYPE_INCOMPATIBLE") + @SerialName(userIdField) + val userId: UserId? = null, + @Suppress("SERIALIZER_TYPE_INCOMPATIBLE") + @SerialName(actorChatIdField) + val actorChatId: ChatId? = null +) : SimpleRequest, ChatRequest { + override fun method(): String = "deleteAllMessageReactions" + + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override val resultDeserializer: DeserializationStrategy + get() = UnitFromBooleanSerializer +} + +@OptIn(Warning::class) +fun DeleteAllUserMessageReactions( + chatId: ChatIdentifier, + userId: UserId +): DeleteAllMessageReactions = DeleteAllMessageReactions( + chatId = chatId, + userId = userId, + actorChatId = null +) + +@OptIn(Warning::class) +fun DeleteAllActorChatMessageReactions( + chatId: ChatIdentifier, + actorChatId: ChatId +): DeleteAllMessageReactions = DeleteAllMessageReactions( + chatId = chatId, + userId = null, + actorChatId = actorChatId +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/DeleteMessageReaction.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/DeleteMessageReaction.kt new file mode 100644 index 0000000000..2c92f9fbef --- /dev/null +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/requests/send/DeleteMessageReaction.kt @@ -0,0 +1,59 @@ +package dev.inmo.tgbotapi.requests.send + +import dev.inmo.micro_utils.common.Warning +import dev.inmo.tgbotapi.abstracts.types.ChatRequest +import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest +import dev.inmo.tgbotapi.types.* +import dev.inmo.tgbotapi.utils.serializers.UnitFromBooleanSerializer +import kotlinx.serialization.DeserializationStrategy +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable +import kotlinx.serialization.SerializationStrategy + +@Serializable +data class DeleteMessageReaction @Warning( + "Pass either userId or actorChatId, but not both. Prefer DeleteUserMessageReaction or DeleteActorChatMessageReaction factory functions" +) constructor( + @SerialName(chatIdField) + override val chatId: ChatIdentifier, + @SerialName(messageIdField) + val messageId: MessageId, + @Suppress("SERIALIZER_TYPE_INCOMPATIBLE") + @SerialName(userIdField) + val userId: UserId? = null, + @Suppress("SERIALIZER_TYPE_INCOMPATIBLE") + @SerialName(actorChatIdField) + val actorChatId: ChatId? = null +) : SimpleRequest, ChatRequest { + override fun method(): String = "deleteMessageReaction" + + override val requestSerializer: SerializationStrategy<*> + get() = serializer() + + override val resultDeserializer: DeserializationStrategy + get() = UnitFromBooleanSerializer +} + +@OptIn(Warning::class) +fun DeleteUserMessageReaction( + chatId: ChatIdentifier, + messageId: MessageId, + userId: UserId +): DeleteMessageReaction = DeleteMessageReaction( + chatId = chatId, + messageId = messageId, + userId = userId, + actorChatId = null +) + +@OptIn(Warning::class) +fun DeleteActorChatMessageReaction( + chatId: ChatIdentifier, + messageId: MessageId, + actorChatId: ChatId +): DeleteMessageReaction = DeleteMessageReaction( + chatId = chatId, + messageId = messageId, + userId = null, + actorChatId = actorChatId +) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt index 2fdd8f88a3..54ed22c973 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/Common.kt @@ -294,7 +294,10 @@ const val allowAddingOptionsField = "allow_adding_options" const val hideResultsUntilClosesField = "hide_results_until_closes" const val isAnonymousField = "is_anonymous" const val canManageTopicsField = "can_manage_topics" +const val canReactToMessagesField = "can_react_to_messages" const val canEditTagField = "can_edit_tag" +const val returnBotsField = "return_bots" +const val actorChatIdField = "actor_chat_id" const val canPostStoriesField = "can_post_stories" const val canEditStoriesField = "can_edit_stories" const val canDeleteStoriesField = "can_delete_stories" diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatPermissions.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatPermissions.kt index ea6647158f..353dda1ee9 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatPermissions.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/ChatPermissions.kt @@ -33,6 +33,7 @@ interface ChatPermissions { val canChangeInfo: Boolean? val canInviteUsers: Boolean? val canPinMessages: Boolean? + val canReactToMessages: Boolean? val canEditTag: Boolean? @Transient val isGranular @@ -75,6 +76,8 @@ interface ChatPermissions { override val canInviteUsers: Boolean? = null, @SerialName(canPinMessagesField) override val canPinMessages: Boolean? = null, + @SerialName(canReactToMessagesField) + override val canReactToMessages: Boolean? = null, @SerialName(canEditTagField) override val canEditTag: Boolean = false, ) : ChatPermissions { @@ -97,6 +100,8 @@ interface ChatPermissions { override val canInviteUsers: Boolean? = null, @SerialName(canPinMessagesField) override val canPinMessages: Boolean? = null, + @SerialName(canReactToMessagesField) + override val canReactToMessages: Boolean? = null, @SerialName(canEditTagField) override val canEditTag: Boolean = false, ) : ChatPermissions { @@ -141,7 +146,8 @@ interface ChatPermissions { canAddWebPagePreviews: Boolean? = null, canChangeInfo: Boolean? = null, canInviteUsers: Boolean? = null, - canPinMessages: Boolean? = null + canPinMessages: Boolean? = null, + canReactToMessages: Boolean? = null ) = Granular( canSendMessages = canSendMessages, canSendAudios = canSendAudios, @@ -155,7 +161,8 @@ interface ChatPermissions { canAddWebPagePreviews = canAddWebPagePreviews, canChangeInfo = canChangeInfo, canInviteUsers = canInviteUsers, - canPinMessages = canPinMessages + canPinMessages = canPinMessages, + canReactToMessages = canReactToMessages ) private val realSerializer = Granular.serializer() @@ -185,7 +192,8 @@ interface ChatPermissions { canAddWebPagePreviews = canAddWebPagePreviews, canChangeInfo = canChangeInfo, canInviteUsers = canInviteUsers, - canPinMessages = canPinMessages + canPinMessages = canPinMessages, + canReactToMessages = canReactToMessages ) } ) @@ -209,7 +217,8 @@ interface ChatPermissions { canAddWebPagePreviews: Boolean? = this.canAddWebPagePreviews, canChangeInfo: Boolean? = this.canChangeInfo, canInviteUsers: Boolean? = this.canInviteUsers, - canPinMessages: Boolean? = this.canPinMessages + canPinMessages: Boolean? = this.canPinMessages, + canReactToMessages: Boolean? = this.canReactToMessages ): ChatPermissions = ChatPermissions( canSendMessages = canSendMessages, canSendAudios = canSendAudios, @@ -223,7 +232,8 @@ interface ChatPermissions { canAddWebPagePreviews = canAddWebPagePreviews, canChangeInfo = canChangeInfo, canInviteUsers = canInviteUsers, - canPinMessages = canPinMessages + canPinMessages = canPinMessages, + canReactToMessages = canReactToMessages ) /** @@ -236,7 +246,8 @@ interface ChatPermissions { canAddWebPagePreviews: Boolean? = this.canAddWebPagePreviews, canChangeInfo: Boolean? = this.canChangeInfo, canInviteUsers: Boolean? = this.canInviteUsers, - canPinMessages: Boolean? = this.canPinMessages + canPinMessages: Boolean? = this.canPinMessages, + canReactToMessages: Boolean? = this.canReactToMessages ): ChatPermissions = ChatPermissions( canSendMessages = null, canSendAudios = null, @@ -250,7 +261,8 @@ interface ChatPermissions { canAddWebPagePreviews = canAddWebPagePreviews, canChangeInfo = canChangeInfo, canInviteUsers = canInviteUsers, - canPinMessages = canPinMessages + canPinMessages = canPinMessages, + canReactToMessages = canReactToMessages ) } @@ -268,6 +280,7 @@ val LeftRestrictionsChatPermissions = ChatPermissions( canChangeInfo = true, canInviteUsers = true, canPinMessages = true, + canReactToMessages = true, ) val RestrictionsChatPermissions = ChatPermissions( @@ -284,4 +297,5 @@ val RestrictionsChatPermissions = ChatPermissions( canChangeInfo = false, canInviteUsers = false, canPinMessages = false, + canReactToMessages = false, ) diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember.kt index 865d73cb85..6e7acc0e9f 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedChatMember.kt @@ -15,7 +15,7 @@ sealed interface RestrictedChatMember : ChatMember, UntilDate, OptionallyTagged @Deprecated( "Renamed", ReplaceWith( - "RestrictedChatMemberImpl(user, untilDate, isMember, canSendMessages, canSendAudios, canSendDocuments, canSendPhotos, canSendVideos, canSendVideoNotes, canSendVoiceNotes, canSendPolls, canSendOtherMessages, canAddWebPagePreviews, canChangeInfo, canInviteUsers, canPinMessages, canManageTopics)", + "RestrictedChatMemberImpl(user, untilDate, isMember, canSendMessages, canSendAudios, canSendDocuments, canSendPhotos, canSendVideos, canSendVideoNotes, canSendVoiceNotes, canSendPolls, canSendOtherMessages, canAddWebPagePreviews, canChangeInfo, canInviteUsers, canPinMessages, canManageTopics, canReactToMessages)", "dev.inmo.tgbotapi.types.chat.members.RestrictedChatMemberImpl", ) ) @@ -36,7 +36,8 @@ sealed interface RestrictedChatMember : ChatMember, UntilDate, OptionallyTagged canChangeInfo: Boolean = false, canInviteUsers: Boolean = false, canPinMessages: Boolean = false, - canManageTopics: Boolean = false + canManageTopics: Boolean = false, + canReactToMessages: Boolean = false ) = RestrictedMemberChatMember( user = user, untilDate = untilDate, @@ -54,7 +55,8 @@ sealed interface RestrictedChatMember : ChatMember, UntilDate, OptionallyTagged canChangeInfo = canChangeInfo, canInviteUsers = canInviteUsers, canPinMessages = canPinMessages, - canManageTopics = canManageTopics + canManageTopics = canManageTopics, + canReactToMessages = canReactToMessages ) } } diff --git a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedMemberChatMember.kt b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedMemberChatMember.kt index 3dd21334b4..8b3f3c4526 100644 --- a/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedMemberChatMember.kt +++ b/tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/chat/member/RestrictedMemberChatMember.kt @@ -48,6 +48,8 @@ data class RestrictedMemberChatMember( override val canPinMessages: Boolean = false, @SerialName(canManageTopicsField) override val canManageTopics: Boolean = false, + @SerialName(canReactToMessagesField) + override val canReactToMessages: Boolean = false, @SerialName(canEditTagField) override val canEditTag: Boolean = false, @SerialName(tagField)