aichaos / rivescript-go

A RiveScript interpreter for Go. RiveScript is a scripting language for chatterbots.
https://www.rivescript.com/
MIT License
60 stars 16 forks source link

Different database backend? #39

Closed rmasci closed 5 years ago

rmasci commented 5 years ago

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.

meowgorithm commented 5 years ago

How important is the permanence of your sessions? RiveScript has an in-memory store (I believe it's just a map[string]string) which is set by default.

kirsle commented 5 years ago

Hello,

Yes, RiveScript's default session manager is an in-memory one where it keeps them in a map within the object. You could then use .GetUservars() and .SetUservars() to export them from the bot's memory and save them, and load them back in again respectively.

If you'd like to implement a BoltDB or other interface to replace the Memory and Redis options, you can implement the sessions.SessionManager interface with your own type: https://godoc.org/github.com/aichaos/rivescript-go/sessions

The Redis, memory and null session managers are in this repo that you can reference. A pull request to add new drivers under rivescript-go/sessions/ would be welcome too. :smile:

rmasci commented 5 years ago

Thanks for your comments. I looked into both Ledis and Bolt and realized I know nothing about these types of databases. Now I've written my own mysql client in Go, so I do know db, but nosql is new to me.