-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStateBot.ts
More file actions
22 lines (18 loc) · 834 Bytes
/
StateBot.ts
File metadata and controls
22 lines (18 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { TurnContext, ConversationReference, Middleware, Storage, ConversationState, UserState, MemoryStorage } from 'botbuilder';
import { BaseBot } from './BaseBot';
import { StateContext } from './StateContext';
const key = 'github.com/billba/botbldr';
export abstract class StateBot <Conversation = any, User = any> extends BaseBot<StateContext<Conversation, User>> {
conversationState: ConversationState<Conversation>;
userState: UserState<User>;
constructor (storage: Storage = new MemoryStorage()) {
super();
this.conversationState = new ConversationState<Conversation>(storage, key);
this.userState = new UserState<User>(storage, key);
}
getContext(
context: TurnContext,
) {
return StateContext.from(context, this.conversationState, this.userState)
}
}