示例#1
0
        public override void Execute(string[] arguments)
        {
            base.Execute(arguments);

            if (arguments.Count() != 1)
            {
                Fail();
                return;
            }

            DataTable table = Program.rooms.JoinRoom(Program.login.userID, arguments[0]);

            if (table == null)
            {
                ConsoleAdditions.WriteLine($"§4Unable to find Chatroom with the name §7{arguments[0]}§4. Please try again or use the .help command for more information.");
                return;
            }

            Console.Clear();
            Console.Title = table.Rows[0][0].ToString();

            DataRow[] messages = Program.rooms.ReadMessages();

            StringBuilder stringBuilder = new StringBuilder();

            foreach (DataRow row in messages)
            {
                stringBuilder.Append(row[1]);
                stringBuilder.Append(": ");
                stringBuilder.AppendLine(row[0].ToString());
            }
            Program.chatViewer.Invoke(new Action(() => { Program.chatViewer.label.Text = stringBuilder.ToString(); }));

            Program.commandHandler.Register(new InviteCommand());
        }
示例#2
0
        public override void Execute(string[] arguments)
        {
            base.Execute(arguments);

            DataTable table = Program.rooms.GetRooms();

            StringBuilder builder = new StringBuilder("Available Rooms: ");

            foreach (DataRow row in table.Rows)
            {
                builder.Append(row[0]);
                builder.Append(", ");
            }

            if (table.Rows.Count != 0)
            {
                builder.Remove(builder.Length - 2, 2);
                ConsoleAdditions.WriteLine(builder.ToString());
            }
            else
            {
                Console.WriteLine("You do not have access to any chatrooms! Try creating one with .creatroom.");
            }
        }