summaryrefslogtreecommitdiff
path: root/Hsbot/Plugin
diff options
context:
space:
mode:
authorJulien Dessaux2011-05-17 00:21:31 +0200
committerJulien Dessaux2011-05-17 00:21:31 +0200
commitdfba882e1acbefebdd051d04cb2722405e55e257 (patch)
tree009b7c172b084d688ab19f4099e1352efb6c7e6e /Hsbot/Plugin
parentFixed inconsistencies in the duck module. (diff)
downloadhsbot-dfba882e1acbefebdd051d04cb2722405e55e257.tar.gz
hsbot-dfba882e1acbefebdd051d04cb2722405e55e257.tar.bz2
hsbot-dfba882e1acbefebdd051d04cb2722405e55e257.zip
Wrote the quote module data structures.
Diffstat (limited to 'Hsbot/Plugin')
-rw-r--r--Hsbot/Plugin/Quote.hs47
1 files changed, 47 insertions, 0 deletions
diff --git a/Hsbot/Plugin/Quote.hs b/Hsbot/Plugin/Quote.hs
new file mode 100644
index 0000000..adfcd24
--- /dev/null
+++ b/Hsbot/Plugin/Quote.hs
@@ -0,0 +1,47 @@
+{-# LANGUAGE TypeFamilies, DeriveDataTypeable, TemplateHaskell #-}
+-- | This module is an IRC plugin that manages quotes for posterity and legend
+module Hsbot.Plugin.Quote
+ () where
+
+import qualified Data.Map as M
+import Data.SafeCopy
+import Data.Typeable
+import System.Time
+
+import Hsbot.Message
+import Hsbot.Types
+import Hsbot.Utils
+
+-- | A quote element
+data QuoteElt = QuoteElt
+ { eltQuotee :: String
+ , eltQuote :: String
+ } deriving (Show, Typeable)
+
+-- | A quote object
+data Quote = Quote
+ { quoter :: String
+ , quote :: [QuoteElt]
+ , quoteTime :: ClockTime
+ , votes :: Int
+ , voters :: M.Map String Int
+ } deriving (Show, Typeable)
+
+emptyQuote :: Quote
+emptyQuote = Quote { quoter = ""
+ , quote = []
+ , quoteTime = TOD 0 0
+ , votes = 0
+ , voters = M.empty }
+
+-- The Quote database
+data QuoteDB = QuoteDB
+ { nextQuoteId :: Int
+ , quoteBotDB :: M.Map Int Quote
+ , lockedQuotes :: M.Map Int (String, ClockTime)
+ } deriving (Show, Typeable)
+
+$(deriveSafeCopy 0 'base ''QuoteElt)
+$(deriveSafeCopy 0 'base ''Quote)
+$(deriveSafeCopy 0 'base ''QuoteDB)
+