Git Product home page Git Product logo

rivescript-go's People

Contributors

agungwk avatar echoline avatar kirsle avatar liadala avatar meowgorithm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rivescript-go's Issues

Topic Timeout

I have a chatbot running, and I have programming that allows a user to start a troubleshooting session, and each step is a topic. The problem is they may go away, and then come back hours later and try to ask the chatbot another question -- but they're stuck inside the topic they left on which may be a few days ago. Is there a way to time out a topic? So that ten minutes later it goes back to topic=random?

Ignore case in triggers?

ALl triggers are lower cased -- is it possible to create a trigger that doesn't? I have a user of my chatbot that he wants to decrypt a string. So that string is in upper / lower case etc.

+ decrypt string *
- LocalCommand /usr/local/bin/decrypt <star1>

I have code in my chatbot that looks at the response. If the response starts with: LocalCommand, RemoteCommand it tries to execute the command, the results of that command is what gets sent to the user. This is configurable and can check if that user is allowed to run that command etc. Anyway is there a way to ignore the case of what is input in <star1>? Something like this:

+ decrypt string <ignorecase>*
- LocalCommand /usr/local/bin/decrypt <star1>

I am asking first. I plan on creating one for my chatbot....

Unformatted Input

I’m curious if it's possible to capture raw (or at least, unlowercased) input in a macro. I'm encountering a case where I need to capture case-sensitive input with punctuation and, as far as I can tell, the data would currently need to be captured outside of RiveScript.

Make the API more idiomatic as a Go library

This is a blanket ticket for going through the codebase and doing general cleanup and API fixes to make the code more idiomatic from a Go point of view.

Examples:

  • More functions should return error objects to communicate failure conditions rather than relying on "magic" return values like empty strings.

    • e.g. func ClearUservars(username string) error could return an error when the user had no vars to clear.
    • e.g. func CurrentUser() (string, error) where it gives an error when called outside of an object macro context, rather than what it currently does by returning an empty string -- this isn't idiomatic Go.
  • User variable getter functions should be refactored to make more sense for "API context" vs. "internal use w/ <get>"

    • The public API functions like GetUservar() should follow Go idioms and return "", error in case of errors rather than "undefined", error
    • The internal use of the functions for the <get> types of tags would handle the mapping of "" to "undefined" for their own use.
  • Find a way to make the constructor config object easier to get and use. It's stupid to need to import aichaos/rivescript-go/config to get the config.Config{} type for initializing RiveScript. The config type should be available directly from the parent package.

    This might require refactoring to make the parent package include more logic for config handling rather than just proxying all methods through to the /src versions, but that's probably a good thing anyway. The /src package is private use only and I already spelled out in its docs that its API can be changed at any time without notice.

    bot := rivescript.New(rivescript.BasicConfig())

Strips out . in message

OK So I have a rive script that looks like this:

Rivescript:
+ echo domain *
- What is <star1>

Go code (simplified):
var bot *rivescript.RiveScript
chatbot = rivescript.New(rivescript.WithUTF8())
err := chatbot.LoadDirectory("/path/to/rivescript/files")
errhandle(err)
bot.SortReplies()
// chatStr = echo domain www.google.com
reply, err := chatbot.Reply(userID, chatStr)
// reply = "What is wwwgooglecom"

What is happening is that rivescript appears to be stripping off the . in urls. Not sure why...

Matching and Linebreaks

I've been noticing that user input with linebreaks seems to not match anything at all, not even the topmost catch-all rule. I've been solving for this in the meantime by stripping line breaks before passing the input to RiveScript, but wondering if this is a bug or intended behavior?

Different database backend?

Hey -- I Love Rivescript -- I've implemented a chatbot that integrates into my companies proprietary chat system. Normally folks would open tickets to our team, and we'd go and pull info off of a server, put it in the ticket. Now those users can request that information using our chat system. Rivescript makes it VERY easy for the non-programmers to teach our chatbot new tricks.

