8000 address feedback · itsmokha/botbuilder-python@37c6028 · GitHub
[go: up one dir, main page]

Skip to content

Commit 37c6028

Browse files
author
Eric Dahlvang
committed
address feedback
1 parent d5344f4 commit 37c6028

File tree

5 files changed

+80
-86
lines changed

5 files changed

+80
-86
lines changed

libraries/botbuilder-core/botbuilder/core/skills/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77

88
from .bot_framework_skill import BotFrameworkSkill
99
from .conversation_id_factory import ConversationIdFactoryBase
10-
from .skill_conversation_id_factory import SkillConversationIdFactory
1110
from .skill_handler import SkillHandler
1211
from .skill_conversation_id_factory_options import SkillConversationIdFactoryOptions
1312
from .skill_conversation_reference import SkillConversationReference
1413

1514
__all__ = [
1615
"BotFrameworkSkill",
1716
"ConversationIdFactoryBase",
18-
"SkillConversationIdFactory",
1917
"SkillConversationIdFactoryOptions",
2018
"SkillConversationReference",
2119
"SkillHandler",

libraries/botbuilder-core/botbuilder/core/skills/skill_conversation_id_factory.py

Lines changed: 0 additions & 54 deletions
This file was deleted.

libraries/botbuilder-core/botbuilder/core/skills/skill_conversation_id_factory_options.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,7 @@ def __init__(
3333
"SkillConversationIdFactoryOptions(): bot_framework_skill cannot be None."
3434
)
3535

36-
self._from_bot_oauth_scope = from_bot_oauth_scope
37-
self._from_bot_id = from_bot_id
38-
self._activity = activity
39-
self._bot_framework_skill = bot_framework_skill
40-
41-
@property
42-
def from_bot_oauth_scope(self) -> str:
43-
return self._from_bot_oauth_scope
44-
45-
@property
46-
def from_bot_id(self) -> str:
47-
return self._from_bot_id
48-
49-
@property
50-
def activity(self) -> Activity:
51-
return self._activity
52-
53-
@property
54-
def bot_framework_skill(self) -> BotFrameworkSkill:
55-
return self._bot_framework_skill
36+
self.from_bot_oauth_scope = from_bot_oauth_scope
37+
self.from_bot_id = from_bot_id
38+
self.activity = activity
39+
self.bot_framework_skill = bot_framework_skill

libraries/botbuilder-core/botbuilder/core/skills/skill_conversation_reference.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,5 @@ def __init__(self, conversation_reference: ConversationReference, oauth_scope: s
1717
if oauth_scope is None:
1818
raise TypeError("SkillConversationReference(): oauth_scope cannot be None.")
1919

20-
self._conversation_reference = conversation_reference
21-
self._oauth_scope = oauth_scope
22-
23-
@property
24-
def conversation_reference(self) -> ConversationReference:
25-
return self._conversation_reference
26-
27-
@property
28-
def oauth_scope(self) -> str:
29-
return self._oauth_scope
20+
self.conversation_reference = conversation_reference
21+
self.oauth_scope = oauth_scope
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
from botbuilder.core import (
5+
BotFrameworkHttpClient,
6+
InvokeResponse,
7+
)
8+
from botbuilder.core.skills import (
9+
ConversationIdFactoryBase,
10+
SkillConversationIdFactoryOptions,
11+
BotFrameworkSkill,
12+
)
13+
from botbuilder.schema import Activity
14+
from botframework.connector.auth import (
15+
AuthenticationConstants,
16+
ChannelProvider,
17+
GovernmentConstants,
18+
SimpleCredentialProvider,
19+
)
20+
21+
22+
class SkillHttpClient(BotFrameworkHttpClient):
23+
def __init__(
24+
self,
25+
credential_provider: SimpleCredentialProvider,
26+
skill_conversation_id_factory: ConversationIdFactoryBase,
27+
channel_provider: ChannelProvider = None,
28+
):
29+
if not skill_conversation_id_factory:
30+
raise TypeError(
31+
"SkillHttpClient(): skill_conversation_id_factory can't be None"
32+
)
33+
34+
super().__init__(credential_provider)
35+
36+
self._skill_conversation_id_factory = skill_conversation_id_factory
37+
self._channel_provider = channel_provider
38+
39+
async def post_activity_to_skill(
40+
self,
41+
from_bot_id: str,
42+
to_skill: BotFrameworkSkill,
43+
service_url: str,
44+
activity: Activity,
45+
originating_audience: str = None,
46+
) -> InvokeResponse:
47+
48+
if originating_audience is None:
49+
originating_audience = (
50+
GovernmentConstants.TO_CHANNEL_FROM_BOT_OAUTH_SCOPE
51+
if self._channel_provider is not None
52+
and self._channel_provider.IsGovernment()
53+
else AuthenticationConstants.TO_CHANNEL_FROM_BOT_OAUTH_SCOPE
54+
)
55+
56+
options = SkillConversationIdFactoryOptions(
57+
from_bot_oauth_scope=originating_audience,
58+
from_bot_id=from_bot_id,
59+
activity=activity,
60+
bot_framework_skill=to_skill,
61+
)
62+
63+
skill_conversation_id = await self._skill_conversation_id_factory.create_skill_conversation_id(
64+
options
65+
)
66+
67+
return await super().post_activity(
68+
from_bot_id,
69+
to_skill.app_id,
70+
to_skill.skill_endpoint,
71+
service_url,
72+
skill_conversation_id,
73+
activity,
74+
)

0 commit comments

Comments
 (0)
0