mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 18:44:04 +01:00
Added <action>, <reply>, and | handling
This commit is contained in:
parent
a8a95c2ecc
commit
7f112672de
@ -177,7 +177,7 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
def die(self):
|
def die(self):
|
||||||
self.db.close()
|
self.db.close()
|
||||||
|
|
||||||
def reply(self, s, irc=None, msg=None):
|
def reply(self, s, irc=None, msg=None, action=False):
|
||||||
if self.replied:
|
if self.replied:
|
||||||
self.log.debug('Already replied, not replying again.')
|
self.log.debug('Already replied, not replying again.')
|
||||||
return
|
return
|
||||||
@ -188,7 +188,8 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
assert self.msg is not None
|
assert self.msg is not None
|
||||||
msg = self.msg
|
msg = self.msg
|
||||||
self.replied = True
|
self.replied = True
|
||||||
irc.reply(plugins.standardSubstitute(irc, msg, s), prefixName=False)
|
irc.reply(plugins.standardSubstitute(irc, msg, s), prefixName=False,
|
||||||
|
action=action)
|
||||||
|
|
||||||
def confirm(self, irc=None, msg=None):
|
def confirm(self, irc=None, msg=None):
|
||||||
if self.registryValue('personality'):
|
if self.registryValue('personality'):
|
||||||
@ -223,7 +224,15 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
self.dunno(irc=irc, msg=msg)
|
self.dunno(irc=irc, msg=msg)
|
||||||
else:
|
else:
|
||||||
# XXX
|
# XXX
|
||||||
self.reply('%s %s %s, $who.' % (key,isAre,value), irc=irc, msg=msg)
|
if value.startswith('<or>'):
|
||||||
|
value = random.choice(value[4:].split('|'))
|
||||||
|
if value.startswith('<reply>'):
|
||||||
|
self.reply('%s' % value[7:].strip(), irc=irc, msg=msg)
|
||||||
|
elif value.startswith('<action>'):
|
||||||
|
self.reply('%s' % value[8:].strip(), irc=irc, msg=msg,
|
||||||
|
action=True)
|
||||||
|
else:
|
||||||
|
self.reply('%s %s %s, $who.' % (key,isAre,value), irc=irc, msg=msg)
|
||||||
|
|
||||||
def normalize(self, s):
|
def normalize(self, s):
|
||||||
s = ircutils.stripFormatting(s)
|
s = ircutils.stripFormatting(s)
|
||||||
@ -298,8 +307,9 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
# TODO: Add invalidCommand.
|
# TODO: Add invalidCommand.
|
||||||
|
|
||||||
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, also, value) = match.groups()
|
(key, isAre, also, value) = match.groups()
|
||||||
|
key = key.replace('\\', '')
|
||||||
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 \
|
||||||
@ -312,6 +322,8 @@ class Infobot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
isAre = isAre.lower()
|
isAre = isAre.lower()
|
||||||
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 '|' in value:
|
||||||
|
value = '<or>%s' % value
|
||||||
if isAre in ('was', 'is', 'am'):
|
if isAre in ('was', 'is', 'am'):
|
||||||
if self.db.hasIs(key):
|
if self.db.hasIs(key):
|
||||||
if also:
|
if also:
|
||||||
|
Loading…
Reference in New Issue
Block a user