+ show  server uptime on *
- LocalComand ssh <star1> uptime

(User gets the output of 'LocalCommand')

What I would like is to eliminate the requirement to install redis for sessions. How hard would it be to write a client for Rivescript so that it could use one of the Go naitive databases like Ledis, or Bolt (I know there are others) that way the user can embed the database into their chatbot code, and not have a requirement.

regular expression in rivescript?

Hi -- Is it possible using rivescript-go to define a regular expression? I am developing a chatbot where I ask the user for information for example if I need to get a serial number that is formatted like this:
123AB6-12C3-123EF456

> topic getserialnumber 
  + lookup serial number in database
  - Please enter your serial number

  + [A-Z0-9]{6}-[A-Z0-9]{4}-[A-Z0-9]{8}
  - Cool, thank you, looking <star1> up
< topic

Is something like this possible?

javascript Handler panic with rs.SetUservar

I tried the example provided

// JavaScript Object Macro Examples
! version = 2.0
> object setvar javascript
	// Example of how to get the current user's ID and set
	// variables for them.
	var uid = rs.CurrentUser();
	var name  = args[0];
	var value = args[1];
	rs.SetUservar(uid, name, value);
< object
+ javascript set * to *
- Set user variable <star1> to <star2>.<call>setvar <star1> <star2></call>

but it only ends in panic

http: panic serving [::1]:54453: reflect: Call using []interface {} as type string
goroutine 40 [running]:
net/http.(*conn).serve.func1(0xc042270000)
        E:/dev/bin/go/src/net/http/server.go:1721 +0xd7
panic(0x8a0400, 0xc042284090)
        E:/dev/bin/go/src/runtime/panic.go:489 +0x2dd
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.catchPanic.func1(0xc0422ee750)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/error.go:240 +0x3de
panic(0x8a0400, 0xc042284090)
        E:/dev/bin/go/src/runtime/panic.go:489 +0x2dd
reflect.Value.call(0x8b7f20, 0xc0421b50e0, 0x13, 0x93fd98, 0x4, 0xc042119a90, 0x3, 0x3, 0x942b91, 0x8a0400, ...)
        E:/dev/bin/go/src/reflect/value.go:371 +0x109b
