Exemple #1
0
        private void netcom_InstantMessageReceived(object sender, InstantMessageEventArgs e)
        {
            // Messaage from someone we muted?
            if (null != client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == e.IM.FromAgentID))
            {
                return;
            }

            try
            {
                if (instance.State.LSLHelper.ProcessIM(e))
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                Logger.Log("Failed executing automation action: " + ex.ToString(), Helpers.LogLevel.Warning);
            }

            switch (e.IM.Dialog)
            {
            case InstantMessageDialog.SessionSend:
                if (instance.Groups.ContainsKey(e.IM.IMSessionID))
                {
                    HandleGroupIM(e);
                }
                else
                {
                    HandleConferenceIM(e);
                }
                break;

            case InstantMessageDialog.MessageFromAgent:
                if (e.IM.FromAgentName == "Second Life")
                {
                    HandleIMFromObject(e);
                }
                else if (e.IM.FromAgentID == UUID.Zero)
                {
                    instance.MainForm.AddNotification(new ntfGeneric(instance, e.IM.Message));
                }
                else if (e.IM.GroupIM || instance.Groups.ContainsKey(e.IM.IMSessionID))
                {
                    HandleGroupIM(e);
                }
                else if (e.IM.BinaryBucket.Length > 1)
                {     // conference
                    HandleConferenceIM(e);
                }
                else if (e.IM.IMSessionID == UUID.Zero)
                {
                    String msg = string.Format("Message from {0}: {1}", instance.Names.Get(e.IM.FromAgentID, e.IM.FromAgentName), e.IM.Message);
                    instance.MainForm.AddNotification(new ntfGeneric(instance, msg));
                    DisplayNotificationInChat(msg);
                }
                else
                {
                    HandleIM(e);
                }
                break;

            case InstantMessageDialog.MessageFromObject:
                HandleIMFromObject(e);
                break;

            case InstantMessageDialog.StartTyping:
                if (TabExists(e.IM.FromAgentName))
                {
                    RadegastTab tab = tabs[e.IM.FromAgentName.ToLower()];
                    if (!tab.Highlighted)
                    {
                        tab.PartialHighlight();
                    }
                }

                break;

            case InstantMessageDialog.StopTyping:
                if (TabExists(e.IM.FromAgentName))
                {
                    RadegastTab tab = tabs[e.IM.FromAgentName.ToLower()];
                    if (!tab.Highlighted)
                    {
                        tab.Unhighlight();
                    }
                }

                break;

            case InstantMessageDialog.MessageBox:
                instance.MainForm.AddNotification(new ntfGeneric(instance, e.IM.Message));
                break;

            case InstantMessageDialog.RequestTeleport:
                if (instance.RLV.AutoAcceptTP(e.IM.FromAgentID))
                {
                    DisplayNotificationInChat("Auto accepting teleprot from " + e.IM.FromAgentName);
                    instance.Client.Self.TeleportLureRespond(e.IM.FromAgentID, e.IM.IMSessionID, true);
                }
                else
                {
                    instance.MainForm.AddNotification(new ntfTeleport(instance, e.IM));
                }
                break;

            case InstantMessageDialog.RequestLure:
                instance.MainForm.AddNotification(new ntfRequestLure(instance, e.IM));
                break;

            case InstantMessageDialog.GroupInvitation:
                instance.MainForm.AddNotification(new ntfGroupInvitation(instance, e.IM));
                break;

            case InstantMessageDialog.FriendshipOffered:
                if (e.IM.FromAgentName == "Second Life")
                {
                    HandleIMFromObject(e);
                }
                else
                {
                    instance.MainForm.AddNotification(new ntfFriendshipOffer(instance, e.IM));
                }
                break;

            case InstantMessageDialog.InventoryAccepted:
                DisplayNotificationInChat(e.IM.FromAgentName + " accepted your inventory offer.");
                break;

            case InstantMessageDialog.InventoryDeclined:
                DisplayNotificationInChat(e.IM.FromAgentName + " declined your inventory offer.");
                break;

            case InstantMessageDialog.GroupNotice:
                // Is this group muted?
                if (null != client.Self.MuteList.Find(me => me.Type == MuteType.Group && me.ID == e.IM.FromAgentID))
                {
                    break;
                }

                instance.MainForm.AddNotification(new ntfGroupNotice(instance, e.IM));
                break;

            case InstantMessageDialog.InventoryOffered:
                var ion = new ntfInventoryOffer(instance, e.IM);
                instance.MainForm.AddNotification(ion);
                if (instance.GlobalSettings["inv_auto_accept_mode"].AsInteger() == 1)
                {
                    ion.btnAccept.PerformClick();
                }
                else if (instance.GlobalSettings["inv_auto_accept_mode"].AsInteger() == 2)
                {
                    ion.btnDiscard.PerformClick();
                }
                break;

            case InstantMessageDialog.TaskInventoryOffered:
                // Is the object muted by name?
                if (null != client.Self.MuteList.Find(me => me.Type == MuteType.ByName && me.Name == e.IM.FromAgentName))
                {
                    break;
                }

                var iont = new ntfInventoryOffer(instance, e.IM);
                instance.MainForm.AddNotification(iont);
                if (instance.GlobalSettings["inv_auto_accept_mode"].AsInteger() == 1)
                {
                    iont.btnAccept.PerformClick();
                }
                else if (instance.GlobalSettings["inv_auto_accept_mode"].AsInteger() == 2)
                {
                    iont.btnDiscard.PerformClick();
                }
                break;
            }
        }
