Пример #1
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsSession || !target.IsRoom || target.Session.Account == null || !(target.Room is MafiaRoom))
                return;

            var room = (MafiaRoom)target.Room;

            if (room.IsPlaying)
            {
                target.Send("A game is currently in progress. You must wait until it has finished to join.");
                return;
            }

            if (parameters.Length < 1)
            {
                target.Send("You must specify an alias to join the game: /join Brian");
                return;
            }

            if (!Util.IsValidUsername(parameters[0]))
            {
                target.Send(Util.InvalidUsernameMessage);
                return;
            }

            // TODO: add to game
        }
Пример #2
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !Util.IsMod(target) || parameters.Length == 0)
                return;

            if (!Util.IsValidUsername(parameters[0]))
            {
                target.Send("Invalid username.");
                return;
            }

            if (!Account.Exists(parameters[0]))
            {
                target.Send("Account does not exist.");
                return;
            }

            if (Util.IsAdmin(target.Room, parameters[0]))
            {
                target.Send("Administrators can not be banned.");
                return;
            }

            if (!target.Room.IsWhitelisted)
                target.Room.Unban(parameters[0]);
            else
                target.Room.Ban(parameters[0]);

            target.Send("Account unbanned.");
        }
Пример #3
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!Util.IsSuperAdmin(target) || parameters.Length == 0)
            {
                return;
            }

            if (!Util.IsValidUsername(parameters[0]))
            {
                target.Send("Invalid username.");
                return;
            }

            var session = Program.SessionManager.Get(parameters[0]);

            if (session == null)
            {
                target.Send("Session does not exist.");
                return;
            }

            var connectionCount = session.ConnectionCount;

            session.Destroy();

            target.Send($"Kicked session ({connectionCount} connections).");
        }
Пример #4
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !Util.IsMod(target) || parameters.Length == 0)
                return;

            if (!Util.IsValidUsername(parameters[0]))
            {
                target.Send("Invalid username.");
                return;
            }

            if (!Account.Exists(parameters[0]))
            {
                target.Send("Account does not exist.");
                return;
            }

            if (Util.IsAdmin(target.Room, parameters[0]))
            {
                target.Send("Administrators can not be banned.");
                return;
            }

            string sourceUser;
            if (target.IsWeb)
                sourceUser = target.Connection.Session.Account.Name;
            else
                sourceUser = string.Format("steam:{0:D}", (ulong)target.SteamId);

            Program.Logger.InfoFormat("User '{0}' unbanning '{1}'", sourceUser, parameters[0]);

            target.Room.Unban(parameters[0]);
            target.Send("Account unbanned.");
        }
Пример #5
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !Util.IsAdmin(target) || parameters.Length == 0)
            {
                return;
            }

            if (!Util.IsValidUsername(parameters[0]))
            {
                target.Send("Invalid username.");
                return;
            }

            if (!Account.Exists(parameters[0]))
            {
                target.Send("Account does not exist.");
                return;
            }

            if (target.Room.IsMod(parameters[0]))
            {
                target.Send("Account is already a mod.");
                return;
            }

            target.Room.Mod(parameters[0]);
            target.Send("Account modded.");
        }
Пример #6
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !Util.IsMod(target))
            {
                return;
            }

            var banned = target.Room.Banned;

            banned = banned.OrderBy(s => s).ToList();

            if (banned.Count == 0)
            {
                if (!target.Room.IsWhitelisted)
                {
                    target.Send("Nobody is banned.");
                }
                else
                {
                    target.Send("Everybody is banned.");
                }
            }
            else
            {
                if (!target.Room.IsWhitelisted)
                {
                    target.Send(string.Format("Banned: {0}", string.Join(", ", banned)));
                }
                else
                {
                    target.Send(string.Format("Whitelisted: {0}", string.Join(", ", banned)));
                }
            }
        }
