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:
Fix the movie table
Consider re-adding the following modules: `etymology, ip`
Consider logging
Add CTCP responses
More complex versioning
Better readme

6
bot.py
View File

@ -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

View File

@ -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)