reflect.Value.Call(0x8b7f20, 0xc0421b50e0, 0x13, 0xc042119a90, 0x3, 0x3, 0xc042284080, 0x98, 0x40ed49)
        E:/dev/bin/go/src/reflect/value.go:302 +0xab
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).toValue.func1(0xc042198000, 0x0, 0x0, 0x5, 0x92ff00, 0
xc0422ad6e0, 0xc0422ada40, 0x3, 0x4, 0xc0421132f0, ...)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/runtime.go:403 +0x6e7
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_object).call(0xc0422adb00, 0x5, 0x92ff00, 0xc0422ad6e0, 0xc0422
ada40, 0x3, 0x4, 0x0, 0xc04229d5f0, 0x0, ...)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/type_function.go:140 +0x1bf
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).cmpl_evaluate_nodeCallExpression(0xc042198000, 0xc0422
9d8f0, 0x0, 0x0, 0x0, 0xc04200bf50, 0xc0422eda00, 0x40d036)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/cmpl_evaluate_expression.go:244 +0x55e
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).cmpl_evaluate_nodeExpression(0xc042198000, 0xbb2180, 0
xc04229d8f0, 0x8a0400, 0xc04200bf50, 0x6ed7a2)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/cmpl_evaluate_expression.go:44 +0x79b
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).cmpl_evaluate_nodeStatement(0xc042198000, 0xbb2300, 0x
c0422aaa80, 0x0, 0x0, 0x0)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/cmpl_evaluate_statement.go:62 +0x11a4
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).cmpl_evaluate_nodeStatementList(0xc042198000, 0xc0422a
8980, 0x2, 0x2, 0xc0425a9ed0, 0x470604, 0x8f5a60)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/cmpl_evaluate_statement.go:121 +0x7c
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).cmpl_evaluate_nodeStatement(0xc042198000, 0xbb20c0, 0x
c0422a89a0, 0x0, 0x0, 0x0)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/cmpl_evaluate_statement.go:30 +0x6ef
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).cmpl_call_nodeFunction(0xc042198000, 0xc0422ad1a0, 0xc
042135f20, 0xc0421cb400, 0x5, 0x92ff00, 0xc042188120, 0xc042135ef0, 0x2, 0x2, ...)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/cmpl_evaluate.go:61 +0x4fb
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_object).call(0xc0422ad1a0, 0x5, 0x92ff00, 0xc042188120, 0xc0421
35ef0, 0x2, 0x2, 0xc04200be00, 0x0, 0x0, ...)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/type_function.go:157 +0x74d
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.(*_runtime).cmpl_evaluate_nodeCallExpression(0xc042198000, 0xc0421
35e90, 0xc0425aa9f0, 0x2, 0x2, 0x755e55, 0xc0425aa728, 0xc0425aa720)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/cmpl_evaluate_expression.go:244 +0x55e
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.Otto.Call.func2()
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/otto.go:482 +0x62
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.catchPanic(0xc0425aa830, 0x0, 0x0)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/error.go:243 +0x73
github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto.Otto.Call(0x0, 0xc042198000, 0xc04200bbe0, 0xd, 0x0, 0x0, 0xc0425a
a9f0, 0x2, 0x2, 0x0, ...)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/vendor/github.com/robertkrimen/otto/otto.go:483 +0x7df
github.com/aichaos/rivescript-go/lang/javascript.JavaScriptHandler.Call(0xc0421132f0, 0xc042196000, 0xc0421b4ba0, 0xc042122361, 0x6, 0x
c042135db0, 0x2, 0x2, 0x1, 0xc0421c4000)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/lang/javascript/javascript.go:102 +0x466
github.com/aichaos/rivescript-go/lang/javascript.(*JavaScriptHandler).Call(0xc04217c140, 0xc042122361, 0x6, 0xc042135db0, 0x2, 0x2, 0x3
, 0xc042122340)
        <autogenerated>:2 +0x9e
github.com/aichaos/rivescript-go.(*RiveScript).processTags(0xc042196000, 0xc0422ba8e3, 0x2, 0xc0421e8f80, 0xf, 0xc042122340, 0x34, 0xc0
422a38a0, 0x2, 0x2, ...)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/tags.go:511 +0x3653
github.com/aichaos/rivescript-go.(*RiveScript).getReply(0xc042196000, 0xc0422ba8e3, 0x2, 0xc0421e8f80, 0xf, 0x0, 0x0, 0xc042118323, 0x4
, 0x0, ...)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/brain.go:411 +0xcc8
github.com/aichaos/rivescript-go.(*RiveScript).Reply(0xc042196000, 0xc0422ba8e3, 0x2, 0xc0421e8f80, 0xf, 0xc0422ba8ef, 0x3, 0xffffffff,
 0x15)
        E:/dev/code/go/src/github.com/aichaos/rivescript-go/brain.go:43 +0x515
main.RawIntentHandler(0xbb8480, 0xc042196460, 0xc04203ac00)
        net/http.HandlerFunc.ServeHTTP(0x95a458, 0xbb8480, 0xc042196460, 0xc04203ac00)
        E:/dev/bin/go/src/net/http/server.go:1942 +0x4b
main.Logger.func1(0xbb8480, 0xc042196460, 0xc04203ac00)
net/http.HandlerFunc.ServeHTTP(0xc0422b6040, 0xbb8480, 0xc042196460, 0xc04203ac00)
        E:/dev/bin/go/src/net/http/server.go:1942 +0x4b