Пример #7
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !Util.IsAdmin(target) || parameters.Length == 0)
                return;

            if (!Util.IsValidUsername(parameters[0]))
            {
                target.Send("Invalid username.");
                return;
            }

            if (!Account.Exists(parameters[0]))
            {
                target.Send("Account does not exist.");
                return;
            }

            if (!target.Room.IsMod(parameters[0]))
            {
                target.Send("Account is not a mod.");
                return;
            }

            target.Room.Demod(parameters[0]);
            target.Send("Account demodded.");
        }
Пример #8
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsSession || target.Session.Account == null)
                return;

            if (parameters.Length < 1)
            {
                target.Send("Currently in room: " + target.Session.Room);
                return;
            }

            if (Program.DelayManager.AddAndCheck(target.Session, 2.5))
                return;

            switch (parameters[0])
            {
                case "default":
                    {
                        var defaultRoom = target.Session.Account.DefaultRoom;
                        var newRoom = parameters.Length < 2 ? defaultRoom : parameters[1];

                        if (!target.Session.SwitchRoom(newRoom))
                            break;

                        if (parameters.Length >= 2)
                        {
                            target.Session.Account.DefaultRoom = target.Session.Room;
                            target.Session.Account.Save();
                        }

                        target.Send("Switched to room: " + newRoom);
                        break;
                    }

                case "list":
                    {
                        var roomNames = Program.RoomManager.List
                            .Where(r => !r.IsHidden)
                            .Select(r => r.RoomInfo)
                            .Select(r => string.Format("{0} ({1})", r.Name, r.ShortName));
                        target.Send("Available rooms: " + string.Join(", ", roomNames));
                        break;
                    }

                default:
                    {
                        if (!target.Session.SwitchRoom(parameters[0]))
                            break;

                        target.Send("Switched to room: " + parameters[0]);
                        break;
                    }
            }
        }
Пример #9
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom && !target.IsPrivateChat)
            {
                target.Send("RohBot is not in this room.");
                return;
            }

            if (target.IsSession)
            {
                var roomName = target.Session.Room;
                var room = target.Room;

                var steamRoom = room as SteamRoom;
                var userList = new Packets.UserList();
                var chat = Program.Steam.Status == Steam.ConnectionStatus.Connected && steamRoom != null ? steamRoom.Chat : null;
                var steamUsers = chat != null ? chat.Members.ToList() : new List<SteamID>();
                var sessions = Program.SessionManager.List.Where(s => s.Account != null).ToList();

                foreach (var id in steamUsers.Where(i => i != Program.Steam.Bot.PersonaId))
                {
                    var persona = Program.Steam.Bot.GetPersona(id);
                    var steamId = id.ConvertToUInt64().ToString("D");
                    var groupMember = chat.Group.Members.FirstOrDefault(m => m.Id == id);
                    var rank = groupMember != null ? groupMember.Rank.ToString() : "Member";
                    var avatar = BitConverter.ToString(persona.Avatar).Replace("-", "").ToLower();
                    userList.AddUser(persona.Name, steamId, rank, avatar, persona.PlayingName, false);
                }

                var accounts = sessions.Where(s => s.Room == roomName).Select(s => s.Account).Distinct(new Account.Comparer());

                foreach (var account in accounts)
                {
                    var userId = account.Id.ToString();
                    var rank = Util.GetRank(target.Room, account.Name).ToString();
                    userList.AddUser(account.Name, userId, rank, "", "", true);
                }

                userList.Users = userList.Users.OrderBy(u => u.Name).ToList();
                target.Session.Send(userList);
            }
            else
            {
                var roomName = target.Room.RoomInfo.ShortName;
                var sessions = Program.SessionManager.List.Where(s => s.Account != null).ToList();
                var accounts = sessions.Where(s => s.Room == roomName).Select(s => s.Account).Distinct(new Account.Comparer());
                target.Send("In this room: " + string.Join(", ", accounts.Select(a => a.Name)));
            }
        }
