242 ri <- clientRoomA |
242 ri <- clientRoomA |
243 rnc <- gets roomsClients |
243 rnc <- gets roomsClients |
244 newMasterId <- liftM (head . filter (/= ci)) . io $ roomClientsIndicesM rnc ri |
244 newMasterId <- liftM (head . filter (/= ci)) . io $ roomClientsIndicesM rnc ri |
245 newMaster <- io $ client'sM rnc id newMasterId |
245 newMaster <- io $ client'sM rnc id newMasterId |
246 oldRoomName <- io $ room'sM rnc name ri |
246 oldRoomName <- io $ room'sM rnc name ri |
|
247 oldMaster <- client's nick |
|
248 thisRoomChans <- liftM (map sendChan) $ roomClientsS ri |
247 let newRoomName = nick newMaster |
249 let newRoomName = nick newMaster |
248 mapM_ processAction [ |
250 mapM_ processAction [ |
249 ModifyRoom (\r -> r{masterID = newMasterId, name = newRoomName}), |
251 ModifyRoom (\r -> r{masterID = newMasterId, name = newRoomName, isRestrictedJoins = False, isRestrictedTeams = False}) |
250 ModifyClient2 newMasterId (\c -> c{isMaster = True}), |
252 , ModifyClient2 newMasterId (\c -> c{isMaster = True}) |
251 AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"] |
253 , AnswerClients [sendChan newMaster] ["ROOM_CONTROL_ACCESS", "1"] |
|
254 , AnswerClients thisRoomChans ["WARNING", "New room admin is " `B.append` nick newMaster] |
|
255 , AnswerClients thisRoomChans ["CLIENT_FLAGS", "-h", oldMaster] |
|
256 , AnswerClients thisRoomChans ["CLIENT_FLAGS", "+h", nick newMaster] |
252 ] |
257 ] |
253 |
258 |
254 proto <- client's clientProto |
259 proto <- client's clientProto |
255 newRoom <- io $ room'sM rnc id ri |
260 newRoom <- io $ room'sM rnc id ri |
256 chans <- liftM (map sendChan) $! sameProtoClientsS proto |
261 chans <- liftM (map sendChan) $! sameProtoClientsS proto |
260 processAction (AddRoom roomName roomPassword) = do |
265 processAction (AddRoom roomName roomPassword) = do |
261 Just clId <- gets clientIndex |
266 Just clId <- gets clientIndex |
262 rnc <- gets roomsClients |
267 rnc <- gets roomsClients |
263 proto <- client's clientProto |
268 proto <- client's clientProto |
264 n <- client's nick |
269 n <- client's nick |
|
270 chan <- client's sendChan |
265 |
271 |
266 let rm = newRoom{ |
272 let rm = newRoom{ |
267 masterID = clId, |
273 masterID = clId, |
268 name = roomName, |
274 name = roomName, |
269 password = roomPassword, |
275 password = roomPassword, |
276 |
282 |
277 chans <- liftM (map sendChan) $! sameProtoClientsS proto |
283 chans <- liftM (map sendChan) $! sameProtoClientsS proto |
278 |
284 |
279 mapM_ processAction [ |
285 mapM_ processAction [ |
280 AnswerClients chans ("ROOM" : "ADD" : roomInfo n rm) |
286 AnswerClients chans ("ROOM" : "ADD" : roomInfo n rm) |
|
287 , AnswerClients [chan] ["CLIENT_FLAGS", "+h", n] |
281 , ModifyClient (\cl -> cl{isMaster = True}) |
288 , ModifyClient (\cl -> cl{isMaster = True}) |
282 ] |
289 ] |
283 |
290 |
284 |
291 |
285 processAction RemoveRoom = do |
292 processAction RemoveRoom = do |