Пример #1
0
        public static void Main(string[] args)
        {
            IConfig config = ParseConfig(args);
            if (config.Get("help") != null || config.Get("loginuri") == null)
            {
                Help();
            }
            else if (config.Get("firstname") == null ||  config.Get("lastname") == null || config.Get("password") == null)
            {
                Console.WriteLine("ERROR: You must supply a firstname, lastname and password for the bots.");
            }
            else
            {
                int botcount = config.GetInt("botcount", 1);

                BotManager bm = new BotManager();

                //startup specified number of bots.  1 is the default
                bm.dobotStartup(botcount, config);

                while (true)
                {
                    try
                    {
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="bm"></param>
        /// <param name="behaviours">Behaviours for this bot to perform</param>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="password"></param>
        /// <param name="loginUri"></param>
        /// <param name="behaviours"></param>
        public Bot(
            BotManager bm, List <IBehaviour> behaviours,
            string firstName, string lastName, string password, string startLocation, string loginUri)
        {
            ConnectionState = ConnectionState.Disconnected;

            Random        = new Random(Environment.TickCount);// We do stuff randomly here
            FirstName     = firstName;
            LastName      = lastName;
            Name          = string.Format("{0} {1}", FirstName, LastName);
            Password      = password;
            LoginUri      = loginUri;
            StartLocation = startLocation;

            Manager = bm;

            Behaviours = new Dictionary <string, IBehaviour>();
            foreach (IBehaviour behaviour in behaviours)
            {
                AddBehaviour(behaviour);
            }

            // Only calling for use as a template.
            CreateLibOmvClient();
        }
Пример #3
0
//        /// <summary>
//        /// Add additional bots (and threads) to our bot pool
//        /// </summary>
//        /// <param name="botcount">How Many of them to add</param>
//        public void addbots(int botcount)
//        {
//            int len = m_td.Length;
//            Thread[] m_td2 = new Thread[len + botcount];
//            for (int i = 0; i < len; i++)
//            {
//                m_td2[i] = m_td[i];
//            }
//            m_td = m_td2;
//            int newlen = len + botcount;
//            for (int i = len; i < newlen; i++)
//            {
//                startupBot(Config);
//            }
//        }

        /// <summary>
        /// This starts up the bot and stores the thread for the bot in the thread array
        /// </summary>
        /// <param name="bm"></param>
        /// <param name="behaviours">Behaviours for this bot to perform.</param>
        /// <param name="firstName">First name</param>
        /// <param name="lastName">Last name</param>
        /// <param name="password">Password</param>
        /// <param name="loginUri">Login URI</param>
        public void StartBot(
            BotManager bm, List <IBehaviour> behaviours,
            string firstName, string lastName, string password, string loginUri)
        {
            MainConsole.Instance.OutputFormat(
                "[BOT MANAGER]: Starting bot {0} {1}, behaviours are {2}",
                firstName, lastName, string.Join(",", behaviours.ConvertAll <string>(b => b.Name).ToArray()));

            Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri);

            pb.OnConnected    += handlebotEvent;
            pb.OnDisconnected += handlebotEvent;

            lock (m_lBot)
                m_lBot.Add(pb);

            Thread pbThread = new Thread(pb.startup);

            pbThread.Name         = pb.Name;
            pbThread.IsBackground = true;

            pbThread.Start();

            // Stagger logins
            Thread.Sleep(LoginDelay);
        }
Пример #4
0
        public static void Main(string[] args)
        {
            IConfig config = ParseConfig(args);

            if (config.Get("help") != null || config.Get("loginuri") == null)
            {
                Help();
            }
            else if (config.Get("firstname") == null || config.Get("lastname") == null || config.Get("password") == null)
            {
                Console.WriteLine("ERROR: You must supply a firstname, lastname and password for the bots.");
            }
            else
            {
                int botcount = config.GetInt("botcount", 1);

                BotManager bm = new BotManager();

                //startup specified number of bots.  1 is the default
                bm.dobotStartup(botcount, config);

                while (true)
                {
                    try
                    {
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
Пример #5
0
        public static void Main(string[] args)
        {
            IConfig config = ParseConfig(args);

            if (config.Get("help") != null || config.Get("loginuri") == null)
            {
                Help();
            }
            else
            {
                int botcount = config.GetInt("botcount", 1);

                BotManager bm = new BotManager();

                //startup specified number of bots.  1 is the default
                bm.dobotStartup(botcount, config);

                while (true)
                {
                    try
                    {
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
Пример #6
0
        public static void Main(string[] args)
        {
            IConfig config = ParseConfig(args);
            if (config.Get("help") != null || config.Get("loginuri") == null)
            {
                Help();
            }
            else
            {
                int botcount = config.GetInt("botcount", 1);

                BotManager bm = new BotManager();

                //startup specified number of bots.  1 is the default
                bm.dobotStartup(botcount, config);

                while (true)
                {
                    try
                    {
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
Пример #7
0
//        /// <summary>
//        /// Add additional bots (and threads) to our bot pool
//        /// </summary>
//        /// <param name="botcount">How Many of them to add</param>
//        public void addbots(int botcount)
//        {
//            int len = m_td.Length;
//            Thread[] m_td2 = new Thread[len + botcount];
//            for (int i = 0; i < len; i++)
//            {
//                m_td2[i] = m_td[i];
//            }
//            m_td = m_td2;
//            int newlen = len + botcount;
//            for (int i = len; i < newlen; i++)
//            {
//                startupBot(Config);
//            }
//        }

        /// <summary>
        /// This starts up the bot and stores the thread for the bot in the thread array
        /// </summary>
        /// <param name="bm"></param>
        /// <param name="behaviours">Behaviours for this bot to perform.</param>
        /// <param name="firstName">First name</param>
        /// <param name="lastName">Last name</param>
        /// <param name="password">Password</param>
        /// <param name="loginUri">Login URI</param>
        public void StartBot(
            BotManager bm, List <IBehaviour> behaviours,
            string firstName, string lastName, string password, string loginUri)
        {
            Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri);

            pb.OnConnected    += handlebotEvent;
            pb.OnDisconnected += handlebotEvent;

            lock (m_lBot)
                m_lBot.Add(pb);

            Thread pbThread = new Thread(pb.startup);

            pbThread.Name         = pb.Name;
            pbThread.IsBackground = true;
            pbThread.Start();
        }
Пример #8
0
        /// <summary>
        /// This creates a bot but does not start it.
        /// </summary>
        /// <param name="bm"></param>
        /// <param name="behaviours">Behaviours for this bot to perform.</param>
        /// <param name="firstName">First name</param>
        /// <param name="lastName">Last name</param>
        /// <param name="password">Password</param>
        /// <param name="loginUri">Login URI</param>
        /// <param name="startLocation">Location to start the bot.  Can be "last", "home" or a specific sim name.</param>
        /// <param name="wearSetting"></param>
        public void CreateBot(
            BotManager bm, List <IBehaviour> behaviours,
            string firstName, string lastName, string password, string loginUri, string startLocation, string wearSetting)
        {
            MainConsole.Instance.OutputFormat(
                "[BOT MANAGER]: Creating bot {0} {1}, behaviours are {2}",
                firstName, lastName, string.Join(",", behaviours.ConvertAll <string>(b => b.Name).ToArray()));

            Bot pb = new Bot(bm, behaviours, firstName, lastName, password, startLocation, loginUri);

            pb.wear = wearSetting;
            pb.Client.Settings.SEND_AGENT_UPDATES = InitBotSendAgentUpdates;
            pb.RequestObjectTextures = InitBotRequestObjectTextures;

            pb.OnConnected    += handlebotEvent;
            pb.OnDisconnected += handlebotEvent;

            m_bots.Add(pb);
        }
Пример #9
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="bm"></param>
        /// <param name="behaviours">Behaviours for this bot to perform</param>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="password"></param>
        /// <param name="loginUri"></param>
        /// <param name="behaviours"></param>
        public Bot(
            BotManager bm, List <IBehaviour> behaviours,
            string firstName, string lastName, string password, string loginUri)
        {
            behaviours.ForEach(b => b.Initialize(this));

            Client = new GridClient();

            Random    = new Random(Environment.TickCount);// We do stuff randomly here
            FirstName = firstName;
            LastName  = lastName;
            Name      = string.Format("{0} {1}", FirstName, LastName);
            Password  = password;
            LoginUri  = loginUri;

            Manager       = bm;
            startupConfig = bm.Config;
            readconfig();

            Behaviours = behaviours;
        }
Пример #10
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="bm"></param>
        /// <param name="behaviours">Behaviours for this bot to perform</param>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="password"></param>
        /// <param name="loginUri"></param>
        /// <param name="behaviours"></param>
        public Bot(
            BotManager bm, List <IBehaviour> behaviours,
            string firstName, string lastName, string password, string startLocation, string loginUri)
        {
            ConnectionState = ConnectionState.Disconnected;

            behaviours.ForEach(b => b.Initialize(this));

            Random        = new Random(Environment.TickCount);// We do stuff randomly here
            FirstName     = firstName;
            LastName      = lastName;
            Name          = string.Format("{0} {1}", FirstName, LastName);
            Password      = password;
            LoginUri      = loginUri;
            StartLocation = startLocation;

            Manager    = bm;
            Behaviours = behaviours;

            // Only calling for use as a template.
            CreateLibOmvClient();
        }
Пример #11
0
        public static void Main(string[] args)
        {
            XmlConfigurator.Configure();

            IConfig config = ParseConfig(args);
            if (config.Get("help") != null || config.Get("loginuri") == null)
            {
                Help();
            }
            else if (config.Get("firstname") == null ||  config.Get("lastname") == null || config.Get("password") == null)
            {
                Console.WriteLine("ERROR: You must supply a firstname, lastname and password for the bots.");
            }
            else
            {
                int botcount = config.GetInt("botcount", 1);

                BotManager bm = new BotManager();

                //startup specified number of bots.  1 is the default
                Thread startBotThread = new Thread(o => bm.dobotStartup(botcount, config));
                startBotThread.Name = "Initial start bots thread";
                startBotThread.Start();

                while (true)
                {
                    try
                    {
                        //MainConsole.Instance.Output("Please input command...");
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
Пример #12
0
        public static void Main(string[] args)
        {
            XmlConfigurator.Configure();

            IConfig commandLineConfig = ParseConfig(args);

            if (commandLineConfig.Get("help") != null || commandLineConfig.Get("loginuri") == null)
            {
                Help();
            }
            else if (
                commandLineConfig.Get("firstname") == null ||
                commandLineConfig.Get("lastname") == null ||
                commandLineConfig.Get("password") == null)
            {
                Console.WriteLine("ERROR: You must supply a firstname, lastname and password for the bots.");
            }
            else
            {
                BotManager bm = new BotManager();

                string iniFilePath = Path.GetFullPath(Path.Combine(Util.configDir(), ConfigFileName));

                if (File.Exists(iniFilePath))
                {
                    m_log.InfoFormat("[PCAMPBOT]: Reading configuration settings from {0}", iniFilePath);

                    IConfigSource configSource = new IniConfigSource(iniFilePath);

                    IConfig botManagerConfig = configSource.Configs["BotManager"];

                    if (botManagerConfig != null)
                    {
                        bm.LoginDelay = botManagerConfig.GetInt("LoginDelay", bm.LoginDelay);
                    }

                    IConfig botConfig = configSource.Configs["Bot"];

                    if (botConfig != null)
                    {
                        bm.InitBotSendAgentUpdates
                            = botConfig.GetBoolean("SendAgentUpdates", bm.InitBotSendAgentUpdates);
                        bm.InitBotRequestObjectTextures
                            = botConfig.GetBoolean("RequestObjectTextures", bm.InitBotRequestObjectTextures);
                    }
                }

                int  botcount       = commandLineConfig.GetInt("botcount", 1);
                bool startConnected = commandLineConfig.Get("connect") != null;

                bm.CreateBots(botcount, commandLineConfig);

                if (startConnected)
                {
                    bm.ConnectBots(botcount);
                }

                while (true)
                {
                    try
                    {
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
Пример #13
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="bm"></param>
        /// <param name="behaviours">Behaviours for this bot to perform</param>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="password"></param>
        /// <param name="loginUri"></param>
        /// <param name="behaviours"></param>
        public Bot(
            BotManager bm, List<IBehaviour> behaviours,
            string firstName, string lastName, string password, string startLocation, string loginUri)
        {
            ConnectionState = ConnectionState.Disconnected;

            Random = new Random(bm.Rng.Next());
            FirstName = firstName;
            LastName = lastName;
            Name = string.Format("{0} {1}", FirstName, LastName);
            Password = password;
            LoginUri = loginUri;
            StartLocation = startLocation;

            Manager = bm;

            Behaviours = new Dictionary<string, IBehaviour>();
            foreach (IBehaviour behaviour in behaviours)
                AddBehaviour(behaviour);

            // Only calling for use as a template.
            CreateLibOmvClient();
        }
Пример #14
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="bm"></param>
        /// <param name="behaviours">Behaviours for this bot to perform</param>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="password"></param>
        /// <param name="loginUri"></param>
        /// <param name="behaviours"></param>
        public Bot(
            BotManager bm, List<IBehaviour> behaviours,
            string firstName, string lastName, string password, string loginUri)
        {
            behaviours.ForEach(b => b.Initialize(this));
            
            Client = new GridClient();

            Random = new Random(Environment.TickCount);// We do stuff randomly here
            FirstName = firstName;
            LastName = lastName;
            Name = string.Format("{0} {1}", FirstName, LastName);
            Password = password;
            LoginUri = loginUri;

            Manager = bm;
            startupConfig = bm.Config;
            readconfig();

            Behaviours = behaviours;
        }
Пример #15
0
//        /// <summary>
//        /// Add additional bots (and threads) to our bot pool
//        /// </summary>
//        /// <param name="botcount">How Many of them to add</param>
//        public void addbots(int botcount)
//        {
//            int len = m_td.Length;
//            Thread[] m_td2 = new Thread[len + botcount];
//            for (int i = 0; i < len; i++)
//            {
//                m_td2[i] = m_td[i];
//            }
//            m_td = m_td2;
//            int newlen = len + botcount;
//            for (int i = len; i < newlen; i++)
//            {
//                startupBot(Config);
//            }
//        }

        /// <summary>
        /// This starts up the bot and stores the thread for the bot in the thread array
        /// </summary>
        /// <param name="bm"></param>
        /// <param name="behaviours">Behaviours for this bot to perform.</param>
        /// <param name="firstName">First name</param>
        /// <param name="lastName">Last name</param>
        /// <param name="password">Password</param>
        /// <param name="loginUri">Login URI</param>
        public void StartBot(
             BotManager bm, List<IBehaviour> behaviours,
             string firstName, string lastName, string password, string loginUri)
        {
            Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri);

            pb.OnConnected += handlebotEvent;
            pb.OnDisconnected += handlebotEvent;

            lock (m_lBot)
                m_lBot.Add(pb);

            Thread pbThread = new Thread(pb.startup);
            pbThread.Name = pb.Name;
            pbThread.IsBackground = true;
            pbThread.Start();
        }
Пример #16
0
        public static void Main(string[] args)
        {
            XmlConfigurator.Configure();

            IConfig commandLineConfig = ParseConfig(args);
            if (commandLineConfig.Get("help") != null || commandLineConfig.Get("loginuri") == null)
            {
                Help();
            }
            else if (
                commandLineConfig.Get("firstname") == null 
                    ||  commandLineConfig.Get("lastname") == null 
                    || commandLineConfig.Get("password") == null)
            {
                Console.WriteLine("ERROR: You must supply a firstname, lastname and password for the bots.");
            }
            else
            {
                BotManager bm = new BotManager();

                string iniFilePath = Path.GetFullPath(Path.Combine(Util.configDir(), ConfigFileName));

                if (File.Exists(iniFilePath))
                {
                    m_log.InfoFormat("[PCAMPBOT]: Reading configuration settings from {0}", iniFilePath);

                    IConfigSource configSource = new IniConfigSource(iniFilePath);

                    IConfig botManagerConfig = configSource.Configs["BotManager"];

                    if (botManagerConfig != null)
                    {
                        bm.LoginDelay = botManagerConfig.GetInt("LoginDelay", bm.LoginDelay);
                    }

                    IConfig botConfig = configSource.Configs["Bot"];

                    if (botConfig != null)
                    {
                        bm.InitBotSendAgentUpdates 
                            = botConfig.GetBoolean("SendAgentUpdates", bm.InitBotSendAgentUpdates);
                        bm.InitBotRequestObjectTextures
                            = botConfig.GetBoolean("RequestObjectTextures", bm.InitBotRequestObjectTextures);
                    }
                }

                int botcount = commandLineConfig.GetInt("botcount", 1);
                bool startConnected = commandLineConfig.Get("connect") != null;

                bm.CreateBots(botcount, commandLineConfig);

                if (startConnected)
                    bm.ConnectBots(botcount);

                while (true)
                {
                    try
                    {
                        MainConsole.Instance.Prompt();
                    }
                    catch (Exception e)
                    {
                        m_log.ErrorFormat("Command error: {0}", e);
                    }
                }
            }
        }
Пример #17
0
//        /// <summary>
//        /// Add additional bots (and threads) to our bot pool
//        /// </summary>
//        /// <param name="botcount">How Many of them to add</param>
//        public void addbots(int botcount)
//        {
//            int len = m_td.Length;
//            Thread[] m_td2 = new Thread[len + botcount];
//            for (int i = 0; i < len; i++)
//            {
//                m_td2[i] = m_td[i];
//            }
//            m_td = m_td2;
//            int newlen = len + botcount;
//            for (int i = len; i < newlen; i++)
//            {
//                startupBot(Config);
//            }
//        }

        /// <summary>
        /// This starts up the bot and stores the thread for the bot in the thread array
        /// </summary>
        /// <param name="bm"></param>
        /// <param name="behaviours">Behaviours for this bot to perform.</param>
        /// <param name="firstName">First name</param>
        /// <param name="lastName">Last name</param>
        /// <param name="password">Password</param>
        /// <param name="loginUri">Login URI</param>
        public void StartBot(
             BotManager bm, List<IBehaviour> behaviours,
             string firstName, string lastName, string password, string loginUri)
        {
            MainConsole.Instance.OutputFormat(
                "[BOT MANAGER]: Starting bot {0} {1}, behaviours are {2}",
                firstName, lastName, string.Join(",", behaviours.ConvertAll<string>(b => b.Name).ToArray()));

            Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri);

            pb.OnConnected += handlebotEvent;
            pb.OnDisconnected += handlebotEvent;

            lock (m_lBot)
                m_lBot.Add(pb);

            Thread pbThread = new Thread(pb.startup);
            pbThread.Name = pb.Name;
            pbThread.IsBackground = true;

            pbThread.Start();

            // Stagger logins
            Thread.Sleep(LoginDelay);
        }
Пример #18
0
        /// <summary>
        /// This creates a bot but does not start it.
        /// </summary>
        /// <param name="bm"></param>
        /// <param name="behaviours">Behaviours for this bot to perform.</param>
        /// <param name="firstName">First name</param>
        /// <param name="lastName">Last name</param>
        /// <param name="password">Password</param>
        /// <param name="loginUri">Login URI</param>
        /// <param name="startLocation">Location to start the bot.  Can be "last", "home" or a specific sim name.</param>
        /// <param name="wearSetting"></param>
        public void CreateBot(
             BotManager bm, List<IBehaviour> behaviours,
             string firstName, string lastName, string password, string loginUri, string startLocation, string wearSetting)
        {
            MainConsole.Instance.OutputFormat(
                "[BOT MANAGER]: Creating bot {0} {1}, behaviours are {2}",
                firstName, lastName, string.Join(",", behaviours.ConvertAll<string>(b => b.Name).ToArray()));

            Bot pb = new Bot(bm, behaviours, firstName, lastName, password, startLocation, loginUri);
            pb.wear = wearSetting;
            pb.Client.Settings.SEND_AGENT_UPDATES = InitBotSendAgentUpdates;
            pb.RequestObjectTextures = InitBotRequestObjectTextures;

            pb.OnConnected += handlebotEvent;
            pb.OnDisconnected += handlebotEvent;

            m_bots.Add(pb);
        }
Пример #19
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="bm"></param>
        /// <param name="behaviours">Behaviours for this bot to perform</param>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="password"></param>
        /// <param name="loginUri"></param>
        /// <param name="behaviours"></param>
        public Bot(
            BotManager bm, List<IBehaviour> behaviours,
            string firstName, string lastName, string password, string startLocation, string loginUri)
        {
            ConnectionState = ConnectionState.Disconnected;

            behaviours.ForEach(b => b.Initialize(this));

            Random = new Random(Environment.TickCount);// We do stuff randomly here
            FirstName = firstName;
            LastName = lastName;
            Name = string.Format("{0} {1}", FirstName, LastName);
            Password = password;
            LoginUri = loginUri;
            StartLocation = startLocation;

            Manager = bm;
            Behaviours = behaviours;

            // Only calling for use as a template.
            CreateLibOmvClient();
        }