Reference implementation of the
Currently alpha code
Hello!
Thanks if you have come here from the tutorial!
If not, it might be worth starting there.
The tutorial gives you an overview of how to develop within the ubibot framework, using the supplied libraries
npm install @numical/ubibot-engine
Treat as a library of utility functions:
const { respondTo } = require("@numical/ubibot-engine");
...
const reponse = respondTo(command);
This module exports a single function:
###respondTo(request, respond)
- iteratively calls itself whilst
respond(request)
results in a function;
arguments
- request (any) : arbitary argument passed torespond
function;
- respond (function) : accepts a single argument
returns
(any) - the first non-function response in the iterative chain
This library provides a single function to create or access a configuration object used by an ubibot implementation.
Pass arguments to create a configuration object:
- sets default values;
- merges in domain-specific configuration;
- validates the result.
Typical usage follows this pattern:
const { configure } = require("@numical/ubibot-config");
const domainOptions = { ... };
const config = configure(domainOptions);
...
The resultant config
object is then used as an argument for any package that instantiates an ubibot instance - generally a channel package such as @numical/ubibot-channel-cli.
If no arguments are passed this simply returns the default or last generated configuration.
const { configure } = require("@numical/ubibot-config");
const config = configure();
...
The package guards against modification after the getter has been called - see api for details.
This module exports a single function:
###configure([options], [allowModifyAfterGet])
- creates or returns a previously created configuration object for an ubibot implementation;
arguments
- options (optional Object) : a dictionary to be merged with default configuration; will be validated;
- allowModifyAfterGet (optional boolean) : default behaviour is to throw an error if this function is called as a setter after having been called as a getter; set this value totrue
to override this; returns
(object) - the created (setter) or previously created (getter) configuration.