UNBAN implementation
authorunc0rr
Sat, 13 Oct 2012 00:07:46 +0400
changeset 7748 f160fbc139b1
parent 7747 8df97e271e5e
child 7749 edad8a7bcaea
UNBAN implementation
gameServer/Actions.hs
gameServer/HWProtoLobbyState.hs
--- a/gameServer/Actions.hs	Fri Oct 12 11:02:43 2012 +0200
+++ b/gameServer/Actions.hs	Sat Oct 13 00:07:46 2012 +0400
@@ -50,6 +50,7 @@
     | BanClient NominalDiffTime B.ByteString ClientIndex
     | BanIP B.ByteString NominalDiffTime B.ByteString
     | BanList
+    | Unban B.ByteString
     | ChangeMaster
     | RemoveClientTeams ClientIndex
     | ModifyClient (ClientInfo -> ClientInfo)
@@ -482,7 +483,11 @@
     processAction $
         AnswerClients [ch] ["BANLIST", bans]
 
-
+processAction (Unban entry) = do
+    processAction $ ModifyServerInfo (\s -> s{bans = filter f $ bans s})
+    where
+        f (BanByIP bip _ _) = bip == entry
+        f (BanByNick bn _ _) = bn == entry
 
 processAction (KickRoomClient kickId) = do
     modify (\s -> s{clientIndex = Just kickId})
--- a/gameServer/HWProtoLobbyState.hs	Fri Oct 12 11:02:43 2012 +0200
+++ b/gameServer/HWProtoLobbyState.hs	Sat Oct 13 00:07:46 2012 +0400
@@ -166,6 +166,12 @@
     return [BanList | isAdministrator cl]
 
 
+handleCmd_lobby ["UNBAN", entry] = do
+    (ci, _) <- ask
+    cl <- thisClient
+    return [Unban entry | isAdministrator cl]
+
+
 handleCmd_lobby ["SET_SERVER_VAR", "MOTD_NEW", newMessage] = do
     cl <- thisClient
     return [ModifyServerInfo (\si -> si{serverMessage = newMessage}) | isAdministrator cl]