github.com/gorilla/mux.(*Router).ServeHTTP(0xc04213efa0, 0xbb8480, 0xc042196460, 0xc04203ac00)
        E:/dev/code/go/src/github.com/gorilla/mux/mux.go:114 +0x113
net/http.serverHandler.ServeHTTP(0xc04215c0b0, 0xbb8480, 0xc042196460, 0xc042154100)
        E:/dev/bin/go/src/net/http/server.go:2568 +0x99
net/http.(*conn).serve(0xc042270000, 0xbb8c80, 0xc042012580)
        E:/dev/bin/go/src/net/http/server.go:1825 +0x619
created by net/http.(*Server).Serve
        E:/dev/bin/go/src/net/http/server.go:2668 +0x2d5

How to use a golang object macro

Hi,
I'm can't figure out how to use a golang object macro. On top of that I have no idea what is available in the object definition or how to inject context, if possible like in the js version.

I've tried both > object foo go and object foo golang and both give me the [ERR: Object Not Found] so I'm going to assume that it isn't supported. And I see that only javascript and text are tested.

I would love to not have to touch javascript at all. Thanks. I am getting pretty excited about rivescript.

+ # + # is not matching

I have a trigger

+ # + # 
- Adding <star1> and <star2>

But it never matches... looks like the + in the middle is confusing the parser... So how do I write this for inputs like

10+22

Related to #25 How to use SetSubroutine

cannot find package "github.com/aichaos/rivescript-go/src" in any of:

github.com/aichaos/rivescript-go/src does not exist in current repo...and it does not work.. Whats the alternative?

Can't run python macros with rivescript-go interpreter

I had written a python macro in .rive file. I ran it earlier using python interpreter and it worked fine. But, now when I'm running it using go interpreter it gives me an error.
[ERR: Object Not Found]

Please help me..!!

how did you find golang?

just wondering how you liked golang for this project? I'm a bit fedup wtih JS but not sure where to jump next. go seems much more C like and strict - for example parsing JSON you have to declare structs in advance... so maybe not as good for moving fast. but with pointers and other features it gives more fine grained control. presumably goroutines obviate the need for callback hell too...
but for something as freeform a dialect as rivescript, how did you find writing the interpreter compared to say the python port?

Redirects should be lowercased

When a redirection is called for a different reply, the text should be lowercased and probably run through the same filters that an original message is.

The following code demonstrates the issue:

! var master = Kirsle

+ my name is (<bot master>)
- <set name=<formal>>That's my master's name too.

+ call me <bot master>
@ my name is <bot master>

If you say "call me kirsle" it will try to redirect and find a match for my name is Kirsle (with a capital K), which doesn't satisfy the regular expression /my name is kirsle/ of the first trigger. The result is a "No reply matched" error.

Lowercasing it in the RiveScript code doesn't work around this problem:

+ call me <bot master>
@ my name is {lowercase}<bot master>{/lowercase}

Catching it in a <star> works though in the mean time:

+ call me (<bot master>)
@ my name is <star>

Also look into the other RiveScript implementations and see if they're affected by this bug.

Library not thread safe

@kirsle
This library is not thread safe. It panics and raises fatal error in multi threaded environment. This is because you are not handling concurrent read and write of maps which is not thread safe in golang. Please see these posts for reference:

  1. https://www.reddit.com/r/golang/comments/4a8y8c/go_16_fatal_error_concurrent_map_read_and_map/
  2. http://stackoverflow.com/questions/36167200/how-safe-are-golang-maps-for-concurrent-read-write-operations
  3. http://stackoverflow.com/questions/11063473/map-with-concurrent-access

I'm also posting the error message for your reference.


fatal error: concurrent map read and map write

goroutine 51 [running]:
runtime.throw(0x89e4a0, 0x21)
    /home/ravi/Work/software/go/src/runtime/panic.go:530 +0x90 fp=0xc8206221f8 sp=0xc8206221e0
