mirror of
				https://github.com/Mikaela/Limnoria.git
				synced 2025-10-31 15:47:25 +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 | ||||
| 
 | ||||
|  | ||||
| @ -339,6 +339,11 @@ if sqlite is not None: | ||||
|             MFconf.showFactoidIfOnlyOneMatch.setValue(False) | ||||
|             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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 James Vega
						James Vega