mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
MoobotFactoids.randomfactoid must've felt so lonely not having anyone to test
that he was ok. Add that to him having an unwanted msg lying around, and he must've been quite sad.
This commit is contained in:
parent
1ef546178c
commit
3128255c0f
@ -681,14 +681,15 @@ class MoobotFactoids(callbacks.PrivmsgCommandAndRegexp):
|
||||
|
||||
Displays a random factoid (along with its key) from the database.
|
||||
"""
|
||||
cursor = self.db.cursor()
|
||||
db = self.dbHandler.getDb()
|
||||
cursor = 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.')
|
||||
irc.error('No factoids in the database.')
|
||||
return
|
||||
(fact, key) = cursor.fetchone()
|
||||
irc.reply(msg, 'Random factoid: "%s" is "%s"' % (key, fact))
|
||||
irc.reply('Random factoid: "%s" is "%s"' % (key, fact))
|
||||
|
||||
Class = MoobotFactoids
|
||||
|
||||
|
@ -340,5 +340,10 @@ if sqlite is not None:
|
||||
self.assertResponse('listkeys foo', 'Key search for "foo" '
|
||||
'(1 found): "foo"')
|
||||
|
||||
def testRandomFactoid(self):
|
||||
self.assertNotError('foo is <reply>bar')
|
||||
self.assertNotError('bar is <reply>baz')
|
||||
self.assertRegexp('randomfactoid', r'bar|baz')
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
Loading…
Reference in New Issue
Block a user