-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime error: invalid memory address or nil pointer dereference #30
Comments
Notes to self or whoever wants to tackle this one:
The fix would be: handle the error here. Actually it would probably be better to move the // See if there were any %Previous's in this topic, or any topic related to
// it. This should only be done the first time -- not during a recursive
// redirection. This is because in a redirection, "lastReply" is still gonna
// be the same as it was the first time, resulting in an infinite loop!
+ history, err := rs.sessions.GetHistory(username)
- if step == 0 {
+ if err != nil && step == 0 {
allTopics := []string{topic}
if len(rs.includes[topic]) > 0 || len(rs.inherits[topic]) > 0 {
// Get ALL the topics!
allTopics = rs.getTopicTree(topic, 0)
} |
Is this corrected in the current release? Or there a work around? |
Not yet. As a workaround, if you set a user variable before getting a reply, then it will initialize the user's session and it won't raise a nil pointer exception. This might be a good idea to do anyway, for example to set an "is_admin" variable that you could query from within RiveScript -- if your bot has any need of such things, anyway. Example: // Setting a user variable to initialize their session
// will avoid the nil pointer exception when getting
// their history back from the session manager.
bot.SetUservar(username, "is_admin", isAdmin(username))
reply, err := bot.Reply(username, message) |
I get this panic even after setting uservar :(
if I try to
|
I try ro copy and paste your example for rivescript session using redis
but I keep on getting this error.
The text was updated successfully, but these errors were encountered: