summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Dessaux2011-09-18 23:23:24 +0200
committerJulien Dessaux2011-09-18 23:23:24 +0200
commitb60594890fabc52fcfa15b13f61267a8a5aa3c5a (patch)
tree3757730186d78e55420855b08a532f15768816a2
parentWrote the quote append function. (diff)
downloadhsbot-b60594890fabc52fcfa15b13f61267a8a5aa3c5a.tar.gz
hsbot-b60594890fabc52fcfa15b13f61267a8a5aa3c5a.tar.bz2
hsbot-b60594890fabc52fcfa15b13f61267a8a5aa3c5a.zip
Added the getLastActiveQuote transaction.
-rw-r--r--Hsbot/Plugin/Quote.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/Hsbot/Plugin/Quote.hs b/Hsbot/Plugin/Quote.hs
index 19c7d6d..9c253ed 100644
--- a/Hsbot/Plugin/Quote.hs
+++ b/Hsbot/Plugin/Quote.hs
@@ -92,10 +92,14 @@ lockQuoteIdFor quoteId requestor now = get >>= \db -> put db { lockedQuotes = M.
setQuote :: QuoteID -> Quote -> Update QuoteDB ()
setQuote quoteId theQuote = get >>= \db -> put db { quoteBotDB = M.insert quoteId theQuote (quoteBotDB db) }
+getLastActiveQuote :: IRC.Channel -> Query QuoteDB (Maybe QuoteID)
+getLastActiveQuote channel = asks lastActive >>= return . M.lookup channel
+
setLastActiveQuote :: QuoteID -> IRC.Channel -> Update QuoteDB ()
setLastActiveQuote quoteId channel = get >>= \db -> put db { lastActive = M.insert channel quoteId (lastActive db)}
-$(makeAcidic ''QuoteDB ['getQuote, 'getQuoteDB, 'isQuoteLockedFor, 'lockQuoteIdFor, 'setLastActiveQuote, 'setQuote])
+$(makeAcidic ''QuoteDB [ 'getQuote, 'getQuoteDB, 'isQuoteLockedFor, 'lockQuoteIdFor, 'setQuote
+ , 'getLastActiveQuote, 'setLastActiveQuote ])
-- | gets a random quote from the database
getRandomQuote :: AcidState QuoteDB -> IO (Maybe Quote)