diff --git a/README.md b/README.md index 7bf140d..1a535f2 100755 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ Dependencies: `twisted, python-dateutil, requests, bs4, wolfram, pyenchant` ### TODO: Fix the movie table Consider re-adding the following modules: `etymology, ip` -Consider logging Add CTCP responses More complex versioning Better readme diff --git a/bot.py b/bot.py index 973ba68..a73f112 100755 --- a/bot.py +++ b/bot.py @@ -258,10 +258,10 @@ class Fulvia(irc.IRCClient): if message.startswith(self.prefix) and message != self.prefix: command, _, _ = message.partition(" ") command = command.replace(self.prefix, "", 1) - func_name = self.commands.get(command)._func_name - if not func_name: + cmd = self.commands.get(command) + if not cmd: return - func_names.append(func_name) + func_names.append(cmd._func_name) func_names += self._hooks diff --git a/tools/__init__.py b/tools/__init__.py index bdb0675..145ef86 100755 --- a/tools/__init__.py +++ b/tools/__init__.py @@ -38,17 +38,28 @@ class FulviaMemory(dict): def __setitem__(self, key, value): + """ + Set a key-value pair. Eg. 'dict[key]=value'. + """ self.lock.acquire() result = dict.__setitem__(self, key, value) self.lock.release() return result + def __getitem__(self, key): + """ + Get the value of 'key'. Eg. 'dict[key]'. + """ + self.lock.acquire() + result = dict.__getitem__(self, key) + self.lock.release() + return result + + def __contains__(self, key): """ - Check if a key is in the dict. - - It locks it for writes when doing so. + Check if a key is in the dict. Eg. 'key in dict'. """ self.lock.acquire() result = dict.__contains__(self, key) @@ -70,15 +81,29 @@ class FulviaMemoryDefault(defaultdict): def __setitem__(self, key, value): + """ + Set a key-value pair. Eg. 'dict[key]=value'. + """ self.lock.acquire() result = defaultdict.__setitem__(self, key, value) self.lock.release() return result + def __getitem__(self, key): + """ + Get the value of 'key'. Eg. 'dict[key]'. + """ + # TODO: figure out why this doesn't work + #self.lock.acquire() + result = defaultdict.__getitem__(self, key) + #self.lock.release() + return result + + def __contains__(self, key): """ - Check if a key is in the dict. Locks it for writes when doing so. + Check if a key is in the dict. Eg. 'key in dict'. """ self.lock.acquire() result = defaultdict.__contains__(self, key)