454 , ModifyClient (\c -> c{webPassword = p, isAdministrator = a, isContributor = contr}) |
454 , ModifyClient (\c -> c{webPassword = p, isAdministrator = a, isContributor = contr}) |
455 ] |
455 ] |
456 |
456 |
457 processAction JoinLobby = do |
457 processAction JoinLobby = do |
458 chan <- client's sendChan |
458 chan <- client's sendChan |
|
459 rnc <- gets roomsClients |
459 clientNick <- client's nick |
460 clientNick <- client's nick |
460 isAuthenticated <- liftM (not . B.null) $ client's webPassword |
461 isAuthenticated <- liftM (not . B.null) $ client's webPassword |
461 isAdmin <- client's isAdministrator |
462 isAdmin <- client's isAdministrator |
462 isContr <- client's isContributor |
463 isContr <- client's isContributor |
463 loggedInClients <- liftM (Prelude.filter isVisible) $! allClientsS |
464 loggedInClients <- liftM (Prelude.filter isVisible) $! allClientsS |
464 let (lobbyNicks, clientsChans) = unzip . L.map (nick &&& sendChan) $ loggedInClients |
465 let (lobbyNicks, clientsChans) = unzip . L.map (nick &&& sendChan) $ loggedInClients |
465 let authenticatedNicks = L.map nick . L.filter (not . B.null . webPassword) $ loggedInClients |
466 let authenticatedNicks = L.map nick . L.filter (not . B.null . webPassword) $ loggedInClients |
466 let adminsNicks = L.map nick . L.filter isAdministrator $ loggedInClients |
467 let adminsNicks = L.map nick . L.filter isAdministrator $ loggedInClients |
467 let contrNicks = L.map nick . L.filter isContributor $ loggedInClients |
468 let contrNicks = L.map nick . L.filter isContributor $ loggedInClients |
|
469 inRoomNicks <- io $ |
|
470 allClientsM rnc |
|
471 >>= filterM (liftM ((/=) lobbyId) . clientRoomM rnc) |
|
472 >>= mapM (client'sM rnc nick) |
468 let clFlags = B.concat . L.concat $ [["u" | isAuthenticated], ["a" | isAdmin], ["c" | isContr]] |
473 let clFlags = B.concat . L.concat $ [["u" | isAuthenticated], ["a" | isAdmin], ["c" | isContr]] |
469 mapM_ processAction . concat $ [ |
474 mapM_ processAction . concat $ [ |
470 [AnswerClients clientsChans ["LOBBY:JOINED", clientNick]] |
475 [AnswerClients clientsChans ["LOBBY:JOINED", clientNick]] |
471 , [AnswerClients [chan] ("LOBBY:JOINED" : clientNick : lobbyNicks)] |
476 , [AnswerClients [chan] ("LOBBY:JOINED" : clientNick : lobbyNicks)] |
472 , [AnswerClients [chan] ("CLIENT_FLAGS" : "+u" : authenticatedNicks) | not $ null authenticatedNicks] |
477 , [AnswerClients [chan] ("CLIENT_FLAGS" : "+u" : authenticatedNicks) | not $ null authenticatedNicks] |
473 , [AnswerClients [chan] ("CLIENT_FLAGS" : "+a" : adminsNicks) | not $ null adminsNicks] |
478 , [AnswerClients [chan] ("CLIENT_FLAGS" : "+a" : adminsNicks) | not $ null adminsNicks] |
474 , [AnswerClients [chan] ("CLIENT_FLAGS" : "+c" : contrNicks) | not $ null contrNicks] |
479 , [AnswerClients [chan] ("CLIENT_FLAGS" : "+c" : contrNicks) | not $ null contrNicks] |
|
480 , [AnswerClients [chan] ("CLIENT_FLAGS" : "+i" : inRoomNicks) | not $ null inRoomNicks] |
475 , [AnswerClients (chan : clientsChans) ["CLIENT_FLAGS", B.concat["+" , clFlags], clientNick] | not $ B.null clFlags] |
481 , [AnswerClients (chan : clientsChans) ["CLIENT_FLAGS", B.concat["+" , clFlags], clientNick] | not $ B.null clFlags] |
476 , [ModifyClient (\cl -> cl{logonPassed = True, isVisible = True})] |
482 , [ModifyClient (\cl -> cl{logonPassed = True, isVisible = True})] |
477 , [SendServerMessage] |
483 , [SendServerMessage] |
478 ] |
484 ] |
479 |
485 |