forked from service-bot/servicebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (34 loc) · 1.09 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//todo, integrate this into a plugin.
let { EVENT, SET_OPTIONS,SET_EVENT_SAGAS, INIT_STORE, setOptions ,setEventSagas, initializeStore, triggerEvent} = require("./config/redux/actions");
const defaultAppState = {
"eventReducer" : null,
"eventSagas" : {},
"options" : {}
};
function appReducer(state = defaultAppState , action) {
//change the store state based on action.type
switch(action.type) {
case EVENT:
return state;
case INIT_STORE:
return action.initialStore;
case SET_OPTIONS :
let options = Object.assign({}, state.options, action.options);
return Object.assign({}, state, {
"options" : options
})
default:
return state;
}
}
module.exports = async function(configPath) {
try {
let Pluginbot = require("pluginbot");
let path = require("path");
let app = await Pluginbot.createPluginbot(configPath)
await app.initialize({"servicebot": appReducer});
return app;
}catch(e){
console.error(e);
}
};