mirror of https://github.com/Mikaela/Limnoria.git
Updated.
This commit is contained in:
parent
53b29f1bf8
commit
70dc5c3096
|
@ -53,7 +53,7 @@ import callbacks
|
||||||
|
|
||||||
conf.registerPlugin('Infobot')
|
conf.registerPlugin('Infobot')
|
||||||
conf.registerGlobalValue(conf.supybot.plugins.Infobot, 'personality',
|
conf.registerGlobalValue(conf.supybot.plugins.Infobot, 'personality',
|
||||||
registry.Boolean(True, """Determines whether the bot will respond will
|
registry.Boolean(True, """Determines whether the bot will respond with
|
||||||
personable (Infobot-like) responses rather than its standard messages."""))
|
personable (Infobot-like) responses rather than its standard messages."""))
|
||||||
conf.registerGlobalValue(conf.supybot.plugins.Infobot, 'boringDunno',
|
conf.registerGlobalValue(conf.supybot.plugins.Infobot, 'boringDunno',
|
||||||
registry.String('Dunno.', """Determines what boring dunno should be given
|
registry.String('Dunno.', """Determines what boring dunno should be given
|
||||||
|
@ -245,24 +245,17 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
||||||
payload = maybeAddressed
|
payload = maybeAddressed
|
||||||
else:
|
else:
|
||||||
payload = msg.args[1]
|
payload = msg.args[1]
|
||||||
#print '*', payload
|
|
||||||
payload = self.normalize(payload)
|
payload = self.normalize(payload)
|
||||||
#print '**', payload
|
|
||||||
maybeForced = self._forceRe.sub('', payload)
|
maybeForced = self._forceRe.sub('', payload)
|
||||||
if maybeForced != payload:
|
if maybeForced != payload:
|
||||||
self.force = True
|
self.force = True
|
||||||
payload = maybeForced
|
payload = maybeForced
|
||||||
#print '***', payload
|
|
||||||
if payload.endswith(irc.nick):
|
if payload.endswith(irc.nick):
|
||||||
self.addressed = True
|
self.addressed = True
|
||||||
payload = payload[:-len(irc.nick)]
|
payload = payload[:-len(irc.nick)]
|
||||||
payload = payload.strip(', ') # Strip punctuation separating nick.
|
payload = payload.strip(', ') # Strip punctuation separating nick.
|
||||||
payload += '?' # So doUnknown gets called.
|
payload += '?' # So doUnknown gets called.
|
||||||
#print '****', payload
|
|
||||||
try:
|
try:
|
||||||
#print 'Payload:', payload
|
|
||||||
#print 'Force:', self.force
|
|
||||||
#print 'Addressed:', self.addressed
|
|
||||||
msg = ircmsgs.privmsg(msg.args[0], payload, prefix=msg.prefix)
|
msg = ircmsgs.privmsg(msg.args[0], payload, prefix=msg.prefix)
|
||||||
callbacks.PrivmsgCommandAndRegexp.doPrivmsg(self, irc, msg)
|
callbacks.PrivmsgCommandAndRegexp.doPrivmsg(self, irc, msg)
|
||||||
finally:
|
finally:
|
||||||
|
@ -283,12 +276,18 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
||||||
def doForget(self, irc, msg, match):
|
def doForget(self, irc, msg, match):
|
||||||
r"^forget\s+(.+?)[?!. ]*$"
|
r"^forget\s+(.+?)[?!. ]*$"
|
||||||
fact = match.group(1)
|
fact = match.group(1)
|
||||||
|
deleted = False
|
||||||
for method in [self.db.delIs, self.db.delAre]:
|
for method in [self.db.delIs, self.db.delAre]:
|
||||||
try:
|
try:
|
||||||
method(fact)
|
method(fact)
|
||||||
|
deleted = True
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
if deleted:
|
||||||
self.confirm()
|
self.confirm()
|
||||||
|
else:
|
||||||
|
# XXX: Should this be genericified?
|
||||||
|
irc.reply('I\'ve never heard of %s, %s!' % (fact, msg.nick))
|
||||||
|
|
||||||
def doUnknown(self, irc, msg, match):
|
def doUnknown(self, irc, msg, match):
|
||||||
r"^(.+?)\?[?!. ]*$"
|
r"^(.+?)\?[?!. ]*$"
|
||||||
|
@ -300,7 +299,7 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
||||||
|
|
||||||
def doFactoid(self, irc, msg, match):
|
def doFactoid(self, irc, msg, match):
|
||||||
r"^(.+)\s+(was|is|am|were|are)\s+(also\s+)?(.+?)[?!. ]*$"
|
r"^(.+)\s+(was|is|am|were|are)\s+(also\s+)?(.+?)[?!. ]*$"
|
||||||
(key, isAre, maybeForce, value) = match.groups()
|
(key, isAre, also, value) = match.groups()
|
||||||
if key.lower() in ('where', 'what', 'who'):
|
if key.lower() in ('where', 'what', 'who'):
|
||||||
# It's a question.
|
# It's a question.
|
||||||
if self.addressed or \
|
if self.addressed or \
|
||||||
|
@ -311,28 +310,33 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
||||||
not self.registryValue('snarfUnaddressedDefinitions'):
|
not self.registryValue('snarfUnaddressedDefinitions'):
|
||||||
return
|
return
|
||||||
isAre = isAre.lower()
|
isAre = isAre.lower()
|
||||||
self.force = self.force or bool(maybeForce)
|
|
||||||
key = plugins.standardSubstitute(irc, msg, key)
|
key = plugins.standardSubstitute(irc, msg, key)
|
||||||
value = plugins.standardSubstitute(irc, msg, value)
|
value = plugins.standardSubstitute(irc, msg, value)
|
||||||
if isAre in ('was', 'is', 'am'):
|
if isAre in ('was', 'is', 'am'):
|
||||||
if self.db.hasIs(key):
|
if self.db.hasIs(key):
|
||||||
if self.addressed and not self.force:
|
if also:
|
||||||
value = self.db.getIs(key)
|
self.log.info('Adding %r to %r.', key, value)
|
||||||
self.reply('But %s is %s.' % (key, value))
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
value = '%s or %s' % (self.db.getIs(key), value)
|
value = '%s or %s' % (self.db.getIs(key), value)
|
||||||
|
elif self.force:
|
||||||
|
self.log.info('Forcing %r to %r.', key, value)
|
||||||
|
elif self.addressed:
|
||||||
|
value = self.db.getIs(key)
|
||||||
|
self.reply('But %s is %s, %s.' % (key, value, msg.nick))
|
||||||
|
return
|
||||||
self.db.setIs(key, value)
|
self.db.setIs(key, value)
|
||||||
else:
|
else:
|
||||||
if self.db.hasAre(key):
|
if self.db.hasAre(key):
|
||||||
if self.addressed and not self.force:
|
if also:
|
||||||
value = self.db.getAre(key)
|
self.log.info('Adding %r to %r.', key, value)
|
||||||
self.reply('But %s are %s.' % (key, value))
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
value = '%s or %s' % (self.db.getAre(key), value)
|
value = '%s or %s' % (self.db.getAre(key), value)
|
||||||
|
elif self.force:
|
||||||
|
self.log.info('Forcing %r to %r.', key, value)
|
||||||
|
elif self.addressed:
|
||||||
|
value = self.db.getAre(key)
|
||||||
|
self.reply('But %s are %s, %s.' % (key, value, msg.nick))
|
||||||
|
return
|
||||||
self.db.setAre(key, value)
|
self.db.setAre(key, value)
|
||||||
if self.addressed or self.force:
|
if self.addressed or self.force or also:
|
||||||
self.confirm()
|
self.confirm()
|
||||||
|
|
||||||
def stats(self, irc, msg, args):
|
def stats(self, irc, msg, args):
|
||||||
|
|
Loading…
Reference in New Issue