-
Notifications
You must be signed in to change notification settings - Fork 725
/
auth_bot.py
44 lines (38 loc) · 1.51 KB
/
auth_bot.py
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
36
37
38
39
40
41
42
43
44
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
from typing import List
from botbuilder.core import (
ConversationState,
UserState,
TurnContext,
)
from botbuilder.dialogs import Dialog
from botbuilder.schema import ChannelAccount
from helpers.dialog_helper import DialogHelper
from .dialog_bot import DialogBot
class AuthBot(DialogBot):
def __init__(
self,
conversation_state: ConversationState,
user_state: UserState,
dialog: Dialog,
):
super(AuthBot, self).__init__(conversation_state, user_state, dialog)
async def on_members_added_activity(
self, members_added: List[ChannelAccount], turn_context: TurnContext
):
for member in members_added:
# Greet anyone that was not the target (recipient) of this message.
# To learn more about Adaptive Cards, see https://aka.ms/msbot-adaptivecards for more details.
if member.id != turn_context.activity.recipient.id:
await turn_context.send_activity(
"Welcome to AuthenticationBot. Type anything to get logged in. Type "
"'logout' to sign-out."
)
async def on_token_response_event(self, turn_context: TurnContext):
# Run the Dialog with the new Token Response Event Activity.
await DialogHelper.run_dialog(
self.dialog,
turn_context,
self.conversation_state.create_property("DialogState"),
)