summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2011-09-30 23:14:20 +0200
committerJulien Dessaux2011-09-30 23:14:20 +0200
commit21bc372a1a77952f7c04a320a3977420b6171d09 (patch)
tree42c7748848d4afedb4a804e54a78462ad36fcc27
parentUpdated schema to save the channel on which the quote is from. (diff)
downloadhsbot-21bc372a1a77952f7c04a320a3977420b6171d09.tar.gz
hsbot-21bc372a1a77952f7c04a320a3977420b6171d09.tar.bz2
hsbot-21bc372a1a77952f7c04a320a3977420b6171d09.zip
Updated the getRandomQuote transaction.
-rw-r--r--Hsbot/Plugin/Quote.hs6
1 files 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 "