Exemple #1
0
        private void ProcessIncomingIM(InstantMessageEventArgs e)
        {
            // Check to see if avatar is muted
            if (instance.IsAvatarMuted(e.IM.FromAgentID, e.IM.FromAgentName))
            {
                return;
            }

            //string iuid = this.instance.Config.CurrentConfig.IgnoreUID;

            //if (e.IM.Message.Contains(iuid)) return; // Ignore Im for plugins use etc.
            if (e.IM.Message.Contains(this.instance.Config.CurrentConfig.CommandInID))
            {
                return;
            }
            if (e.IM.Message.Contains(this.instance.Config.CurrentConfig.IgnoreUID))
            {
                return;
            }

            bool isgroup = this.instance.State.GroupStore.ContainsKey(e.IM.IMSessionID);

            if (isgroup)
            {
                //if (null != client.Self.MuteList.Find(me => me.Type == MuteType.Group && (me.ID == e.IM.IMSessionID || me.ID == e.IM.FromAgentID))) return;

                // Check to see if group IMs are disabled
                if (instance.Config.CurrentConfig.DisableGroupIMs)
                {
                    return;
                }
            }

            PrintIM(DateTime.Now, e.IM.FromAgentID.ToString(), e.IM.FromAgentName, e.IM.Message, e.IM.IMSessionID);

            //string msg = ">>> " + e.IM.FromAgentName + ": " + e.IM.Message;

            //// Handles twitter
            //if (TEnabled)
            //{
            //    if (!isgroup)
            //    {
            //        Yedda.Twitter twit = new Yedda.Twitter();
            //        string resp = string.Empty;

            //        if (tweet)
            //        {
            //            // if enabled print to Twitter
            //            resp = twit.UpdateAsJSON(tName, tPwd, msg);
            //        }
            //        else
            //        {
            //            // it's a direct message
            //            resp = twit.Send(tName, tPwd, tweetname, msg);
            //        }

            //        if (resp != "OK")
            //        {
            //            Logger.Log("Twitter error: " + resp, Helpers.LogLevel.Warning);
            //        }
            //    }
            //}

            if (!isgroup)
            {
                if (instance.State.IsBusy)
                {
                    string responsemsg = this.instance.Config.CurrentConfig.BusyReply;
                    client.Self.InstantMessage(client.Self.Name, e.IM.FromAgentID, responsemsg, e.IM.IMSessionID, InstantMessageDialog.BusyAutoResponse, InstantMessageOnline.Offline, instance.SIMsittingPos(), UUID.Zero, new byte[0]);
                }
                else
                {
                    // Handles METAbrain
                    if (this.instance.Config.CurrentConfig.AIon)
                    {
                        if (e.IM.FromAgentID == client.Self.AgentID)
                        {
                            return;
                        }
                        if (client.Self.GroupChatSessions.ContainsKey(e.IM.IMSessionID))
                        {
                            return;
                        }
                        if (e.IM.FromAgentName == "Second Life")
                        {
                            return;
                        }
                        if (e.IM.FromAgentName.Contains("Linden"))
                        {
                            return;
                        }
                        if (e.IM.Dialog == InstantMessageDialog.SessionSend)
                        {
                            return;
                        }

                        ////METAbrain brain = new METAbrain(instance, myBot, e);
                        brain = new METAbrain(instance, myBot);
                        brain.StartProcess(e);
                    }
                }
            }
        }
        private void ProcessIncomingIM(InstantMessageEventArgs e)
        {
            // Check to see if avatar is muted
            if (instance.IsAvatarMuted(e.IM.FromAgentID, e.IM.FromAgentName))
                return;

            //string iuid = this.instance.Config.CurrentConfig.IgnoreUID;

            //if (e.IM.Message.Contains(iuid)) return; // Ignore Im for plugins use etc.
            if (e.IM.Message.Contains(this.instance.Config.CurrentConfig.CommandInID)) return;
            if (e.IM.Message.Contains(this.instance.Config.CurrentConfig.IgnoreUID)) return;

            bool isgroup = this.instance.State.GroupStore.ContainsKey(e.IM.IMSessionID);

            if (isgroup)
            {
                //if (null != client.Self.MuteList.Find(me => me.Type == MuteType.Group && (me.ID == e.IM.IMSessionID || me.ID == e.IM.FromAgentID))) return;

                // Check to see if group IMs are disabled
                if (instance.Config.CurrentConfig.DisableGroupIMs)
                    return;
            }

            PrintIM(DateTime.Now, e.IM.FromAgentID.ToString(), e.IM.FromAgentName, e.IM.Message, e.IM.IMSessionID);

            //string msg = ">>> " + e.IM.FromAgentName + ": " + e.IM.Message;

            //// Handles twitter
            //if (TEnabled)
            //{
            //    if (!isgroup)
            //    {
            //        Yedda.Twitter twit = new Yedda.Twitter();
            //        string resp = string.Empty;

            //        if (tweet)
            //        {
            //            // if enabled print to Twitter
            //            resp = twit.UpdateAsJSON(tName, tPwd, msg);
            //        }
            //        else
            //        {
            //            // it's a direct message
            //            resp = twit.Send(tName, tPwd, tweetname, msg);
            //        }

            //        if (resp != "OK")
            //        {
            //            Logger.Log("Twitter error: " + resp, Helpers.LogLevel.Warning);
            //        }
            //    }
            //}

            if (!isgroup)
            {
                if (instance.State.IsBusy)
                {
                    string responsemsg = this.instance.Config.CurrentConfig.BusyReply;
                    client.Self.InstantMessage(client.Self.Name, e.IM.FromAgentID, responsemsg, e.IM.IMSessionID, InstantMessageDialog.BusyAutoResponse, InstantMessageOnline.Offline, instance.SIMsittingPos(), UUID.Zero, new byte[0]);
                }
                else
                {
                    // Handles METAbrain
                    if (this.instance.Config.CurrentConfig.AIon)
                    {
                        if (e.IM.FromAgentID == client.Self.AgentID) return;
                        if (client.Self.GroupChatSessions.ContainsKey(e.IM.IMSessionID)) return;
                        if (e.IM.FromAgentName == "Second Life") return;
                        if (e.IM.FromAgentName.Contains("Linden")) return;
                        if (e.IM.Dialog == InstantMessageDialog.SessionSend) return;

                        ////METAbrain brain = new METAbrain(instance, myBot, e);
                        brain = new METAbrain(instance, myBot);
                        brain.StartProcess(e);
                    }
                }
            }
        }