Пример #10
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsWeb || !target.IsRoom || parameters.Length == 0)
                return;

            if (Program.DelayManager.AddAndCheck(target.Connection, DelayManager.Message))
                return;

            var username = target.Connection.Session.Account.Name;
            var room = target.Room;
            if (room.IsBanned(username))
            {
                target.Send("You are banned from this room.");
                return;
            }

            var line = new StateLine(
                Util.GetCurrentTimestamp(),
                target.Room.RoomInfo.ShortName,
                "Action",
                username,
                target.Connection.Session.Account.Id.ToString("D"),
                "RohBot",
                "", "0", "",
                string.Format("{0} {1}", username, parameters[0]));

            target.Room.SendLine(line);
        }
Пример #11
0
 public override void Handle(CommandTarget target, string type, string[] parameters)
 {
     if (target.IsWeb || target.IsPrivateChat)
     {
         target.Send("Unknown command.");
     }
 }
Пример #12
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsWeb || !target.IsRoom || parameters.Length == 0)
            {
                return;
            }

            if (Program.DelayManager.AddAndCheck(target.Connection, DelayManager.Message))
            {
                return;
            }

            var username = target.Connection.Session.Account.Name;
            var room     = target.Room;

            if (room.IsBanned(username))
            {
                target.Send("You are banned from this room.");
                return;
            }

            var line = new StateLine(
                Util.GetCurrentTimestamp(),
                target.Room.RoomInfo.ShortName,
                "Action",
                username,
                target.Connection.Session.Account.Id.ToString("D"),
                "RohBot",
                "", "0", "",
                string.Format("{0} hugs {1}.", username, parameters[0]));

            target.Room.SendLine(line);
        }
Пример #13
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || target.IsPrivateChat)
            {
                return;
            }

            var room     = target.Room;
            var roomName = room.RoomInfo.ShortName;

            var sessions = Program.SessionManager.List;
            var accounts = sessions.Where(s => s.IsInRoom(roomName))
                           .Select(s => s.Account)
                           .Distinct(new Account.Comparer());

            if (target.IsWeb)
            {
                var userList = new Packets.UserList();

                var steamRoom = room as SteamRoom;
                var chat      = steamRoom != null && Program.Steam.Status == Steam.ConnectionStatus.Connected ? steamRoom.Chat : null;

                if (chat != null)
                {
                    var steamUsers = chat.Users.Select(p => p.Id)
                                     .Where(i => i != Program.Steam.Bot.SteamId);

                    foreach (var id in steamUsers)
                    {
                        var persona     = Program.Steam.Bot.GetPersona(id);
                        var steamId     = id.ConvertToUInt64().ToString("D");
                        var groupMember = chat.Group.Members.FirstOrDefault(m => m.Persona.Id == id);
                        var rank        = groupMember != null?GetRankString(groupMember.Rank) : "Guest";

                        var avatar = BitConverter.ToString(persona.Avatar).Replace("-", "").ToLower();
                        var status = GetStatusString(persona.State);
                        userList.AddUser(persona.DisplayName, steamId, rank, avatar, status, persona.PlayingName, false);
                    }
                }

                foreach (var account in accounts)
                {
                    var userId = account.Id.ToString("D");
                    var rank   = GetRankString(target.Room, account.Name);
                    userList.AddUser(account.Name, userId, rank, "", "", null, true);
                }

                userList.ShortName = roomName;
                userList.Users     = userList.Users.OrderBy(u => u.Name, StringComparer.InvariantCultureIgnoreCase).ToList();
                target.Connection.Send(userList);
            }
            else
            {
                var names = accounts.OrderBy(a => a.Name, StringComparer.InvariantCultureIgnoreCase)
                            .Select(a => a.Name);

                target.Send("In this room: " + string.Join(", ", names));
            }
        }
Пример #14
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!Util.IsSuperAdmin(target))
                return;

            var sessions = Program.SessionManager.List.Select(s => string.Format("{0} ({1})", s.Account.Name, s.ConnectionCount));
            var sessionsText = string.Join(", ", sessions);
            target.Send(string.Format("Active sessions: {0}", sessionsText));
        }
Пример #15
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsWeb || !Util.IsSuperAdmin(target))
                return;

            var sessions = Program.SessionManager.List.Select(s => $"{s.Account.Name} ({s.ConnectionCount})");
            var sessionsText = string.Join(", ", sessions);
            target.Send($"Sessions: {sessionsText}");
        }
