85 h "GREETING" msg | not $ B.null msg = handleCmd ["GREETING", msg] |
85 h "GREETING" msg | not $ B.null msg = handleCmd ["GREETING", msg] |
86 h "CALLVOTE" msg | B.null msg = handleCmd ["CALLVOTE"] |
86 h "CALLVOTE" msg | B.null msg = handleCmd ["CALLVOTE"] |
87 | otherwise = let (c, p) = extractParameters msg in |
87 | otherwise = let (c, p) = extractParameters msg in |
88 if B.null p then handleCmd ["CALLVOTE", c] else handleCmd ["CALLVOTE", c, p] |
88 if B.null p then handleCmd ["CALLVOTE", c] else handleCmd ["CALLVOTE", c, p] |
89 h "VOTE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg] |
89 h "VOTE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg] |
|
90 | otherwise = handleCmd ["VOTE", ""] |
|
91 h "FORCE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg, "FORCE"] |
|
92 | otherwise = handleCmd ["VOTE", "", "FORCE"] |
|
93 h "VOTE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg] |
90 h "FORCE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg, "FORCE"] |
94 h "FORCE" msg | not $ B.null msg = handleCmd ["VOTE", upperCase msg, "FORCE"] |
91 h "MAXTEAMS" n | not $ B.null n = handleCmd ["MAXTEAMS", n] |
95 h "MAXTEAMS" n | not $ B.null n = handleCmd ["MAXTEAMS", n] |
92 h "INFO" n | not $ B.null n = handleCmd ["INFO", n] |
96 h "INFO" n | not $ B.null n = handleCmd ["INFO", n] |
93 h "HELP" _ = handleCmd ["HELP"] |
97 h "HELP" _ = handleCmd ["HELP"] |
94 h "RESTART_SERVER" "YES" = handleCmd ["RESTART_SERVER"] |
98 h "RESTART_SERVER" "YES" = handleCmd ["RESTART_SERVER"] |
97 return |
101 return |
98 [ModifyServerInfo(\s -> s{isRegisteredUsersOnly = not $ isRegisteredUsersOnly s}) |
102 [ModifyServerInfo(\s -> s{isRegisteredUsersOnly = not $ isRegisteredUsersOnly s}) |
99 , AnswerClients [sendChan cl] ["CHAT", "[server]", "'Registered only' state toggled"] |
103 , AnswerClients [sendChan cl] ["CHAT", "[server]", "'Registered only' state toggled"] |
100 ] |
104 ] |
101 h "SUPER_POWER" _ = serverAdminOnly $ return [ModifyClient (\c -> c{hasSuperPower = True})] |
105 h "SUPER_POWER" _ = serverAdminOnly $ return [ModifyClient (\c -> c{hasSuperPower = True})] |
102 h c p = return [Warning $ B.concat ["Unknown cmd: /", c, " ", p]] |
106 h c p = return [Warning $ B.concat [ loc "Unknown command:", " /", c, " ", p, "<br/>", loc "Say '/help' in chat for a list of commands" ]] |
|
107 |
103 |
108 |
104 extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b) |
109 extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b) |
105 |
110 |
106 handleCmd_loggedin ["INFO", asknick] = do |
111 handleCmd_loggedin ["INFO", asknick] = do |
107 (_, rnc) <- ask |
112 (_, rnc) <- ask |
112 let cl = rnc `client` fromJust maybeClientId |
117 let cl = rnc `client` fromJust maybeClientId |
113 let roomId = clientRoom rnc clientId |
118 let roomId = clientRoom rnc clientId |
114 let clRoom = room rnc roomId |
119 let clRoom = room rnc roomId |
115 let roomMasterSign = if isMaster cl then "+" else "" |
120 let roomMasterSign = if isMaster cl then "+" else "" |
116 let adminSign = if isAdministrator cl then "@" else "" |
121 let adminSign = if isAdministrator cl then "@" else "" |
117 let rInfo = if roomId /= lobbyId then B.concat [adminSign, roomMasterSign, "room ", name clRoom] else adminSign `B.append` "lobby" |
122 let rInfo = if roomId /= lobbyId then B.concat [adminSign, roomMasterSign, loc "room", " ", name clRoom] else adminSign `B.append` (loc "lobby") |
118 let roomStatus = if isJust $ gameInfo clRoom then |
123 let roomStatus = if isJust $ gameInfo clRoom then |
119 if teamsInGame cl > 0 then "(playing)" else "(spectating)" |
124 if teamsInGame cl > 0 then (loc "(playing)") else (loc "(spectating)") |
120 else |
125 else |
121 "" |
126 "" |
122 let hostStr = if isAdminAsking then host cl else B.empty |
127 let hostStr = if isAdminAsking then host cl else B.empty |
123 if noSuchClient then |
128 if noSuchClient then |
124 return [] |
129 answerClient [ "CHAT", "[server]", loc "Player is not online." ] |
125 else |
130 else |
126 answerClient [ |
131 answerClient [ |
127 "INFO", |
132 "INFO", |
128 nick cl, |
133 nick cl, |
129 B.concat ["[", hostStr, "]"], |
134 B.concat ["[", hostStr, "]"], |