Exemple #2
0
        private void netcom_InstantMessageReceived(object sender, InstantMessageEventArgs e)
        {
            // Messaage from someone we muted?
            if (null != client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == e.IM.FromAgentID)) return;

            try
            {
                if (instance.State.LSLHelper.ProcessIM(e))
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                Logger.Log("Failed executing automation action: " + ex.ToString(), Helpers.LogLevel.Warning);
            }

            switch (e.IM.Dialog)
            {
                case InstantMessageDialog.SessionSend:
                    if (instance.Groups.ContainsKey(e.IM.IMSessionID))
                    {
                        HandleGroupIM(e);
                    }
                    else
                    {
                        HandleConferenceIM(e);
                    }
                    break;

                case InstantMessageDialog.MessageFromAgent:
                    if (e.IM.FromAgentName == "Second Life")
                    {
                        HandleIMFromObject(e);
                    }
                    else if (e.IM.FromAgentID == UUID.Zero)
                    {
                        instance.MainForm.AddNotification(new ntfGeneric(instance, e.IM.Message));
                    }
                    else if (e.IM.GroupIM || instance.Groups.ContainsKey(e.IM.IMSessionID))
                    {
                        HandleGroupIM(e);
                    }
                    else if (e.IM.BinaryBucket.Length > 1)
                    { // conference
                        HandleConferenceIM(e);
                    }
                    else if (e.IM.IMSessionID == UUID.Zero)
                    {
                        String msg = string.Format("Region message from {0}: {1}", instance.Names.Get(e.IM.FromAgentID, e.IM.FromAgentName), e.IM.Message);
                        instance.MainForm.AddNotification(new ntfGeneric(instance, msg));
                        DisplayNotificationInChat(msg);
                    }
                    else
                    {
                        HandleIM(e);
                    }
                    break;

                case InstantMessageDialog.MessageFromObject:
                    HandleIMFromObject(e);
                    break;

                case InstantMessageDialog.StartTyping:
                    if (TabExists(e.IM.FromAgentName))
                    {
                        RadegastTab tab = tabs[e.IM.FromAgentName.ToLower()];
                        if (!tab.Highlighted) tab.PartialHighlight();
                    }

                    break;

                case InstantMessageDialog.StopTyping:
                    if (TabExists(e.IM.FromAgentName))
                    {
                        RadegastTab tab = tabs[e.IM.FromAgentName.ToLower()];
                        if (!tab.Highlighted) tab.Unhighlight();
                    }

                    break;

                case InstantMessageDialog.MessageBox:
                    instance.MainForm.AddNotification(new ntfGeneric(instance, e.IM.Message));
                    break;

                case InstantMessageDialog.RequestTeleport:
                    if (instance.RLV.AutoAcceptTP(e.IM.FromAgentID))
                    {
                        DisplayNotificationInChat("Auto accepting teleprot from " + e.IM.FromAgentName);
                        instance.Client.Self.TeleportLureRespond(e.IM.FromAgentID, e.IM.IMSessionID, true);
                    }
                    else
                    {
                        instance.MainForm.AddNotification(new ntfTeleport(instance, e.IM));
                    }
                    break;

                case InstantMessageDialog.RequestLure:
                    instance.MainForm.AddNotification(new ntfRequestLure(instance, e.IM));
                    break;

                case InstantMessageDialog.GroupInvitation:
                    instance.MainForm.AddNotification(new ntfGroupInvitation(instance, e.IM));
                    break;

                case InstantMessageDialog.FriendshipOffered:
                    if (e.IM.FromAgentName == "Second Life")
                    {
                        HandleIMFromObject(e);
                    }
                    else
                    {
                        instance.MainForm.AddNotification(new ntfFriendshipOffer(instance, e.IM));
                    }
                    break;

                case InstantMessageDialog.InventoryAccepted:
                    DisplayNotificationInChat(e.IM.FromAgentName + " accepted your inventory offer.");
                    break;

                case InstantMessageDialog.InventoryDeclined:
                    DisplayNotificationInChat(e.IM.FromAgentName + " declined your inventory offer.");
                    break;

                case InstantMessageDialog.GroupNotice:
                    // Is this group muted?
                    if (null != client.Self.MuteList.Find(me => me.Type == MuteType.Group && me.ID == e.IM.FromAgentID)) break;

                    instance.MainForm.AddNotification(new ntfGroupNotice(instance, e.IM));
                    break;

                case InstantMessageDialog.InventoryOffered:
                    var ion = new ntfInventoryOffer(instance, e.IM);
                    instance.MainForm.AddNotification(ion);
                    if (instance.GlobalSettings["inv_auto_accept_mode"].AsInteger() == 1)
                    {
                        ion.btnAccept.PerformClick();
                    }
                    else if (instance.GlobalSettings["inv_auto_accept_mode"].AsInteger() == 2)
                    {
                        ion.btnDiscard.PerformClick();
                    }
                    break;

                case InstantMessageDialog.TaskInventoryOffered:
                    // Is the object muted by name?
                    if (null != client.Self.MuteList.Find(me => me.Type == MuteType.ByName && me.Name == e.IM.FromAgentName)) break;

                    var iont = new ntfInventoryOffer(instance, e.IM);
                    instance.MainForm.AddNotification(iont);
                    if (instance.GlobalSettings["inv_auto_accept_mode"].AsInteger() == 1)
                    {
                        iont.btnAccept.PerformClick();
                    }
                    else if (instance.GlobalSettings["inv_auto_accept_mode"].AsInteger() == 2)
                    {
                        iont.btnDiscard.PerformClick();
                    }
                    break;
            }
        }