Skip to content

Commit

Permalink
Do not set memory if parameter is none
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankWhoee committed Feb 2, 2020
1 parent 1ee7cef commit 9d8895e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
11 changes: 6 additions & 5 deletions action.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ def __init__(self, parameters=None, client: Client = None):
self.gdb = self.get(parameters, 'gdb')
client.markAsDelivered(self.thread_id, self.message_object.uid)
client.markAsRead(self.thread_id)
if 'memory' not in self.database:
self.database['memory']: dict = {}
self.memory = self.database['memory']
if str(self.author_id) not in self.memory: self.memory[str(self.author_id)]: dict = {}
self.memory = self.memory[str(self.author_id)]
if parameters:
if 'memory' not in self.database:
self.database['memory']: dict = {}
self.memory = self.database['memory']
if str(self.author_id) not in self.memory: self.memory[str(self.author_id)]: dict = {}
self.memory = self.memory[str(self.author_id)]
self.define_documentation()

def process(self):
Expand Down
11 changes: 6 additions & 5 deletions commands/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ class Command(Action):
def __init__(self, parameters=None, client: Client = None):
Action.__init__(self, parameters, client)
self.user_params: list = self.get(parameters, 'user')
if 'commands' not in self.memory:
self.memory['commands'] = {}
self.memory = self.memory['commands']
if self.trigger not in self.memory:
self.memory[self.trigger] = {}
if parameters:
if 'commands' not in self.memory:
self.memory['commands'] = {}
self.memory = self.memory['commands']
if self.trigger not in self.memory:
self.memory[self.trigger] = {}
4 changes: 3 additions & 1 deletion commands/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ def run(self):
instance = self.get_instance(x)
response_text += "\n\n!" + x + ": " + instance.documentation["function"]
response_text += "\n\nIf you want to learn more about a specific command, send '!help !COMMAND_NAME'."
except:
except ValueError:
# sends detailed information about a specific command
c_name = str(self.user_params[0]).replace("!", "", 1)
print(c_name)
print(modules)
if c_name in modules:
instance = self.get_instance(c_name)
response_text += """
Expand Down
11 changes: 6 additions & 5 deletions keywords/keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ def __init__(self, parameters=None, client: Client=None):
"trigger": "",
"function": ""
}
if 'keywords' not in self.memory:
self.memory['keywords'] = {}
self.memory = self.memory['keywords']
if self.trigger not in self.memory:
self.memory[self.trigger] = {}
if parameters:
if 'keywords' not in self.memory:
self.memory['keywords'] = {}
self.memory = self.memory['keywords']
if self.trigger not in self.memory:
self.memory[self.trigger] = {}

0 comments on commit 9d8895e

Please sign in to comment.