- Implement BAN protocol command
authorunc0rr
Wed, 02 Feb 2011 22:19:10 +0300
changeset 4909 dc6482438674
parent 4908 99d6797b7ff4
child 4910 9dcb2e83b24f
- Implement BAN protocol command - Make BanClient handler call KickClient
gameServer/Actions.hs
gameServer/HWProtoLobbyState.hs
--- a/gameServer/Actions.hs	Wed Feb 02 22:14:00 2011 +0300
+++ b/gameServer/Actions.hs	Wed Feb 02 22:19:10 2011 +0300
@@ -366,7 +366,10 @@
     clHost <- client's host
     currentTime <- io $ getCurrentTime
     let msg = "Ban for " `B.append` (B.pack . show $ seconds) `B.append` "seconds (" `B.append` msg` B.append` ")"
-    processAction $ ModifyServerInfo (\s -> s{lastLogins = (clHost, (addUTCTime seconds $ currentTime, msg)) : lastLogins s})
+    mapM_ processAction [
+        ModifyServerInfo (\s -> s{lastLogins = (clHost, (addUTCTime seconds $ currentTime, msg)) : lastLogins s})
+        , KickClient banId
+        ]
 
 
 processAction (KickRoomClient kickId) = do
--- a/gameServer/HWProtoLobbyState.hs	Wed Feb 02 22:14:00 2011 +0300
+++ b/gameServer/HWProtoLobbyState.hs	Wed Feb 02 22:19:10 2011 +0300
@@ -139,15 +139,12 @@
     kickId <- clientByNick kickNick
     return [KickClient $ fromJust kickId | isAdministrator cl && isJust kickId && fromJust kickId /= ci]
 
-{-
-handleCmd_lobby clID clients rooms ["BAN", banNick] =
-    if not $ isAdministrator client then
-        []
-    else
-        BanClient banNick : handleCmd_lobby clID clients rooms ["KICK", banNick]
-    where
-        client = clients IntMap.! clID
-        -}
+
+handleCmd_lobby ["BAN", banNick, reason] = do
+    (ci, _) <- ask
+    cl <- thisClient
+    banId <- clientByNick banNick
+    return [BanClient 60 reason (fromJust banId) | isAdministrator cl && isJust banId && fromJust banId /= ci]
 
 
 handleCmd_lobby ["SET_SERVER_VAR", "MOTD_NEW", newMessage] = do