service-irc/ircprototest/plugin.ts

29 lines
715 B
TypeScript
Raw Normal View History

2020-11-29 13:16:00 +00:00
import {
Plugin,
EventListener,
} from '@squeebot/core/lib/plugin';
import { IMessage } from '@squeebot/core/lib/types';
2020-11-29 13:16:00 +00:00
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);
2020-11-29 13:16:00 +00:00
}
}
@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;