141 extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b) |
141 extractParameters p = let (a, b) = B.break (== ' ') p in (upperCase a, B.dropWhile (== ' ') b) |
142 |
142 |
143 handleCmd_loggedin ["MSG", nickMsg] = do |
143 handleCmd_loggedin ["MSG", nickMsg] = do |
144 thisCl <- thisClient |
144 thisCl <- thisClient |
145 thisNick <- clientNick |
145 thisNick <- clientNick |
146 clChans <- thisClientChans |
146 clChansProto <- thisClientChansProto |
147 let addEcho nick msg a = AnswerClients clChans ["CHAT", thisNick, B.concat ["/msg [", nick, "] ", msg]] : a |
147 let echoByProto nick msg p = if p < 60 then ["CHAT", thisNick, B.concat ["/msg [", nick, "] ", msg]] else ["MSG_ECHO", nick, msg] |
|
148 let addEcho nick msg a = AnswerClientsByProto clChansProto (echoByProto nick msg) : a |
148 let sendingMsgAllowed clientInfo = case allowMsgState clientInfo of |
149 let sendingMsgAllowed clientInfo = case allowMsgState clientInfo of |
149 AllowAll -> True |
150 AllowAll -> True |
150 AllowRegistered -> isRegistered thisCl |
151 AllowRegistered -> isRegistered thisCl |
151 AllowNone -> False |
152 AllowNone -> False |
|
153 let answerByProto msg p = if p < 60 then ["CHAT", thisNick, B.concat ["[direct] ", msg]] else ["MSG", thisNick, msg] |
152 let sendNickMsg nick msg = do |
154 let sendNickMsg nick msg = do |
153 (_, rnc) <- ask |
155 (_, rnc) <- ask |
154 maybeClientId <- clientByNick nick |
156 maybeClientId <- clientByNick nick |
155 case maybeClientId of |
157 case maybeClientId of |
156 Just cl -> let ci = client rnc cl in |
158 Just cl -> let ci = client rnc cl in |
157 if sendingMsgAllowed ci then |
159 if sendingMsgAllowed ci then |
158 return [AnswerClients [sendChan ci] |
160 return [AnswerClientsByProto [(sendChan ci, clientProto ci)] (answerByProto msg)] |
159 ["CHAT", thisNick, B.concat ["[direct] ", msg]]] |
|
160 else |
161 else |
161 return [Warning $ loc "Player is not allowing direct messages."] |
162 return [Warning $ loc "Player is not allowing direct messages."] |
162 Nothing -> return [Warning $ loc "Player is not online."] |
163 Nothing -> return [Warning $ loc "Player is not online."] |
163 |
164 |
164 case nickMsg =~ ("^[[:space:]]*\\[([^]\\[]*)\\][[:space:]]*(.*)$" :: B.ByteString) of |
165 case nickMsg =~ ("^[[:space:]]*\\[([^]\\[]*)\\][[:space:]]*(.*)$" :: B.ByteString) of |