superscriptjs / superscript

A dialogue engine for creating chat bots
http://superscriptjs.com
MIT License
1.65k stars 209 forks source link

this.message.props does not work as expected #329

Closed hailiang-wang closed 7 years ago

hailiang-wang commented 7 years ago

Write a custom plugin, call plugin from script. Use this.message.props['key'] = value which is described in wiki.

Expected Behavior

With the bot.reply method, get the key-values in callback.

Current Behavior

Get an error.

There was an error processing reply tags: TypeError: Cannot set property 'WHAT_PROPERTY' of undefined

Possible Solution

After check the keys in this.message, it does not contain props object.

image image

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Context

Your Environment

bensalilijames commented 7 years ago

Because the plugin function creates a copy of the message object, modifying the message.props object won't persist once it leaves the function.

Instead, you'll want to do as described here. Essentially we pass back props in the callback which will then be merged into the "real" message object!

bensalilijames commented 7 years ago

Guessing this is OK - closing!