Skip to content

Commit

Permalink
Resolved issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRahme committed Mar 16, 2021
1 parent ba95dfc commit 2509b4e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions actions/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class DatabaseConnection:
query = None

def __init__(self):
if self.connection == None:
if self.connection is None:
self.connect()

def connect(self):
Expand Down Expand Up @@ -121,14 +121,14 @@ def announce(action, tracker = None):
output += '\n- Entities: ' + ', '.join(msg['entities'])
output += '\n- Slots: '
for slot_key, slot_value in slots.items():
if slot_value != None:
if slot_value is not None:
filled_slots[slot_key] = slot_value
if len(filled_slots) > 0:
for slot_key, slot_value in filled_slots.items():
output += str(slot_key) + ': ' + str(slot_value) + ', '
output = output[:-2]
except Exception as e:
pass
print(f'\n> announce: [ERROR] {e}')
print(output)


Expand Down Expand Up @@ -682,7 +682,7 @@ async def required_slots(self, predefined_slots, dispatcher, tracker, domain):

if checkpoint: # There is no noise on the line, continue
required_slots.append('tib_modem_on')
if tracker.get_slot('tib_modem_on') == True: # The modem is on and it works, stop
if tracker.get_slot('tib_modem_on'): # The modem is on and it works, stop
print('\nBOT:', text_if_works)
dispatcher.utter_message(text_if_works)
else: # The modem is on and it doesn't work, continue
Expand Down Expand Up @@ -1097,8 +1097,7 @@ def run(self, dispatcher, tracker, domain):
utterance = 'اللغة الآن هي العربية.'
elif current_language == 'Armenian':
utterance = 'Լեզուն այժմ հայերենն է:'
else:
current_language == 'English'
else:
utterance = 'I only understand English, French, Arabic, and Armenian. The language is now English.'

dispatcher.utter_message(utterance)
Expand Down Expand Up @@ -1188,7 +1187,8 @@ def alpha2_to_name(self, alpha2):
try:
name = pycountry.countries.get(alpha_2=alpha2).name
return name
except:
except Exception as e:
print(f'\n> ActionCheckWeather.alpha2_to_name: [ERROR] {e}')
return alpha2


Expand All @@ -1207,7 +1207,8 @@ def call_api(self, city_name):

return result

except:
except Exception as e:
print(f'\n> ActionCheckWeather.call_api: [ERROR] {e}')
return {'response': False}


Expand Down Expand Up @@ -1271,7 +1272,7 @@ def run(self, dispatcher, tracker, domain):
dispatcher.utter_message(text)
return [SlotSet('out_of_scope', latest['text'])]

elif intent == 'affirm' and query != None:
elif intent == 'affirm' and query is not None:
try:
text = 'Here are the top results:'
urls = [url for url in googlesearch.search(
Expand Down

0 comments on commit 2509b4e

Please sign in to comment.