Пример #16
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || target.IsPrivateChat)
                return;

            var room = target.Room;
            var roomName = room.RoomInfo.ShortName;

            var sessions = Program.SessionManager.List;
            var accounts = sessions.Where(s => s.IsInRoom(roomName))
                                   .Select(s => s.Account)
                                   .Distinct(new Account.Comparer());

            if (target.IsWeb)
            {
                var userList = new Packets.UserList();

                var steamRoom = room as SteamRoom;
                var chat = steamRoom != null && Program.Steam.Status == Steam.ConnectionStatus.Connected ? steamRoom.Chat : null;

                if (chat != null)
                {
                    var steamUsers = chat.Users.Select(p => p.Id)
                                               .Where(i => i != Program.Steam.Bot.SteamId);

                    foreach (var id in steamUsers)
                    {
                        var persona = Program.Steam.Bot.GetPersona(id);
                        var steamId = id.ConvertToUInt64().ToString("D");
                        var groupMember = chat.Group.Members.FirstOrDefault(m => m.Persona.Id == id);
                        var rank = groupMember != null ? GetRankString(groupMember.Rank) : "Guest";
                        var avatar = BitConverter.ToString(persona.Avatar).Replace("-", "").ToLower();
                        var status = GetStatusString(persona.State);
                        userList.AddUser(persona.DisplayName, steamId, rank, avatar, status, persona.PlayingName, false);
                    }
                }

                foreach (var account in accounts)
                {
                    var userId = account.Id.ToString("D");
                    var rank = GetRankString(target.Room, account.Name);
                    userList.AddUser(account.Name, userId, rank, "", "", null, true);
                }

                userList.ShortName = roomName;
                userList.Users = userList.Users.OrderBy(u => u.Name, StringComparer.InvariantCultureIgnoreCase).ToList();
                target.Connection.Send(userList);
            }
            else
            {
                var names = accounts.OrderBy(a => a.Name, StringComparer.InvariantCultureIgnoreCase)
                                    .Select(a => a.Name);

                target.Send("In this room: " + string.Join(", ", names));
            }
        }
Пример #17
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsWeb || parameters.Length == 0)
                return;

            if (Program.DelayManager.AddAndCheck(target.Connection, DelayManager.Database))
                return;

            if (!target.Connection.Session.Join(parameters[0]))
                target.Send("Room does not exist.");
        }
Пример #18
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom)
                return;

            var modded = target.Room.Modded;
            modded.Add(target.Room.RoomInfo.Admin.ToLower());
            modded = modded.OrderBy(n => n).ToList();

            target.Send(string.Format("Mods for this room: {0}", string.Join(", ", modded)));
        }
Пример #19
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsWeb || Program.DelayManager.AddAndCheck(target.Connection, DelayManager.Database))
            {
                return;
            }

            var userId = target.Connection.Session.Account.Id;

            if (parameters.Length == 1 && parameters[0] == "clear")
            {
                LoginToken.RemoveAll(userId);
                target.Send("Cleared all logins.");
                return;
            }

            var loginTokens = LoginToken.FindAll(userId).ToList();

            if (loginTokens.Count == 0)
            {
                target.Send("No active logins.");
                return;
            }

            var sb = new StringBuilder();

            sb.AppendLine("Active logins:");

            foreach (var login in loginTokens)
            {
                var address  = login.Address;
                var ua       = UserAgentParser.Parse(login.UserAgent);
                var created  = Util.DateTimeFromTimestamp(login.Created);
                var accessed = Util.DateTimeFromTimestamp(login.Accessed);

                sb.AppendFormat("{0} - {1} (created {2}, last accessed {3})", address, ua, created, accessed);
                sb.AppendLine();
            }

            target.Send(sb.ToString().Trim());
        }
