8000 17.multilingual-bot suggested corrections · itsmokha/botbuilder-python@52a1d84 · GitHub
[go: up one dir, main page]

Skip to content

Commit 52a1d84

Browse files
author
Tracy Boehrer
committed
17.multilingual-bot suggested corrections
1 parent 6c28f1b commit 52a1d84

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

samples/17.multilingual-bot/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333

3434
# Catch-all for errors.
35-
async def on_error(self, context: TurnContext, error: Exception):
35+
async def on_error(context: TurnContext, error: Exception):
3636
# This check writes out errors to console log .vs. app insights.
3737
# NOTE: In production environment, you should consider logging this to Azure
3838
# application insights.
@@ -55,7 +55,7 @@ async def on_error(self, context: TurnContext, error: Exception):
5555
# Send a trace activity, which will be displayed in Bot Framework Emulator
5656
await context.send_activity(trace_activity)
5757

58-
ADAPTER.on_turn_error = MethodType(on_error, ADAPTER)
58+
ADAPTER.on_turn_error = on_error
5959

6060
# Create MemoryStorage and state
6161
MEMORY = MemoryStorage()

samples/17.multilingual-bot/bots/multilingual_bot.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, user_state: UserState):
2828
self.language_preference_accessor = self.user_state.create_property("LanguagePreference")
2929

3030
async def on_members_added_activity(
31-
self, members_added: [ChannelAccount], turn_context: TurnContext
31+
self, members_added: [ChannelAccount], turn_context: TurnContext
3232
):
3333
# Greet anyone that was not the target (recipient) of this message.
3434
# To learn more about Adaptive Cards, see https://aka.ms/msbot-adaptivecards for more details.
@@ -99,8 +99,7 @@ def _is_language_change_requested(self, utterance: str) -> bool:
9999
return False
100100

101101
utterance = utterance.lower()
102-
return utterance == TranslationSettings.english_spanish.value \
103-
or utterance == TranslationSettings.english_english.value \
104-
or utterance == TranslationSettings.spanish_spanish.value \
105-
or utterance == TranslationSettings.spanish_english.value
106-
102+
return (utterance == TranslationSettings.english_spanish.value
103+
or utterance == TranslationSettings.english_english.value
104+
or utterance == TranslationSettings.spanish_spanish.value
105+
or utterance == TranslationSettings.spanish_english.value)

samples/17.multilingual-bot/translation/microsoft_translator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async def translate(self, text_input, language_output):
3333
'text': text_input
3434
}]
3535
response = requests.post(constructed_url, headers=headers, json=body)
36-
j = response.json()
36+
json_response = response.json()
3737

3838
# for this sample, return the first translation
39-
return j[0]["translations"][0]["text"]
39+
return json_response[0]["translations"][0]["text"]

0 commit comments

Comments
 (0)
0