equal
deleted
inserted
replaced
4 import qualified Data.Map as Map |
4 import qualified Data.Map as Map |
5 import qualified Data.Foldable as Foldable |
5 import qualified Data.Foldable as Foldable |
6 import Data.Maybe |
6 import Data.Maybe |
7 import Data.List |
7 import Data.List |
8 import Control.Monad.Reader |
8 import Control.Monad.Reader |
|
9 import qualified Data.ByteString.Char8 as B |
9 -------------------------------------- |
10 -------------------------------------- |
10 import CoreTypes |
11 import CoreTypes |
11 import Actions |
12 import Actions |
12 import Utils |
13 import Utils |
13 import HandlerUtils |
14 import HandlerUtils |
67 let jRI = fromJust maybeRI |
68 let jRI = fromJust maybeRI |
68 let jRoom = irnc `room` jRI |
69 let jRoom = irnc `room` jRI |
69 let sameProto = clientProto cl == roomProto jRoom |
70 let sameProto = clientProto cl == roomProto jRoom |
70 let jRoomClients = map (client irnc) $ roomClients irnc jRI |
71 let jRoomClients = map (client irnc) $ roomClients irnc jRI |
71 let nicks = map nick jRoomClients |
72 let nicks = map nick jRoomClients |
|
73 let ownerNick = nick . fromJust $ find isMaster jRoomClients |
72 let chans = map sendChan (cl : jRoomClients) |
74 let chans = map sendChan (cl : jRoomClients) |
73 let isBanned = host cl `elem` roomBansList jRoom |
75 let isBanned = host cl `elem` roomBansList jRoom |
74 return $ |
76 return $ |
75 if isNothing maybeRI || not sameProto then |
77 if isNothing maybeRI || not sameProto then |
76 [Warning "No such room"] |
78 [Warning "No such room"] |
80 [Warning "You are banned in this room"] |
82 [Warning "You are banned in this room"] |
81 else if roomPassword /= password jRoom then |
83 else if roomPassword /= password jRoom then |
82 [NoticeMessage WrongPassword] |
84 [NoticeMessage WrongPassword] |
83 else |
85 else |
84 [ |
86 [ |
85 MoveToRoom jRI, |
87 MoveToRoom jRI |
86 AnswerClients [sendChan cl] $ "JOINED" : nicks, |
88 , AnswerClients [sendChan cl] $ "JOINED" : nicks |
87 AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl] |
89 , AnswerClients chans ["CLIENT_FLAGS", "-r", nick cl] |
|
90 , AnswerClients [sendChan cl] $ ["WARNING", "Room admin is " `B.append` ownerNick] |
|
91 , AnswerClients [sendChan cl] $ ["CLIENT_FLAGS", "+h", ownerNick] |
88 ] |
92 ] |
89 ++ map (readynessMessage cl) jRoomClients |
93 ++ map (readynessMessage cl) jRoomClients |
90 ++ answerFullConfig cl (mapParams jRoom) (params jRoom) |
94 ++ answerFullConfig cl (mapParams jRoom) (params jRoom) |
91 ++ answerTeams cl jRoom |
95 ++ answerTeams cl jRoom |
92 ++ watchRound cl jRoom |
96 ++ watchRound cl jRoom |