Skip to content

Nested calls not working, result not interpreted #54

Description

@jbruchanov
val script = """
            + simple1
            - <call>test "<bot VAR1>"</call>

            + complex
            - {@ something <call>test "<bot VAR1>"</call>}

            + interpret
            - {@ build <call>test interpret</call>}

            + setvar *
            - <bot VAR1=<star>>Var updated

            + getvar
            - Var1 is '<bot VAR1>'

            + something *
            - SomethingRef=<star>

            + build *
            - <bot VAR1=<star>>

            > object test javascript
            return "Test:" + args[0]
            < object

            > object interpret javascript
            return "<bot VAR1=interpret>"
            < object
            """.trimIndent()

        val user = "user"
        val re = RiveScript(Config.newBuilder()
                .strict(true)
                .utf8(true)
                .build()).apply {
            stream(script)
            sortReplies()
            setSubroutine("test", { re, args -> "Test:" + args[0] })
            setSubroutine("interpret", { re, args -> "<bot VAR1=interpret>" })
        }

        assertEquals("Var updated", re.reply(user, "setvar 123"))
        assertEquals("Var1 is '123'", re.reply(user, "getvar"))
        assertEquals("Test:123", re.reply(user, "simple1"))
        assertEquals("SomethingRef=Test:123", re.reply(user, "complex"))//failing, is '{__call__test "123"</call>}'
        assertEquals("", re.reply(user, "interpret"))//failing, is 'test interpret</call>}'
        assertEquals("Var1 is 'Test:interpret'", re.reply(user, "getvar"))//failing

javascript result (from https://www.rivescript.com/try)

User: setvar 123
Bot: Var updated
User: getvar
Bot: Var1 is '123'
User: simple1
Bot: Test:123
User: complex
Bot: SomethingRef=Test:123
User: interpret
Bot:
User: getvar
Bot: Var1 is 'Test:interpret'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions