Exemplo n.º 1
0
 private bool SetEnabled(bool e)
 {
     if (!e || AimlLoaded)
     {
         return(e);
     }
     if (!LoadALICE())
     {
         return(false);
     }
     if (Client.Network.Connected)
     {
         Alice.GlobalSettings.updateSetting("name", FirstName(Client.Self.Name));
     }
     AimlLoaded   = true;
     talkToAvatar = new TalkToAvatar(Instance, Alice);
     Instance.ContextActionManager.RegisterContextAction(talkToAvatar);
     return(true);
 }
Exemplo n.º 2
0
        public void StartPlugin(RadegastInstance inst)
        {
            Instance = inst;
            Instance.ClientChanged += new EventHandler<ClientChangedEventArgs>(Instance_ClientChanged);

            if (!Instance.GlobalSettings.Keys.Contains("plugin.alice.enabled"))
            {
                Instance.GlobalSettings["plugin.alice.enabled"] = OSD.FromBoolean(Enabled);
            }
            else
            {
                Enabled = Instance.GlobalSettings["plugin.alice.enabled"].AsBoolean();
            }

            if (!Instance.GlobalSettings.Keys.Contains("plugin.alice.disableOnStart"))
            {
                Instance.GlobalSettings["plugin.alice.disableOnStart"] = OSD.FromBoolean(DisableOnStart);
            }
            else
            {
                DisableOnStart = Instance.GlobalSettings["plugin.alice.disableOnStart"].AsBoolean();
            }
            if (DisableOnStart)
            {
                Enabled = false;
            }
            btn_DisableOnStart = new ToolStripMenuItem("Disable on start", null, (object sender, EventArgs e) =>
            {
                DisableOnStart = btn_DisableOnStart.Checked = !DisableOnStart;
                Instance.GlobalSettings["plugin.alice.disableOnStart"] = OSD.FromBoolean(DisableOnStart);
            });
            btn_DisableOnStart.Checked = DisableOnStart;

            EnabledButton = new ToolStripMenuItem("Enabled", null, (object sender, EventArgs e) =>
            {
                Enabled = EnabledButton.Checked = MenuButton.Checked = !Enabled;
                Instance.GlobalSettings["plugin.alice.enabled"] = OSD.FromBoolean(Enabled);
            });

            if (!Instance.GlobalSettings.Keys.Contains("plugin.alice.respondWithoutName"))
            {
                Instance.GlobalSettings["plugin.alice.respondWithoutName"] = OSD.FromBoolean(respondWithoutName);
            }
            else
            {
                respondWithoutName = Instance.GlobalSettings["plugin.alice.respondWithoutName"].AsBoolean();
            }

            respondWithoutNameButton = new ToolStripMenuItem("Respond without name", null, (object sender, EventArgs e) =>
            {
                respondWithoutName = respondWithoutNameButton.Checked = !respondWithoutName;
                Instance.GlobalSettings["plugin.alice.respondWithoutName"] = OSD.FromBoolean(respondWithoutName);
            });

            if (!Instance.GlobalSettings.Keys.Contains("plugin.alice.respondRange"))
            {
                Instance.GlobalSettings["plugin.alice.respondRange"] = respondRange;
            }
            else
            {
                respondRange = Instance.GlobalSettings["plugin.alice.respondRange"];
            }

            distance_5m = new ToolStripMenuItem("5m range", null, (object sender, EventArgs e) =>
            {
                distance_5m.Checked = !distance_5m.Checked;
                if (distance_5m.Checked)
                {
                    respondRange = 5;
                    distance_10m.Checked = false;
                    distance_15m.Checked = false;
                    distance_20m.Checked = false;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
                else if (!distance_10m.Checked && !distance_15m.Checked && !distance_20m.Checked)
                {
                    respondRange = -1;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
            });

            distance_10m = new ToolStripMenuItem("10m range", null, (object sender, EventArgs e) =>
            {
                distance_10m.Checked = !distance_10m.Checked;
                if (distance_10m.Checked)
                {
                    respondRange = 10;
                    distance_5m.Checked = false;
                    distance_15m.Checked = false;
                    distance_20m.Checked = false;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
                else if (!distance_5m.Checked && !distance_15m.Checked && !distance_20m.Checked)
                {
                    respondRange = -1;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
            });

            distance_15m = new ToolStripMenuItem("15m range", null, (object sender, EventArgs e) =>
            {
                distance_15m.Checked = !distance_15m.Checked;
                if (distance_15m.Checked)
                {
                    respondRange = 15;
                    distance_5m.Checked = false;
                    distance_10m.Checked = false;
                    distance_20m.Checked = false;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
                else if (!distance_5m.Checked && !distance_10m.Checked && !distance_20m.Checked)
                {
                    respondRange = -1;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
            });

            distance_20m = new ToolStripMenuItem("20m range", null, (object sender, EventArgs e) =>
            {
                distance_20m.Checked = !distance_20m.Checked;
                if (distance_20m.Checked)
                {
                    respondRange = 20;
                    distance_5m.Checked = false;
                    distance_10m.Checked = false;
                    distance_15m.Checked = false;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
                else if (!distance_5m.Checked && !distance_10m.Checked && !distance_15m.Checked)
                {
                    respondRange = -1;
                    Instance.GlobalSettings["plugin.alice.respondRange"] = OSD.FromReal(respondRange);
                }
            });

            if (!Instance.GlobalSettings.ContainsKey("plugin.alice.shout2shout"))
            {
                Instance.GlobalSettings["plugin.alice.shout2shout"] = OSD.FromBoolean(shout2shout);
            }
            else
            {
                shout2shout = Instance.GlobalSettings["plugin.alice.shout2shout"].AsBoolean();
            }

            btn_shout2shout = new ToolStripMenuItem("Shout response to Shout", null, (object sender, EventArgs e) =>
            {
                shout2shout = btn_shout2shout.Checked = !shout2shout;
                Instance.GlobalSettings["plugin.alice.shout2shout"] = OSD.FromBoolean(shout2shout);
            });

            if (!Instance.GlobalSettings.ContainsKey("plugin.alice.whisper2whisper"))
            {
                Instance.GlobalSettings["plugin.alice.whisper2whisper"] = OSD.FromBoolean(whisper2whisper);
            }
            else
            {
                whisper2whisper = Instance.GlobalSettings["plugin.alice.whisper2whisper"].AsBoolean();
            }

            btn_whisper2whisper = new ToolStripMenuItem("Whisper response to Whisper", null, (object sender, EventArgs e) =>
            {
                whisper2whisper = btn_whisper2whisper.Checked = !whisper2whisper;
                Instance.GlobalSettings["plugin.alice.whisper2whisper"] = OSD.FromBoolean(whisper2whisper);
            });

            MenuButton = new ToolStripMenuItem("ALICE chatbot", null, (object sender, EventArgs e) =>
            {
                Enabled = EnabledButton.Checked = MenuButton.Checked = !Enabled;
                Instance.GlobalSettings["plugin.alice.enabled"] = OSD.FromBoolean(Enabled);
            });

            btn_enableDelay = new ToolStripMenuItem("Enable random delay", null, (sender, e) =>
            {
                btn_enableDelay.Checked = !btn_enableDelay.Checked;
                Instance.GlobalSettings["plugin.alice.enable_delay"] = EnableRandomDelay = btn_enableDelay.Checked;
            });
            btn_enableDelay.Checked = EnableRandomDelay = Instance.GlobalSettings["plugin.alice.enable_delay"];

            Instance.MainForm.PluginsMenu.DropDownItems.Add(MenuButton);
            Instance.MainForm.PluginsMenu.Visible = true;
            MenuButton.DropDownItems.Add(EnabledButton);
            MenuButton.Checked = EnabledButton.Checked = Enabled;

            MenuButton.DropDownItems.Add(respondWithoutNameButton);
            MenuButton.DropDownItems.Add(distance_5m);
            MenuButton.DropDownItems.Add(distance_10m);
            MenuButton.DropDownItems.Add(distance_15m);
            MenuButton.DropDownItems.Add(distance_20m);
            MenuButton.DropDownItems.Add(btn_shout2shout);
            MenuButton.DropDownItems.Add(btn_whisper2whisper);

            respondWithoutNameButton.Checked = respondWithoutName;
            if (respondRange == 5.0)
            {
                distance_5m.Checked = true;
            }
            else if (respondRange == 10.0)
            {
                distance_10m.Checked = true;
            }
            else if (respondRange == 15.0)
            {
                distance_15m.Checked = true;
            }
            else if (respondRange == 20.0)
            {
                distance_20m.Checked = true;
            }
            btn_shout2shout.Checked = shout2shout;
            btn_whisper2whisper.Checked = whisper2whisper;

            MenuButton.DropDownItems.Add(btn_enableDelay);
            MenuButton.DropDownItems.Add(btn_DisableOnStart);
            MenuButton.DropDownItems.Add("Reload AIML", null, (object sender, EventArgs e) =>
            {
                Alice = null;
                GC.Collect();
                LoadALICE();
            });

            LoadALICE();
            if (Alice != null)
            {
                talkToAvatar = new TalkToAvatar(Instance, Alice);
                Instance.ContextActionManager.RegisterContextAction(talkToAvatar);
            }
            // Events
            RegisterClientEvents(Client);
        }
Exemplo n.º 3
0
 private bool SetEnabled(bool e)
 {
     if (!e || AimlLoaded) return e;
     if (!LoadALICE()) return false;
     if (Client.Network.Connected)
     {
         Alice.GlobalSettings.updateSetting("name", FirstName(Client.Self.Name));
     }
     AimlLoaded = true;
     talkToAvatar = new TalkToAvatar(Instance, Alice);
     Instance.ContextActionManager.RegisterContextAction(talkToAvatar);
     return true;
 }