mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +01:00
Included plugins.standardSubstitute in factoids parsing now
This commit is contained in:
parent
68d36db874
commit
96f299c10c
@ -159,7 +159,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
self.db.close()
|
self.db.close()
|
||||||
del self.db
|
del self.db
|
||||||
|
|
||||||
def parseFactoid(self, fact):
|
def parseFactoid(self, irc, msg, fact):
|
||||||
type = "define" # Default is to just spit the factoid back as a
|
type = "define" # Default is to just spit the factoid back as a
|
||||||
# definition of what the key is (i.e., "foo is bar")
|
# definition of what the key is (i.e., "foo is bar")
|
||||||
newfact = ''.join(pick(tokenize(fact)))
|
newfact = ''.join(pick(tokenize(fact)))
|
||||||
@ -171,6 +171,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
newfact = newfact.replace("<action>", "", 1)
|
newfact = newfact.replace("<action>", "", 1)
|
||||||
newfact = newfact.strip()
|
newfact = newfact.strip()
|
||||||
type = "action"
|
type = "action"
|
||||||
|
newfact = plugins.standardSubstitute(irc, msg, newfact)
|
||||||
return (type, newfact)
|
return (type, newfact)
|
||||||
|
|
||||||
def updateFactoidRequest(self, key, hostmask):
|
def updateFactoidRequest(self, key, hostmask):
|
||||||
@ -200,7 +201,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
hostmask = msg.prefix
|
hostmask = msg.prefix
|
||||||
self.updateFactoidRequest(key, hostmask)
|
self.updateFactoidRequest(key, hostmask)
|
||||||
# Now actually get the factoid and respond accordingly
|
# Now actually get the factoid and respond accordingly
|
||||||
(type, text) = self.parseFactoid(fact)
|
(type, text) = self.parseFactoid(irc, msg, fact)
|
||||||
if type == "action":
|
if type == "action":
|
||||||
irc.queueMsg(ircmsgs.action(ircutils.replyTo(msg), text))
|
irc.queueMsg(ircmsgs.action(ircutils.replyTo(msg), text))
|
||||||
elif type == "reply":
|
elif type == "reply":
|
||||||
|
@ -53,6 +53,9 @@ if sqlite is not None:
|
|||||||
self.assertResponse('foo', 'foo is foo')
|
self.assertResponse('foo', 'foo is foo')
|
||||||
self.assertNotError('bar is <reply>moo is moo')
|
self.assertNotError('bar is <reply>moo is moo')
|
||||||
self.assertResponse('bar', 'moo is moo')
|
self.assertResponse('bar', 'moo is moo')
|
||||||
|
# Check substitution
|
||||||
|
self.assertNotError('who is <reply>$who')
|
||||||
|
self.assertResponse('who', 'foo')
|
||||||
|
|
||||||
def testLiteral(self):
|
def testLiteral(self):
|
||||||
self.assertError('literal moo') # no factoids yet
|
self.assertError('literal moo') # no factoids yet
|
||||||
|
Loading…
Reference in New Issue
Block a user