diff options
author | Julien Dessaux | 2011-09-18 23:34:13 +0200 |
---|---|---|
committer | Julien Dessaux | 2011-09-18 23:34:13 +0200 |
commit | 2d97af231e4b8c1e2f6b46f4b2783571bf2511d4 (patch) | |
tree | 23d87c71da17651372e6e799b4123625c6b46c32 | |
parent | Added the getLastActiveQuote transaction. (diff) | |
download | hsbot-2d97af231e4b8c1e2f6b46f4b2783571bf2511d4.tar.gz hsbot-2d97af231e4b8c1e2f6b46f4b2783571bf2511d4.tar.bz2 hsbot-2d97af231e4b8c1e2f6b46f4b2783571bf2511d4.zip |
Finished the quote append function.
-rw-r--r-- | Hsbot/Plugin/Quote.hs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Hsbot/Plugin/Quote.hs b/Hsbot/Plugin/Quote.hs index 9c253ed..2736157 100644 --- a/Hsbot/Plugin/Quote.hs +++ b/Hsbot/Plugin/Quote.hs @@ -130,7 +130,11 @@ theQuote = do "quote":"append":quoteID:quotee:quoteTxt -> case reads quoteID :: [(Int, String)] of (qid,_):_ -> quoteAppend quoteDB msg qid quotee $ unwords quoteTxt - _ -> answerMsg msg "Invalid quoteID." -- TODO : try with the last active one + _ -> do + lastQid <- query' quoteDB (GetLastActiveQuote (getChannel msg)) + case lastQid of + Just qid -> quoteAppend quoteDB msg qid quotee . unwords $ quoteID : quoteTxt + Nothing -> answerMsg msg $ getSender msg ++ " : Invalid quoteID." "quote":"help":"append":_ -> answerMsg msg $ "quote append [QUOTEID] QUOTEE QUOTE" ++ "If no QUOTEID is provided, tries to append to the last active quote." "quote":"help":"delete":_ -> do @@ -175,7 +179,7 @@ quoteAppend quoteDB msg quoteID quotee text = do newQuote' = newQuote { quotE = quotE newQuote ++ [ QuoteElt { eltQuotee = quotee, eltQuote = text } ] } _ <- update' quoteDB (SetQuote quoteID newQuote') _ <- update' quoteDB (SetLastActiveQuote quoteID (getChannel msg)) - return () + answerMsg msg $ sender ++ ": Appended to quote " ++ show quoteID Just False -> answerMsg msg $ sender ++ ": Someone else is editing this quote right now." Nothing -> answerMsg msg $ sender ++ ":quoteId not found." where |