Fixed import bug with absolute paths
parent
2c0f2530a7
commit
127d3c1d59
|
@ -80,6 +80,10 @@ class Respond(Skill):
|
|||
entities = self._get_entities(message)
|
||||
chosen_response = self._substitute_entities(chosen_response, entities)
|
||||
if self.callback_file != None and self.callback_name != None:
|
||||
callback_module = importlib.import_module(self.callback_file)
|
||||
# The following three lines allow us to import the module using an absolute path dynamically
|
||||
spec = importlib.util.spec_from_file_location("callback", self.callback_file)
|
||||
callback_module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(callback_module)
|
||||
# Now we can get the response from the callback.
|
||||
chosen_response = eval("callback_module." + self.callback_name + "(message, entities)")
|
||||
await message.respond(chosen_response)
|
||||
|
|
Loading…
Reference in New Issue