-
Notifications
You must be signed in to change notification settings - Fork 194
/
example-plugin.js
27 lines (26 loc) · 1 KB
/
example-plugin.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
module.exports = {
defaultConfig: {
enabled: false,
},
// plugin meta data to better describe your plugin
pluginName: 'ExamplePlugin',
pluginDescription: 'This plugin shows you all API events in the log.',
init(proxy, config) {
// Subscribe to api command events from the proxy here.
// You can subscribe to specifc API commands. Event name is the same as the command string
proxy.on('HubUserLogin', () => {
if (config.Config.Plugins[this.pluginName].enabled) {
proxy.log({ type: 'info', source: 'plugin', name: this.pluginName, message: 'You just logged into the game.' });
}
});
// or all API commands with the 'apiCommand' event
proxy.on('apiCommand', (req, resp) => {
if (config.Config.Plugins[this.pluginName].enabled) {
this.processEveryCommand(proxy, req, resp);
}
});
},
processEveryCommand(proxy, req) {
proxy.log({ type: 'info', source: 'plugin', name: this.pluginName, message: `Found API Command ${req.command}` });
},
};