summaryrefslogtreecommitdiff
path: root/HsBot/IRC
diff options
context:
space:
mode:
authorpb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157>2010-03-28 13:32:02 +0000
committerpb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157>2010-03-28 13:32:02 +0000
commiteb0ca70a636183fea73d884e20a48ac6120066bc (patch)
tree21ba24da99c38fd58a2758876a9bb39af94dc19c /HsBot/IRC
parent4f80cd186f21d9bb6fb3c0ae31e7626c21f531c6 (diff)
git-svn-id: https://ssl.buetow.org/repos/hsbot/trunk@54 9f8f72e9-4bf4-416e-b76e-7d4203597157
Diffstat (limited to 'HsBot/IRC')
-rw-r--r--HsBot/IRC/User.hs27
1 files changed, 26 insertions, 1 deletions
diff --git a/HsBot/IRC/User.hs b/HsBot/IRC/User.hs
index 422f910..375e55e 100644
--- a/HsBot/IRC/User.hs
+++ b/HsBot/IRC/User.hs
@@ -6,9 +6,18 @@ import HsBot.General.Render
data User = User {
userName :: String,
+ userMessages :: Int,
userPts :: Int
} deriving (Show, Read)
+userMakeDefault :: String -> User
+userMakeDefault name =
+ User {
+ userName = name,
+ userMessages = 0,
+ userPts = 0
+ }
+
instance Eq User where
x == y = (userPts x) == (userPts y)
@@ -20,8 +29,24 @@ instance Ord User where
instance Render User where
render user = userName user ++ ": " ++
- (show $ userPts user) ++ "pts"
+ (show $ userPts user) ++ "pts; " ++
+ (show $ userMessages user) ++ "msgs"
userEquals :: User -> User -> Bool
userEquals x y = (userName x) == (userName y)
+userGetIfExists :: String -> [User] -> Maybe User
+userGetIfExists name [] = Nothing
+userGetIfExists name (x:xs)
+ | userName x == name = Just x
+ | otherwise = userGetIfExists name xs
+
+userGet :: String -> [User] -> (User, [User])
+userGet name xs =
+ case userGetIfExists name xs of
+ Just user -> (user, xs)
+ Nothing -> let user = userMakeDefault name in (user, user : xs)
+
+
+
+