-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConsoleBot.ts
32 lines (28 loc) · 967 Bytes
/
ConsoleBot.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
import { ConsoleAdapter, Storage, MemoryStorage, ConversationReference } from 'botbuilder';
import { StateBot, StateContext } from './botbldr';
export class ConsoleBot <Conversation = any, User = any> extends StateBot<Conversation, User> {
adapter: ConsoleAdapter;
constructor(storage?: Storage) {
super(storage);
this.adapter = new ConsoleAdapter()
.use(this.conversationState)
.use(this.userState);
}
onTurn(
handler: (
context: StateContext<Conversation, User>,
) => Promise<void>
) {
this.adapter
.use(... this.middlewares)
.listen(this.do(handler));
}
continueConversation(
reference: ConversationReference,
handler: (
appContext: StateContext<Conversation, User>,
) => Promise<void>
): Promise<void> {
return this.adapter.continueConversation(reference, this.do(handler));
}
}