Skip to content
This repository has been archived by the owner on Dec 26, 2021. It is now read-only.

Created getIntegration method #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/core/Bot.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export declare class Bot {
constructor(obj?: IOptions);
getHTTPEndpoints(): string[];
getRouter(): express.Router | null;
getIntegration(name: string): any | null;
use(instance: any, filter?: string | string[]): void;
hear(pattern: string | boolean, messageTypes?: string | callbackType, cb?: callbackType): Observable<IMessage>;
hears(patterns: string[], messageTypes?: string | callbackType, cb?: callbackType): Observable<IActivityStream>;
Expand Down
7 changes: 7 additions & 0 deletions lib/core/Bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ class Bot {
}
return this.router;
}
getIntegration(name) {
const integrationFind = R.filter((integration) => integration.serviceName() === name, this.integrations);
if (!R.isEmpty(integrationFind)) {
return integrationFind[0];
}
return null;
}
use(instance, filter) {
if (instance.listen) {
this.logger.info({ method: 'use', message: `Integration: ${instance.serviceName()}` });
Expand Down
11 changes: 11 additions & 0 deletions src/core/Bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ export class Bot {
return this.router;
}

public getIntegration(name: string): any | null {
const integrationFind = R.filter((integration: any) =>
integration.serviceName() === name, this.integrations);

if (!R.isEmpty(integrationFind)) {
return integrationFind[0];
}

return null;
}

public use(instance: any, filter?: string | string[]): void {
// it's an integration
if (instance.listen) {
Expand Down