Пример #20
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            var sessions = Program.SessionManager.List.Where(s => s.Account != null).Select(s => s.Account.Name).ToList();
            var req = sessions.Distinct().Select(n =>
            {
                var count = sessions.Count(s => s == n);
                return n + (count > 1 ? string.Format(" ({0})", count) : "");
            });

            var msg = "Active sessions: " + string.Join(", ", req);
            target.Send(msg);
        }
Пример #21
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsWeb || !Util.IsSuperAdmin(target))
            {
                return;
            }

            var sessions     = Program.SessionManager.List.Select(s => string.Format("{0} ({1})", s.Account.Name, s.ConnectionCount));
            var sessionsText = string.Join(", ", sessions);

            target.Send(string.Format("Sessions: {0}", sessionsText));
        }
Пример #22
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !Util.IsMod(target))
            {
                return;
            }

            var modded = target.Room.Modded;

            modded.Add(target.Room.RoomInfo.Admin.ToLower());
            modded = modded.OrderBy(n => n).ToList();

            target.Send($"Mods for this room: {string.Join(", ", modded)}");
        }
Пример #23
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!Util.IsSuperAdmin(target) || parameters.Length == 0)
                return;

            if (!Util.IsValidUsername(parameters[0]))
            {
                target.Send("Invalid username.");
                return;
            }

            var session = Program.SessionManager.Get(parameters[0]);
            if (session == null)
            {
                target.Send("Session does not exist.");
                return;
            }

            var connectionCount = session.ConnectionCount;
            session.Destroy();

            target.Send(string.Format("Kicked session ({0} connections).", connectionCount));
        }
Пример #24
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !Util.IsMod(target))
                return;

            var banned = target.Room.Banned;
            banned = banned.OrderBy(s => s).ToList();

            if (banned.Count == 0)
            {
                if (!target.Room.IsWhitelisted)
                    target.Send("Nobody is banned.");
                else
                    target.Send("Everybody is banned.");
            }
            else
            {
                if (!target.Room.IsWhitelisted)
                    target.Send(string.Format("Banned: {0}", string.Join(", ", banned)));
                else
                    target.Send(string.Format("Whitelisted: {0}", string.Join(", ", banned)));
            }
        }
Пример #25
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!Util.IsSuperAdmin(target))
                return;

            Program.LoadSettings();

            foreach (var roomName in parameters)
            {
                Program.RoomManager.Get(roomName).Leave();
            }

            target.Send("Done.");
        }
Пример #26
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsSession || target.Session.Account == null || parameters.Length == 0)
                return;

            if (Program.DelayManager.AddAndCheck(target.Session, 1))
                return;

            var room = Program.RoomManager.Get(target.Session.Room);
            if (room == null)
            {
                target.Send("RohBot is not in this room.");
                return;
            }

            if (room.IsBanned(target.Session.Account.Name))
            {
                target.Send("You are banned from this room.");
                return;
            }

            room.Send(string.Format("{0} hugs {1}.", target.Session.Account.Name, parameters[0]));
        }
Пример #27
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!Util.IsSuperAdmin(target))
            {
                return;
            }

            Program.LoadSettings();

            foreach (var roomName in parameters)
            {
                Program.RoomManager.Get(roomName).Leave();
            }

            target.Send("Done.");
        }
Пример #28
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !(target.Room is ScriptRoom))
                return;

            var scriptRoom = (ScriptRoom)target.Room;
            ScriptRoom.CommandHandler command;

            if (scriptRoom.Commands.TryGetValue(type, out command))
            {
                scriptRoom.SafeInvoke(() => command.Handler(target, parameters));
                return;
            }

            target.Send("Unknown command.");
        }
Пример #29
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsWeb || parameters.Length == 0)
            {
                return;
            }

            if (Program.DelayManager.AddAndCheck(target.Connection, DelayManager.Database))
            {
                return;
            }

            if (!target.Connection.Session.Join(parameters[0]))
            {
                target.Send("Room does not exist.");
            }
        }
Пример #30
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !(target.Room is ScriptRoom))
            {
                return;
            }

            var scriptRoom = (ScriptRoom)target.Room;

            ScriptRoom.CommandHandler command;

            if (scriptRoom.Commands.TryGetValue(type, out command))
            {
                scriptRoom.SafeInvoke(() => command.Handler(target, parameters));
                return;
            }

            target.Send("Unknown command.");
        }
