From 96eaf44f9626b40a2e9c846b46c92be74923433d Mon Sep 17 00:00:00 2001 From: "nenka.lab" Date: Wed, 4 Nov 2026 13:49:02 +0900 Subject: [PATCH] feat: add isInjected and injectedBy to the standard message --- .../com/xfl/msgbot/plugin/api/standard/StandardApi.kt | 2 ++ .../kotlin/com/xfl/msgbot/plugin/api/schema/TypeTest.kt | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/contract/src/main/kotlin/com/xfl/msgbot/plugin/api/standard/StandardApi.kt b/contract/src/main/kotlin/com/xfl/msgbot/plugin/api/standard/StandardApi.kt index 0fb0362..1daf8f8 100644 --- a/contract/src/main/kotlin/com/xfl/msgbot/plugin/api/standard/StandardApi.kt +++ b/contract/src/main/kotlin/com/xfl/msgbot/plugin/api/standard/StandardApi.kt @@ -163,6 +163,8 @@ object StandardApi { optional("isMention", Type.BOOL) optional("isMultiChat", Type.BOOL) optional("isDebugRoom", Type.BOOL, doc = "Set by the host for the debug room; providers leave it out") + optional("isInjected", Type.BOOL, doc = "Set by the host when a sandbox handed this message over instead of a messenger; providers leave it out") + optional("injectedBy", Type.STRING, doc = "The name of the sandbox that handed this message over; set by the host together with isInjected") optional("image", Type.handle("image"), doc = "An image token") optional("replyToken", Type.handle("reply"), doc = "Absent when this message cannot be answered by token") optional("readToken", Type.handle("read")) diff --git a/contract/src/test/kotlin/com/xfl/msgbot/plugin/api/schema/TypeTest.kt b/contract/src/test/kotlin/com/xfl/msgbot/plugin/api/schema/TypeTest.kt index bb335d8..4d41b5b 100644 --- a/contract/src/test/kotlin/com/xfl/msgbot/plugin/api/schema/TypeTest.kt +++ b/contract/src/test/kotlin/com/xfl/msgbot/plugin/api/schema/TypeTest.kt @@ -164,4 +164,12 @@ class TypeConstraintTest { assertEquals(Type.handle("image").nullable(), message.getValue("image").type) assertEquals(Type.handle("reply").nullable(), StandardApi.Bot.function("reply")!!.params.first { it.name == "token" }.type) } + + @Test + fun `the standard message has optional host-set fields for injected messages`() { + val message = StandardApi.Bot.event("message")!!.fields.associateBy { it.name } + assertEquals(Type.BOOL.nullable(), message.getValue("isInjected").type) + assertEquals(Type.STRING.nullable(), message.getValue("injectedBy").type) + assertTrue(message.getValue("isInjected").optional && message.getValue("injectedBy").optional) + } }