summaryrefslogtreecommitdiff
path: root/HsBot/IRC/User.hs
diff options
context:
space:
mode:
authorpb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157>2010-05-15 16:35:02 +0000
committerpb <pb@9f8f72e9-4bf4-416e-b76e-7d4203597157>2010-05-15 16:35:02 +0000
commitad2e856414300fafee5ab4afd4f2356b0c2fd159 (patch)
tree8a6fd6436771f4c1536b84f21ca8c5be632c0df8 /HsBot/IRC/User.hs
parent1d6e13ef4e50ae53c52b2ce289881a071ecf942e (diff)
implemented callback MessageCounter.
it counts each message a user has posted @ channel git-svn-id: https://ssl.buetow.org/repos/hsbot/trunk@59 9f8f72e9-4bf4-416e-b76e-7d4203597157
Diffstat (limited to 'HsBot/IRC/User.hs')
-rw-r--r--HsBot/IRC/User.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/HsBot/IRC/User.hs b/HsBot/IRC/User.hs
index 2569043..3c9bb3b 100644
--- a/HsBot/IRC/User.hs
+++ b/HsBot/IRC/User.hs
@@ -41,9 +41,19 @@ userGetIfExists name (x:xs)
| userName x == name = Just x
| otherwise = userGetIfExists name xs
+userDeleteIfExists :: String -> [User] -> [User]
+userDeleteIfExists name [] = []
+userDeleteIfExists name (x:xs)
+ | userName x == name = xs
+ | otherwise = x : userDeleteIfExists name xs
+
userGet :: String -> [User] -> (User, [User])
userGet name xs =
case userGetIfExists name xs of
- Just user -> (user, xs)
+ Just user -> (user, user : xs)
Nothing -> let user = userMakeDefault name in (user, user : xs)
+usersUpdate :: String -> [User] -> (User -> User) -> [User]
+usersUpdate name xs update =
+ let (user, _) = userGet name xs
+ in (update user) : (userDeleteIfExists name xs)