fix command name lookup error, maybe fix seendb threading error

This commit is contained in:
iou1name 2018-05-29 08:08:42 -04:00
parent ea4e7a6653
commit feb33e2345
3 changed files with 32 additions and 8 deletions

View File

@ -7,7 +7,6 @@ Dependencies: `twisted, python-dateutil, requests, bs4, wolfram, pyenchant`
### TODO: ### TODO:
Fix the movie table Fix the movie table
Consider re-adding the following modules: `etymology, ip` Consider re-adding the following modules: `etymology, ip`
Consider logging
Add CTCP responses Add CTCP responses
More complex versioning More complex versioning
Better readme Better readme

6
bot.py
View File

@ -258,10 +258,10 @@ class Fulvia(irc.IRCClient):
if message.startswith(self.prefix) and message != self.prefix: if message.startswith(self.prefix) and message != self.prefix:
command, _, _ = message.partition(" ") command, _, _ = message.partition(" ")
command = command.replace(self.prefix, "", 1) command = command.replace(self.prefix, "", 1)
func_name = self.commands.get(command)._func_name cmd = self.commands.get(command)
if not func_name: if not cmd:
return return
func_names.append(func_name) func_names.append(cmd._func_name)
func_names += self._hooks func_names += self._hooks

View File

@ -38,17 +38,28 @@ class FulviaMemory(dict):
def __setitem__(self, key, value): def __setitem__(self, key, value):
"""
Set a key-value pair. Eg. 'dict[key]=value'.
"""
self.lock.acquire() self.lock.acquire()
result = dict.__setitem__(self, key, value) result = dict.__setitem__(self, key, value)
self.lock.release() self.lock.release()
return result 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): def __contains__(self, key):
""" """
Check if a key is in the dict. Check if a key is in the dict. Eg. 'key in dict'.
It locks it for writes when doing so.
""" """
self.lock.acquire() self.lock.acquire()
result = dict.__contains__(self, key) result = dict.__contains__(self, key)
@ -70,15 +81,29 @@ class FulviaMemoryDefault(defaultdict):
def __setitem__(self, key, value): def __setitem__(self, key, value):
"""
Set a key-value pair. Eg. 'dict[key]=value'.
"""
self.lock.acquire() self.lock.acquire()
result = defaultdict.__setitem__(self, key, value) result = defaultdict.__setitem__(self, key, value)
self.lock.release() self.lock.release()
return result 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): 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() self.lock.acquire()
result = defaultdict.__contains__(self, key) result = defaultdict.__contains__(self, key)