specify protocol in channel plugin list
This commit is contained in:
parent
accf789b2a
commit
b4aa431223
@ -8,8 +8,6 @@ export interface IChannel {
|
|||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Source specification to support plugin services.
|
|
||||||
|
|
||||||
export class ChannelManager {
|
export class ChannelManager {
|
||||||
private channels: IChannel[] = [];
|
private channels: IChannel[] = [];
|
||||||
|
|
||||||
@ -39,14 +37,15 @@ export class ChannelManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const source = plugin.manifest.name;
|
const source = plugin.manifest.name;
|
||||||
const emitTo = this.getChannelsByPluginName(source);
|
const emitTo = this.getChannelsByPluginName(source, data.source);
|
||||||
for (const chan of emitTo) {
|
for (const chan of emitTo) {
|
||||||
if (chan.plugins.length < 2) {
|
if (chan.plugins.length < 2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (const pl of chan.plugins) {
|
for (const pl of chan.plugins) {
|
||||||
if (pl !== source) {
|
if (pl !== source &&
|
||||||
this.stream.emitTo(pl, event, data);
|
!(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 = [];
|
const list = [];
|
||||||
for (const chan of this.channels) {
|
for (const chan of this.channels) {
|
||||||
if (chan.enabled === false) {
|
if (chan.enabled === false) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (chan.plugins.indexOf(plugin) !== -1) {
|
for (const pl of chan.plugins) {
|
||||||
list.push(chan);
|
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;
|
return list;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { IChannel } from '../channel';
|
||||||
import { Protocol } from './protocol';
|
import { Protocol } from './protocol';
|
||||||
|
|
||||||
export enum EMessageType {
|
export enum EMessageType {
|
||||||
@ -90,8 +91,4 @@ export interface IMessage {
|
|||||||
* @param target UserTarget to mention (i.e. `msg.sender`)
|
* @param target UserTarget to mention (i.e. `msg.sender`)
|
||||||
*/
|
*/
|
||||||
mention(target: IMessageTarget): string;
|
mention(target: IMessageTarget): string;
|
||||||
|
|
||||||
kick?(reason: string): void;
|
|
||||||
ban?(reason: string): void;
|
|
||||||
mute?(reason: string): void;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user