Exemplo n.º 1
0
 public static void EnsureBotClientHasRadegast(BotClient bc)
 {
     GridClient gridClient = bc.gridClient;
     RadegastInstance inst = bc.TheRadegastInstance;
     lock (ClientManager._wasFirstGridClientLock)
     {
         if (ClientManager._wasFirstGridClient)
         {
             ClientManager._wasFirstGridClient = false;
             if (ClientManagerConfig.UsingCogbotFromRadegast)
             {
                 inst = GlobalRadegastInstance;
             }
             if (inst != null)
             {
                 gridClient = inst.Client;
             }
         }
     }
     string name = "EnsureBotClientHasRadegast: " + bc.GetName();
     ClientManager.InSTAThread(() =>
                     {
                         EnsureRadegastForm(bc, bc.TheRadegastInstance, name);
                         //bc.TheRadegastInstance.MainForm.WindowState = FormWindowState.Minimized;
                     }, name);
 }
Exemplo n.º 2
0
        public static void EnsureBotClientHasRadegast(BotClient bc)
        {
            GridClient       gridClient = bc.gridClient;
            RadegastInstance inst       = bc.TheRadegastInstance;

            lock (ClientManager._wasFirstGridClientLock)
            {
                if (ClientManager._wasFirstGridClient)
                {
                    ClientManager._wasFirstGridClient = false;
                    if (ClientManagerConfig.UsingCogbotFromRadegast)
                    {
                        inst = GlobalRadegastInstance;
                    }
                    if (inst != null)
                    {
                        gridClient = inst.Client;
                    }
                }
            }
            string name = "EnsureBotClientHasRadegast: " + bc.GetName();

            ClientManager.InSTAThread(() =>
            {
                EnsureRadegastForm(bc, bc.TheRadegastInstance, name);
                //bc.TheRadegastInstance.MainForm.WindowState = FormWindowState.Minimized;
            }, name);
        }
Exemplo n.º 3
0
        void SimEventSubscriber.OnEvent(CogbotEvent evt)
        {
            if (!EventsEnabled)
            {
                return;
            }
            const SimEventType du = SimEventType.DATA_UPDATE;

            if (evt.IsEventType(du))
            {
                return;
            }

            if (evt.IsEventType(SimEventType.EFFECT))
            {
                if (evt.Verb == "LookAtType-Idle")
                {
                    return;
                }
                if (evt.Verb == "LookAtType-FreeLook")
                {
                    return;
                }
            }
            String eventName = evt.Verb;

            object[] args = evt.GetArgs();

            String msg   = "[" + From.GetName() + ": " + eventName.ToLower() + "]";
            int    start = 0;

            if (args.Length > 1)
            {
                if (args[0] is Simulator)
                {
                    // start = 1;
                }
            }
            for (int i = start; i < args.Length; i++)
            {
                msg += " ";
                msg += From.argString(args[i]);
            }
            if (msg.Contains("Transfer failed with status code"))
            {
                return;
            }
            msg += "";

            textForm(msg);
        }
Exemplo n.º 4
0
        internal void MakeRunning(BotClient bc)
        {
            lock (MakeRunningLock)
            {
                if (bc.RanMakeRunning) return;
                bc.RanMakeRunning = true;
            }
            ThreadStart invoker0 = () => EnsureMakeRunning(bc);

            PostAutoExecEnqueue(() =>
                                     {
                                         if (ClientManagerConfig.ShowRadegast)
                                         {
                                             CogbotGUI.SetRadegastLoginOptionsFromCogbot(bc.TheRadegastInstance, bc);
                                         }
                                         // in-case someoine hits the login button
                                         bc.Network.LoginProgress += (s, e) =>
                                                                         {
                                                                             if (e.Status == LoginStatus.Success)
                                                                             {
                                                                                 PostAutoExec.Enqueue((() => InSTAThread(invoker0, "LoginProgress: " + bc.GetName())));
                                                                             }
                                                                         };
                                         PostAutoExecEnqueue((() => InSTAThread(invoker0, "StartupClientLisp: " + bc.GetName())));
                                     });
        }
Exemplo n.º 5
0
        public void Remove(BotClient client)
        {
            if (client==null) return;
            string name = client.NameKey();
            BotClient bc0 = null;
            lock (OneAtATime)
            {
                lock (BotByName)
                {
                    if (BotByName.TryGetValue(name, out bc0))
                    {
                        if (!Object.ReferenceEquals(bc0, client))
                        {
                            WriteLine("BotClient != " + bc0.GetName() + " and " + client.GetName());
                        }
                        BotByName.Remove(name);
                    }
                }
                if (bc0 != null) bc0.Dispose();
                lock (Accounts)
                {
                    LoginDetails param;
                    if (Accounts.TryGetValue(name, out param))
                    {
                        BotClient pc = param.Client;
                        if (pc!=null)
                        {
                            param.Client = null;
                        }
                        Accounts.Remove(name);
                    }
                }
            }

        }
