From 21bc372a1a77952f7c04a320a3977420b6171d09 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Fri, 30 Sep 2011 23:14:20 +0200 Subject: Updated the getRandomQuote transaction. --- Hsbot/Plugin/Quote.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Hsbot/Plugin/Quote.hs b/Hsbot/Plugin/Quote.hs index 30d5e7e..a4d5d42 100644 --- a/Hsbot/Plugin/Quote.hs +++ b/Hsbot/Plugin/Quote.hs @@ -116,11 +116,11 @@ $(makeAcidic ''QuoteDB [ 'getQuote, 'getQuoteDB, 'isQuoteLockedFor, 'lockQuoteId , 'getLastActiveQuote, 'takeNextQuoteID ]) -- | gets a random quote from the database -getRandomQuote :: AcidState QuoteDB -> IO (Maybe Quote) +getRandomQuote :: AcidState QuoteDB -> IO (Maybe (Quote, QuoteID)) getRandomQuote quoteDB = do db <- query' quoteDB GetQuoteDB if M.size db > 0 - then getStdRandom (randomR (0, M.size db - 1)) >>= \rInt -> return . Just . snd $ M.elemAt rInt db + then getStdRandom (randomR (0, M.size db - 1)) >>= \rInt -> return $ Just (snd (M.elemAt rInt db), rInt) else return Nothing -- | The duck plugin identity @@ -170,7 +170,7 @@ theQuote = do ++ "QUOTEE's nickname is a reserved word for this quote module. If no QUOTE is " ++ "provided this module lookup it's conversation history and records the " ++ "last sentence of QUOTEE." - "quote":"help":"show":_ -> answerMsg msg "quote show { QUOTEID | random [MIN_SCORE] }" + "quote":"help":"show":_ -> answerMsg msg "quote show { QUOTEID | [random] }" "quote":"help":"stat":_ -> do answerMsg msg "quote stat" answerMsg msg " Compute statistics about the quote database : Most quoters, most quoted " -- cgit v1.2.3