-
Notifications
You must be signed in to change notification settings - Fork 209
Upgrading to v1
Back to Home
There are a number of breaking changes introduced in v1 that you need to be aware of when upgrading.
Warning: This may not be a comprehensive list, as so much has changed that it has been hard to track. If you find any behaviour that has changed, please do edit this page!
- Topic names may no longer have a
~
in them, to prevent mixups with WordNet expansions. - Topic flags should now be included within {}. So instead of
> topic:system:keep topic_name
use> topic topic_name {system, keep}
- Gambit filter functions now use braces to be consistent with reply filters:
{^plugin()}
instead of^plugin()
. - Questions no longer use question subtypes such as
?:YN
or?:ENT:abbv
. Now use the?
token by itself. - Phrases are no longer transformed to phrases like
~emohello
or~emogoodbye
. Instead, these are now properties of the message object asmessage.tags
that you can access in plugin functions. To maintain the same behaviour, you can change:
// This previously matched 'hi', 'hello', 'hey' etc
+ Hello
- Hi there!
to:
+ {^hasTag('hello')} *
- Hi there!
- Parameters of custom functions are now JavaScript literals. Any parameters (with the exception of using
<cap>
s or~wordnetLookup
s) must now have quotes around them. For example,^myFunction(test,<cap1>)
becomes^myFunction("test", <cap1>)
.
This also means you can have arbitrary types in plugins, such as objects and arrays. For example: ^myPlugin({ someKey: "someValue" }, ['hi', 'everybody'])
. Note that a closing parenthesis denotes the end of the function arguments: you can escape this by just writing \(
or \)
within the arguments.
- The API to use SuperScript and the options it accepts have changed significantly. The idea is to express any setup as configuration options, rather than to get you to manage the topic/fact system setup yourself. Thus, the only dependency you now need is
superscript
. You now run:
import superscript from 'superscript';
let options = {};
// Modify the options object
superscript.setup(options, (err, bot) => {
// Do something with bot
});
The default options are (at the time of writing) as follows:
const defaultOptions = {
mongoURI: 'mongodb://localhost/superscriptDB',
importFile: null,
factSystem: {
clean: false,
importFiles: null,
},
scope: {},
editMode: false,
pluginsPath: `${process.cwd()}/plugins`,
logPath: `${process.cwd()}/logs`,
useMultitenancy: false,
conversationTimeout: 1000 * 300, // time window to checkout conversation with lastReply
historyCheckpoints: 10 // length of looking back history data to drop unkeep replies
};
More information about these options may be found in https://github.com/superscriptjs/superscript/blob/v1.0.0/src/bot/index.js.