29 lines
715 B
TypeScript
29 lines
715 B
TypeScript
import {
|
|
Plugin,
|
|
EventListener,
|
|
} from '@squeebot/core/lib/plugin';
|
|
|
|
import { IMessage } from '@squeebot/core/lib/types';
|
|
|
|
import { logger } from '@squeebot/core/lib/core';
|
|
|
|
class MyPlugin extends Plugin {
|
|
@EventListener('message')
|
|
messageHandler(msg: IMessage): void {
|
|
if (msg.data.indexOf('Squeebot') !== -1 && msg.sender) {
|
|
msg.resolve('Hello %s!', msg.sender.name);
|
|
}
|
|
}
|
|
|
|
@EventListener('pluginUnload')
|
|
unloadEventHandler(plugin: string | Plugin): void {
|
|
if (plugin === this.name || plugin === this) {
|
|
logger.debug('[%s]', this.name, 'shutting down..');
|
|
this.config.save().then(() =>
|
|
this.emit('pluginUnloaded', this));
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = MyPlugin;
|