runtime.mapaccess1_faststr(0x727aa0, 0xc820011a10, 0xc82000a538, 0x2, 0x1)
    /home/ravi/Work/software/go/src/runtime/hashmap_fast.go:202 +0x5b fp=0xc820622258 sp=0xc8206221f8
github.com/aichaos/rivescript-go.(*RiveScript).processTags(0xc8200ce580, 0xc82000a538, 0x2, 0xc82019451a, 0xa, 0xc8200cb7a0, 0x16, 0xc8206228e0, 0x0, 0x0, ...)
    /home/ravi/Work/go/src/github.com/aichaos/rivescript-go/tags.go:227 +0xcd1 fp=0xc820622860 sp=0xc820622258
github.com/aichaos/rivescript-go.(*RiveScript).getReply(0xc8200ce580, 0xc82000a538, 0x2, 0xc82019451a, 0xa, 0x0, 0x1, 0x0, 0x0)
    /home/ravi/Work/go/src/github.com/aichaos/rivescript-go/brain.go:400 +0x28ce fp=0xc820622f10 sp=0xc820622860
github.com/aichaos/rivescript-go.(*RiveScript).processTags(0xc8200ce580, 0xc82000a538, 0x2, 0xc8204efbd8, 0x2, 0xc820194510, 0x30, 0xc82000a560, 0x1, 0x1, ...)
    /home/ravi/Work/go/src/github.com/aichaos/rivescript-go/tags.go:435 +0x22c7 fp=0xc820623518 sp=0xc820622f10
github.com/aichaos/rivescript-go.(*RiveScript).getReply(0xc8200ce580, 0xc82000a538, 0x2, 0xc8204efbd8, 0x2, 0x0, 0x0, 0x0, 0x0)
    /home/ravi/Work/go/src/github.com/aichaos/rivescript-go/brain.go:400 +0x28ce fp=0xc820623bc8 sp=0xc820623518
github.com/aichaos/rivescript-go.(*RiveScript).Reply(0xc8200ce580, 0xc82000a538, 0x2, 0xc8204efbd8, 0x2, 0x0, 0x0)
    /home/ravi/Work/go/src/github.com/aichaos/rivescript-go/brain.go:42 +0x47b fp=0xc820623d60 sp=0xc820623bc8

Please resolve this bug.

A suggestion from my side is to use concurrent-map instead of golang inbuilt maps.

no way to see actual input?

There doesn't seem to be any way to get at the un-simplified input
e.g., input of
Jenny's place -> Jennys place
in a function
would like to be able to see Jenny's place not Jennys place
Did I miss it somehow?
also fine to get the whole input not just the if that's available

Cannot sort replies while using in http Handler

Hi,

I am trying to build a telegram bot and using Echo web framework.
trying to integrate this library but unable to do so.

here is my sample function code which is called during webhook call

func NewMsg(message *models.Message) (string, error) {
	
	botbrain := brain.New(brain.UTF8())
	botbrain.SetHandler("javascript", brain.NewJSHandler(botbrain))
	err := botbrain.LoadDirectory("../rivescripts/")
	if err != nil {
		log.Printf("Error loading directory: %s", err)
		os.Exit(1)
	}
	botbrain.SortReplies()
	reply := botbrain.Reply(strconv.Itoa(int(message.User.ID)), message.Text)
	return reply, nil
}

but it gives ERR: Replies Not Sorted

Can you please help?

`RiveScript.SetSubroutine` type troubles

I've noticed in the recent revision of this library RiveScript.SetSubroutine no longer works due to what appears to be a type mismatch:

For example, with the following code:

package main

import "github.com/aichaos/rivescript-go"

main() {
    bot := rivescript.New(nil)
    bot.SetSubroutine("test", func(rs *rivescript.RiveScript, args []string) string {
        return "Oh, hello."
    })
}

…results in the following error:

cannot use func literal (type func(*"github.com/aichaos/rivescript-go".RiveScript, []string) string) string) as type "chat/vendor/github.com/aichaos/rivescript-go/src".Subroutine in argument to bot.SetSubroutine

