diff --git a/src/channel/index.ts b/src/channel/index.ts index f3650d0..606ce52 100644 --- a/src/channel/index.ts +++ b/src/channel/index.ts @@ -8,8 +8,6 @@ export interface IChannel { enabled: boolean; } -// TODO: Source specification to support plugin services. - export class ChannelManager { private channels: IChannel[] = []; @@ -39,14 +37,15 @@ export class ChannelManager { return; } const source = plugin.manifest.name; - const emitTo = this.getChannelsByPluginName(source); + const emitTo = this.getChannelsByPluginName(source, data.source); for (const chan of emitTo) { if (chan.plugins.length < 2) { continue; } for (const pl of chan.plugins) { - if (pl !== source) { - this.stream.emitTo(pl, event, data); + if (pl !== source && + !(pl.indexOf('/') !== -1 && pl.split('/')[0] === source)) { + this.stream.emitTo(pl, event, data, chan); } } } @@ -54,14 +53,21 @@ export class ChannelManager { } } - private getChannelsByPluginName(plugin: string): IChannel[] { + private getChannelsByPluginName(plugin: string, source: Protocol): IChannel[] { const list = []; for (const chan of this.channels) { if (chan.enabled === false) { continue; } - if (chan.plugins.indexOf(plugin) !== -1) { - list.push(chan); + for (const pl of chan.plugins) { + if (pl.indexOf('/') !== -1) { + const split = pl.split('/'); + if (split[0] === plugin && split[1] === source.name) { + list.push(chan); + } + } else if (pl === plugin) { + list.push(chan); + } } } return list; diff --git a/src/types/message.ts b/src/types/message.ts index 31b1efc..a13d2cb 100644 --- a/src/types/message.ts +++ b/src/types/message.ts @@ -1,3 +1,4 @@ +import { IChannel } from '../channel'; import { Protocol } from './protocol'; export enum EMessageType { @@ -90,8 +91,4 @@ export interface IMessage { * @param target UserTarget to mention (i.e. `msg.sender`) */ mention(target: IMessageTarget): string; - - kick?(reason: string): void; - ban?(reason: string): void; - mute?(reason: string): void; }