Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Loading