…which makes me think the issues lies in the fact that "rivescript-go/src".Submodule expects "rivescript-go/src".RiveScript as the first argument whereas "rivescript-go".RiveScript.SetSubmodule expects the local "rivescript-go".RiveScript as an argument, hence the type error.

Python object macro support

It'd be nice if rivescript-go were able to parse and run Python object macros for RiveScript bots, by using the Python C API.

There are two projects I found so far: sbinet/go-python and qur/gopy. They both only support Python 2 so far, but that will work for now.

I did some experimenting and came up with the following Go code that demonstrates the key pieces of functionality needed: dynamically parse a Python function, call the function giving it an array of string arguments, and retrieve the result of the function as a Go string.

package main

import (
    "fmt"
    "github.com/sbinet/go-python"
)

func init() {
    err := python.Initialize()
    if err != nil {
        panic(err.Error())
    }
}

func main() {
    // The source code of the python function we wanna be able to call.
    pycode := `
def test(rs, args):
    print "Test works"
    return "Forwards: {}\nBackwards: {}".format(
        " ".join(args),
        " ".join(args[::-1]),
    )
`

    // The []string to use as the 'args' param to `def test()`
    args := StringList_ToPython("Hello", "world")
    defer args.DecRef() // Always do this so Python can count references well.

    // To load the function you can simply eval the code in the global scope:
    python.PyRun_SimpleString(pycode)

    // Get the main module's dictionary so we can get a reference to our
    // function back out of it.
    main_module   := python.PyImport_AddModule("__main__")
    main_dict     := python.PyModule_GetDict(main_module)
    test_function := python.PyDict_GetItemString(main_dict, "test")

    // The tuple of (rs, args) arguments to pass to the function.
    // This tuple is the *args in Python lingo.
    test_args := python.PyTuple_New(2)
    defer test_args.DecRef()
    python.PyTuple_SetItem(test_args, 0, python.Py_None)
    python.PyTuple_SetItem(test_args, 1, args)

    // Call the actual Python function now. Functions return a *PyObject, and
    // we can cast it back to a string.
    returned := test_function.CallObject(test_args)
    result := python.PyString_AsString(returned)

    // Print the result of the function.
    fmt.Println("Result:", result)
}

// StringList_ToPython is a helper function that simply converts a Go []string
// into a Python List of the same length with the same contents.
func StringList_ToPython(items... string) *python.PyObject {
    list := python.PyList_New(len(items))

    for i, item := range items {
        python.PyList_SetItem(list, i, python.PyString_FromString(item))
    }

    return list
}

This code lets us:

  • Dynamically provide Python source for a function definition.
  • Prepare the Python *args tuple, converting Go strings into Python strings for the args argument (which is a list(str) type)
  • Call the function and gets its (string) result.

The other huge TODO is the rs parameter to the Python function: the above code sends in a NoneType, but IRL it would need to provide an object with at least a subset of the RiveScript API (most importantly, functions like rs.current_user() and rs.set_uservar() & friends). I imagine to expose the full RiveScript API to Python I'd need to write a whole wrapper class that translates all the arguments to/from Python types, but I'll probably just focus on the aforementioned useful functions to start out with.

(?) in golang

Hi, this operator (?) in goo language causes errors .

$ go run . 
[WARN] Unknown command '?' at brain\index.rive line 2
[WARN] Response found before trigger at brain\index.rive line 3
[WARN] Response found before trigger at brain\index.rive line 4

Macros within conditionals

Should macros execute and return before a conditional is evaluated? Currently, in a case such as this…

+ my name is *
* <call>isHisNameFrank <star></call> == true => Welcome, Frank.
- You’re not Frank. Go find Frank.

…it appears that the macro not being called at all.

An issue in the JavaScript RiveScript project makes me think the expected behavior is that macros should indeed execute before the conditional is evaluated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.