Esempio n. 1
0
        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsSession || !target.IsRoom || !(target.Room is MafiaRoom))
                return;

            var room = (MafiaRoom)target.Room;
            var userList = new Packets.UserList();

            if (room.IsPlaying)
            {
                foreach (var player in room.Players)
                {
                    userList.AddUser(player.Alias, "0", "Member", "", "", true);
                }
            }
            else
            {
                var sessions = Program.SessionManager.List.Where(s => s.Account != null).ToList();
                var accounts = sessions.Where(s => s.Room == room.RoomInfo.ShortName).Select(s => s.Account).Distinct(new Account.Comparer());

                foreach (var account in accounts)
                {
                    var userId = account.Id.ToString();
                    userList.AddUser(account.Name, userId, "Member", "", "", true);
                }
            }

            userList.Users = userList.Users.OrderBy(u => u.Name).ToList();
            target.Session.Send(userList);
        }
Esempio n. 2
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));
            }
        }
Esempio n. 3
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));
            }
        }
Esempio n. 4
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)));
            }
        }