service-irc/ircprototest/plugin.ts
2020-11-29 15:16:00 +02:00

36 lines
820 B
TypeScript

import {
Plugin,
EventListener,
Configurable,
InjectService,
Auto
} from '@squeebot/core/lib/plugin';
import { EMessageType, IMessage, IMessageTarget, Protocol } from '@squeebot/core/lib/types';
import { logger } from '@squeebot/core/lib/core';
class MyPlugin extends Plugin {
@Auto()
initialize(): void {
}
@EventListener('message')
messageHandler(msg: IMessage): void {
if (msg.data.indexOf('Squeebot') !== -1) {
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;