diff options
author | Julien Dessaux | 2011-10-01 00:31:23 +0200 |
---|---|---|
committer | Julien Dessaux | 2011-10-01 00:31:23 +0200 |
commit | 99462bfe9f9609e685175a22125b032780679c98 (patch) | |
tree | 4c73fa073948de59f46049339ddd8ec3e7fbfed7 /Hsbot/Plugin | |
parent | Fixed quote append. (diff) | |
download | hsbot-99462bfe9f9609e685175a22125b032780679c98.tar.gz hsbot-99462bfe9f9609e685175a22125b032780679c98.tar.bz2 hsbot-99462bfe9f9609e685175a22125b032780679c98.zip |
Fixed quote delete.
Diffstat (limited to 'Hsbot/Plugin')
-rw-r--r-- | Hsbot/Plugin/Quote.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Hsbot/Plugin/Quote.hs b/Hsbot/Plugin/Quote.hs index d022e85..af61114 100644 --- a/Hsbot/Plugin/Quote.hs +++ b/Hsbot/Plugin/Quote.hs @@ -166,8 +166,8 @@ theQuote = do ++ "If no QUOTEID is provided, tries to append to the last active quote." "quote":"help":"delete":_ -> do answerMsg msg "quote delete QUOTEID [ELTID] :" - answerMsg msg $ " If an ELTID is provided, deletes the ELTID's line (starting from zero) " - ++ "in the quote QUOTEID. If not the whole quote is deleted." + answerMsg msg $ " If an ELTID is provided, deletes the ELTID's line in the quote QUOTEID. " + ++ "If not the whole quote is deleted." "quote":"help":"start":_ -> do answerMsg msg "quote [start] QUOTEE [QUOTE] :" answerMsg msg $ " Begins a quote for QUOTEE. You must provide the keywork start if the " @@ -238,7 +238,7 @@ quoteDelete quoteDB msg quoteID = do case activeLock of Just True -> do _ <- update' quoteDB (DeleteQuote quoteID channel) - answerMsg msg $ sender ++ ": quote " ++ show quoteID ++ "." + answerMsg msg $ sender ++ ": deleted quote " ++ show quoteID ++ "." Just False -> answerMsg msg $ sender ++ ": Someone else is editing this quote right now." Nothing -> answerMsg msg $ sender ++ ":quoteId not found." where @@ -256,7 +256,7 @@ quoteDeleteElt quoteDB msg quoteID eltID = do let newQuote = fromMaybe emptyQuote mQuote newQuote' = newQuote { quotE = getRidOfEltFrom (quotE newQuote) } _ <- update' quoteDB (SetQuote quoteID newQuote') - answerMsg msg $ sender ++ ": Appended to quote " ++ show quoteID ++ "." + answerMsg msg $ sender ++ ": deleted element number " ++ show eltID ++ " from quote " ++ show quoteID ++ "." Just False -> answerMsg msg $ sender ++ ": Someone else is editing this quote right now." Nothing -> answerMsg msg $ sender ++ ": quoteId not found." where @@ -265,8 +265,8 @@ quoteDeleteElt quoteDB msg quoteID eltID = do getRidOfEltFrom :: [QuoteElt] -> [QuoteElt] getRidOfEltFrom elts | eltID <= 0 = elts - | eltID >= length elts = elts - | otherwise = let (l, r) = splitAt eltID elts + | eltID > length elts = elts + | otherwise = let (l, r) = splitAt (eltID -1) elts in l ++ tail r quoteShow :: AcidState QuoteDB -> IRC.Message -> QuoteID -> Quote -> Plugin (Env IO) () |