Пример #31
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            var steamOnline = Program.Steam.Status == Steam.ConnectionStatus.Connected;

            target.Send("Steam: " + (steamOnline ? "Online" : "Offline"));
        }
Пример #32
0
 public override void Handle(CommandTarget target, string type, string[] parameters)
 {
     var steamOnline = Program.Steam.Status == Steam.ConnectionStatus.Connected;
     target.Send("Steam: " + (steamOnline ? "Online" : "Offline"));
 }
Пример #33
0
 public override void Handle(CommandTarget target, string type, string[] parameters)
 {
     if (target.IsWeb || target.IsPrivateChat)
         target.Send("Unknown command.");
 }
Пример #34
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !Util.IsMod(target) || parameters.Length == 0)
                return;

            if (!Util.IsValidUsername(parameters[0]))
            {
                target.Send("Invalid username.");
                return;
            }

            var forAccount = Account.Get(parameters[0]);

            if (forAccount == null)
            {
                target.Send("Account does not exist.");
                return;
            }

            if (Util.IsAdmin(target.Room, forAccount.Name))
            {
                target.Send("Administrators can not be banned.");
                return;
            }

            if (!target.Room.IsBanned(forAccount.Name))
            {
                target.Send("Account is not banned.");
                return;
            }

            target.Room.Unban(parameters[0]);

            var line = new StateLine
            {
                Date = Util.GetCurrentTimestamp(),
                Chat = target.Room.RoomInfo.ShortName,
                State = "Unbanned",
                For = forAccount.Name,
                ForId = forAccount.Id.ToString("D"),
                ForType = "RohBot"
            };

            if (target.IsWeb)
            {
                var byAccount = target.Connection.Session.Account;
                line.By = byAccount.Name;
                line.ById = byAccount.Id.ToString("D");
                line.ByType = "RohBot";
            }
            else
            {
                line.By = target.Persona.DisplayName;
                line.ById = target.Persona.Id.ConvertToUInt64().ToString("D");
                line.ByType = "Steam";
            }

            line.Content = string.Format("{0} was unbanned by {1}.", line.For, line.By);

            target.Room.SendLine(line);
        }
Пример #35
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !Util.IsMod(target) || parameters.Length == 0)
            {
                return;
            }

            if (target.Room.DisableBanning && !Util.IsAdmin(target))
            {
                return;
            }

            if (!Util.IsValidUsername(parameters[0]))
            {
                target.Send("Invalid username.");
                return;
            }

            var forAccount = Account.Get(parameters[0]);

            if (forAccount == null)
            {
                target.Send("Account does not exist.");
                return;
            }

            if (Util.IsAdmin(target.Room, forAccount.Name))
            {
                target.Send("Administrators can not be banned.");
                return;
            }

            if (!target.Room.IsBanned(forAccount.Name))
            {
                target.Send("Account is not banned.");
                return;
            }

            target.Room.Unban(parameters[0]);

            var line = new StateLine
            {
                Date     = Util.GetCurrentTimestamp(),
                Chat     = target.Room.RoomInfo.ShortName,
                State    = "Unbanned",
                For      = forAccount.Name,
                ForId    = forAccount.Id.ToString("D"),
                ForType  = "RohBot",
                ForStyle = forAccount.EnabledStyle
            };

            if (target.IsWeb)
            {
                var byAccount = target.Connection.Session.Account;
                line.By      = byAccount.Name;
                line.ById    = byAccount.Id.ToString("D");
                line.ByType  = "RohBot";
                line.ByStyle = byAccount.EnabledStyle;
            }
            else
            {
                line.By      = target.Persona.DisplayName;
                line.ById    = target.Persona.Id.ConvertToUInt64().ToString("D");
                line.ByType  = "Steam";
                line.ByStyle = "";
            }

            line.Content = $"{line.For} was unbanned by {line.By}.";

            target.Room.SendLine(line);
        }