-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
35 lines (30 loc) · 1.18 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import {Chat} from "./src/chat";
import {FirstChatChain} from "./src/chain-interfaces";
import {HubotChatOptions} from "./src/options";
class HubotChatTesting {
private readonly robotName: string;
private readonly helper: any;
private readonly options: HubotChatOptions;
private readonly roomOptions: any;
constructor(robotName: string, helper: any, options?: HubotChatOptions, roomOptions?: any){
this.robotName = robotName;
this.helper = helper;
this.options = options || new HubotChatOptions();
this.roomOptions = roomOptions;
}
get() {
const self = this;
const chat: Chat = new Chat(this.robotName, this.helper, this.options);
return {
chat: chat,
when: function(context: string) : FirstChatChain {
return chat.startChain(context).setRoomOptions(self.roomOptions);
}
}
}
when(context: string, options?: HubotChatOptions): FirstChatChain {
const opts: HubotChatOptions = options || this.options;
return new Chat(this.robotName, this.helper, opts).startChain(context).setRoomOptions(this.roomOptions);
}
}
module.exports = HubotChatTesting;