mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Make it so that ACTIONs don't get added as factoids
This commit is contained in:
parent
13e0447ea5
commit
9d7c1a64c2
@ -202,6 +202,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
(fact, key) = cursor.fetchone()
|
(fact, key) = cursor.fetchone()
|
||||||
irc.reply("%r is %r" % (key, fact))
|
irc.reply("%r is %r" % (key, fact))
|
||||||
|
|
||||||
|
|
||||||
def invalidCommand(self, irc, msg, tokens):
|
def invalidCommand(self, irc, msg, tokens):
|
||||||
key = ' '.join(tokens)
|
key = ' '.join(tokens)
|
||||||
key = key.rstrip('?!')
|
key = key.rstrip('?!')
|
||||||
@ -231,7 +232,7 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def addFactoid(self, irc, msg, match):
|
def addFactoid(self, irc, msg, match):
|
||||||
r"^(.+?)\s+(?:is|_is_)\s+(.+)"
|
r"^(?!\x01)(.+?)\s+(?:is|_is_)\s+(.+)"
|
||||||
# Check and see if there is a command that matches this that didn't
|
# Check and see if there is a command that matches this that didn't
|
||||||
# get caught due to nesting
|
# get caught due to nesting
|
||||||
# cb = callbacks.findCallbackForCommand(irc, msg)
|
# cb = callbacks.findCallbackForCommand(irc, msg)
|
||||||
@ -658,6 +659,20 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
db.commit()
|
db.commit()
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
|
|
||||||
|
def randomfactoid(self, irc, msg, args):
|
||||||
|
"""<takes no arguments>
|
||||||
|
|
||||||
|
Displays a random factoid (along with its key) from the database.
|
||||||
|
"""
|
||||||
|
cursor = self.db.cursor()
|
||||||
|
cursor.execute("""SELECT fact, key FROM factoids
|
||||||
|
ORDER BY random() LIMIT 1""")
|
||||||
|
if cursor.rowcount == 0:
|
||||||
|
irc.error(msg, 'No factoids in the database.')
|
||||||
|
return
|
||||||
|
(fact, key) = cursor.fetchone()
|
||||||
|
irc.reply(msg, "Random factoid: %r is %r" % (key, fact))
|
||||||
|
|
||||||
Class = MoobotFactoids
|
Class = MoobotFactoids
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
@ -76,6 +76,8 @@ if sqlite is not None:
|
|||||||
# Check substitution
|
# Check substitution
|
||||||
self.assertNotError('who is <reply>$who')
|
self.assertNotError('who is <reply>$who')
|
||||||
self.assertResponse('who', 'foo')
|
self.assertResponse('who', 'foo')
|
||||||
|
# Check that actions ("\x01ACTION...") don't match
|
||||||
|
self.assertNoResponse('\x01ACTION\x01 is doing something', 3)
|
||||||
|
|
||||||
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