Exemplo n.º 6
0
        static public void SetRadegastLoginOptionsFromCogbot(RadegastInstance instance, BotClient TheBot)
        {
            if (instance == null) return;           
            var BotLoginParams = TheBot.BotLoginParams;
            EnsureRadegastForm(TheBot, instance, "EnsureRadegastForm from SetRadegastLoginOptions " + TheBot.GetName());
            var to = instance.Netcom.LoginOptions;
            to.FirstName = BotLoginParams.FirstName;
            to.LastName = BotLoginParams.LastName;
            to.Password = BotLoginParams.Password;
            string loginURI = BotLoginParams.URI;

            MainProgram.CommandLine.LoginUri = loginURI;
            MainProgram.CommandLine.Location = BotLoginParams.Start;
            int gidx;
            Grid G = GetGridIndex(instance, loginURI, out gidx);
            if (G == null)
            {
                G = new Grid(BotLoginParams.URI, BotLoginParams.URI, loginURI);
                to.GridCustomLoginUri = loginURI;
            }
            else
            {
                BotLoginParams.URI = G.LoginURI;
            }
            instance.Netcom.LoginOptions.Grid = G;
            to.Grid = G;
            string botStartAt = BotLoginParams.Start;

            if (botStartAt == "home")
            {
                to.StartLocation = StartLocationType.Home;
            }
            else if (botStartAt == "last")
            {
                to.StartLocation = StartLocationType.Last;
            }
            else
            {
                to.StartLocation = StartLocationType.Custom;
                to.StartLocationCustom = botStartAt;
            }
            to.Version = BotLoginParams.Version;
            to.Channel = BotLoginParams.Channel;
            RadegastTab tab;
            if (instance.TabConsole.Tabs.TryGetValue("login", out tab))
            {
                tab.AllowDetach = true;
                tab.AllowClose = false;
                tab.AllowMerge = false;
                tab.AllowHide = false;
                LoginConsole form = (LoginConsole)tab.Control;
                try
                {
                    if (form.IsDisposed) return;
                    DLRConsole.InvokeControl((Control)instance.MainForm, (MethodInvoker)(() => SetRadegastLoginForm(instance, form, to)));                    
                }
                catch (Exception e) 
                {
                    TheBot.LogException("Set Radegast Login Form", e);
                }
            }
        }
Exemplo n.º 7
0
        static public void SetRadegastLoginOptionsFromCogbot(RadegastInstance instance, BotClient TheBot)
        {
            if (instance == null)
            {
                return;
            }
            var BotLoginParams = TheBot.BotLoginParams;

            EnsureRadegastForm(TheBot, instance, "EnsureRadegastForm from SetRadegastLoginOptions " + TheBot.GetName());
            var to = instance.Netcom.LoginOptions;

            to.FirstName = BotLoginParams.FirstName;
            to.LastName  = BotLoginParams.LastName;
            to.Password  = BotLoginParams.Password;
            string loginURI = BotLoginParams.URI;

            MainProgram.CommandLine.LoginUri = loginURI;
            MainProgram.CommandLine.Location = BotLoginParams.Start;
            int  gidx;
            Grid G = GetGridIndex(instance, loginURI, out gidx);

            if (G == null)
            {
                G = new Grid(BotLoginParams.URI, BotLoginParams.URI, loginURI);
                to.GridCustomLoginUri = loginURI;
            }
            else
            {
                BotLoginParams.URI = G.LoginURI;
            }
            instance.Netcom.LoginOptions.Grid = G;
            to.Grid = G;
            string botStartAt = BotLoginParams.Start;

            if (botStartAt == "home")
            {
                to.StartLocation = StartLocationType.Home;
            }
            else if (botStartAt == "last")
            {
                to.StartLocation = StartLocationType.Last;
            }
            else
            {
                to.StartLocation       = StartLocationType.Custom;
                to.StartLocationCustom = botStartAt;
            }
            to.Version = BotLoginParams.Version;
            to.Channel = BotLoginParams.Channel;
            RadegastTab tab;

            if (instance.TabConsole.Tabs.TryGetValue("login", out tab))
            {
                tab.AllowDetach = true;
                tab.AllowClose  = false;
                tab.AllowMerge  = false;
                tab.AllowHide   = false;
                LoginConsole form = (LoginConsole)tab.Control;
                try
                {
                    if (form.IsDisposed)
                    {
                        return;
                    }
                    DLRConsole.InvokeControl((Control)instance.MainForm, (MethodInvoker)(() => SetRadegastLoginForm(instance, form, to)));
                }
                catch (Exception e)
                {
                    TheBot.LogException("Set Radegast Login Form", e);
                }
            }
        }