diff --git a/plugins/Amazon.py b/plugins/Amazon.py
index a840136f8..fe03836fd 100644
--- a/plugins/Amazon.py
+++ b/plugins/Amazon.py
@@ -89,7 +89,7 @@ class Amazon(callbacks.PrivmsgCommandAndRegexp):
def callCommand(self, method, irc, msg, *L, **kwargs):
try:
- callbacks.PrivmsgCommandAndRegexp.callCommand(self, method, irc, msg, *L, **kwargs)
+ super(Amazon, self).callCommand(method, irc, msg, *L, **kwargs)
except amazon.NoLicenseKey, e:
irc.error('You must have a free Amazon web services license key '
'in order to use this command. You can get one at '
diff --git a/plugins/Infobot.py b/plugins/Infobot.py
index 921523b2a..a6534bd40 100755
--- a/plugins/Infobot.py
+++ b/plugins/Infobot.py
@@ -52,13 +52,14 @@ import supybot.ircmsgs as ircmsgs
import supybot.ircutils as ircutils
import supybot.privmsgs as privmsgs
import supybot.registry as registry
+import supybot.webutils as webutils
import supybot.callbacks as callbacks
-try:
- import sqlite
-except ImportError:
- raise callbacks.Error, 'You need to have PySQLite installed to use this ' \
- 'plugin. Download it at '
+## try:
+## import sqlite
+## except ImportError:
+## raise callbacks.Error, 'You need to have PySQLite installed to use this ' \
+## 'plugin. Download it at '
conf.registerPlugin('Infobot')
conf.registerGlobalValue(conf.supybot.plugins.Infobot, 'personality',
@@ -133,9 +134,12 @@ class PickleInfobotDB(object):
self._changes = 0
else:
try:
- (self._is, self._are) = pickle.load(fd)
- except cPickle.UnpicklingError, e:
- raise dbi.InvalidDBError, str(e)
+ try:
+ (self._is, self._are) = pickle.load(fd)
+ except cPickle.UnpicklingError, e:
+ raise dbi.InvalidDBError, str(e)
+ finally:
+ fd.close()
def flush(self):
fd = utils.transactionalFile(filename, 'wb')
@@ -363,7 +367,7 @@ class SqliteInfobotDB(object):
return areFacts + isFacts
def InfobotDB():
- return SqliteInfobotDB()
+ return PickleInfobotDB()
class Dunno(Exception):
pass
@@ -524,7 +528,7 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
if payload.endswith(irc.nick):
self.addressed = True
payload = payload[:-len(irc.nick)]
- payload = payload.strip(', ') # Strip punctuation separating nick.
+ payload = payload.strip(', ') # Strip punctuation before nick.
payload += '?' # So doUnknown gets called.
if not payload.strip():
self.log.debug('Bailing since we received an empty msg.')
@@ -541,8 +545,7 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
try:
self.irc = irc
self.msg = msg
- callbacks.PrivmsgCommandAndRegexp.callCommand(self, f, irc, msg,
- *L, **kwargs)
+ super(Infobot, self).callCommand(f, irc, msg, *L, **kwargs)
finally:
self.irc = None
self.msg = None
@@ -699,6 +702,52 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
except Dunno:
self.dunno()
+ def update(self, irc, msg, args):
+ """{is,are}
+
+ Updates the Infobot database using the dumped database at . The
+ first argument should be "is" or "are", and determines whether the is
+ or are database is updated.
+ """
+ (isAre, url) = privmsgs.getArgs(args, required=2)
+ isAre = isAre.lower()
+ if isAre == 'is':
+ add = self.db.setIs
+ elif isAre == 'are':
+ add = self.db.setAre
+ else:
+ raise callbacks.ArgumentError
+ count = 0
+ fd = webutils.getUrlFd(url)
+ for line in fd:
+ line = line.rstrip('\r\n')
+ try:
+ (key, value) = line.split(' => ', 1)
+ except ValueError: #unpack list of wrong size
+ self.log.debug('Invalid line: %r', line)
+ continue
+ else:
+ key = key.rstrip()
+ value = value.lstrip()
+ self.log.debug('Adding factoid %r with value %r.', key, value)
+ add(key, value)
+ count += 1
+ irc.replySuccess('%s added.' % utils.nItems('factoid', count))
+ update = privmsgs.checkCapability(update, 'owner')
+
+ def dump(self, irc, msg, args):
+ """
+
+ Dumps the current Infobot database into a flatfile named .
+ is put in the data directory if no directory is specified.
+ """
+ filename = privmsgs.getArgs(args)
+ if filename == os.path.basename(filename):
+ filename = conf.supybot.directories.data.dirize(filename)
+ fd = utils.transactionalFile(filename)
+
+
+
Class = Infobot
diff --git a/plugins/Weather.py b/plugins/Weather.py
index 56ebf1a6f..a4fcc5a29 100644
--- a/plugins/Weather.py
+++ b/plugins/Weather.py
@@ -84,9 +84,9 @@ class Weather(callbacks.Privmsg):
the name of 'weather' which should override this help."""
weatherCommands = ['ham', 'cnn', 'wunder']
threaded = True
- def callCommand(self, method, irc, msg, *L):
+ def callCommand(self, method, irc, msg, *L, **kwargs):
try:
- callbacks.Privmsg.callCommand(self, method, irc, msg, *L)
+ super(Weather, self).callCommand(method, irc, msg, *L, **kwargs)
except webutils.WebError, e:
irc.error(str(e))
diff --git a/plugins/WordStats.py b/plugins/WordStats.py
index 568bb743a..3d369e13f 100644
--- a/plugins/WordStats.py
+++ b/plugins/WordStats.py
@@ -191,7 +191,7 @@ class WordStats(callbacks.Privmsg):
def callCommand(self, *args, **kwargs):
self.queried = True
- return callbacks.Privmsg.callCommand(self, *args, **kwargs)
+ return super(WordStats, self).callCommand(*args, **kwargs)
def doPrivmsg(self, irc, msg):
# This depends on the fact that it's called after the command.
diff --git a/plugins/Words.py b/plugins/Words.py
index 46810bbdc..06b8eabf6 100644
--- a/plugins/Words.py
+++ b/plugins/Words.py
@@ -133,10 +133,10 @@ class HangmanGame:
class Words(callbacks.Privmsg):
- def callCommand(self, command, irc, msg, args):
+ def callCommand(self, command, irc, msg, args, *L, **kw):
# We'll catch the IOError here.
try:
- callbacks.Privmsg.callCommand(self, command, irc, msg, args)
+ super(Words, self).callCommand(command, irc, msg, args, *L, **kw)
except EnvironmentError, e:
irc.error('I couldn\'t open the words file. This plugin expects '
'a words file (i.e., a file with one word per line, in '