示例#1
1
        void Self_IM(object sender, InstantMessageEventArgs e)
        {
            // TODO: MainAvatar.InstantMessageDialog.GroupNotice can also be an inventory offer, should we
            // handle it here?

            if (m_InventoryObjectOffered != null &&
                (e.IM.Dialog == InstantMessageDialog.InventoryOffered
                || e.IM.Dialog == InstantMessageDialog.TaskInventoryOffered))
            {
                AssetType type = AssetType.Unknown;
                UUID objectID = UUID.Zero;
                bool fromTask = false;

                if (e.IM.Dialog == InstantMessageDialog.InventoryOffered)
                {
                    if (e.IM.BinaryBucket.Length == 17)
                    {
                        type = (AssetType)e.IM.BinaryBucket[0];
                        objectID = new UUID(e.IM.BinaryBucket, 1);
                        fromTask = false;
                    }
                    else
                    {
                        Logger.Log("Malformed inventory offer from agent", Helpers.LogLevel.Warning, Client);
                        return;
                    }
                }
                else if (e.IM.Dialog == InstantMessageDialog.TaskInventoryOffered)
                {
                    if (e.IM.BinaryBucket.Length == 1)
                    {
                        type = (AssetType)e.IM.BinaryBucket[0];
                        fromTask = true;
                    }
                    else
                    {
                        Logger.Log("Malformed inventory offer from object", Helpers.LogLevel.Warning, Client);
                        return;
                    }
                }

                // Find the folder where this is going to go
                UUID destinationFolderID = FindFolderForType(type);

                // Fire the callback
                try
                {
                    ImprovedInstantMessagePacket imp = new ImprovedInstantMessagePacket();
                    imp.AgentData.AgentID = Client.Self.AgentID;
                    imp.AgentData.SessionID = Client.Self.SessionID;
                    imp.MessageBlock.FromGroup = false;
                    imp.MessageBlock.ToAgentID = e.IM.FromAgentID;
                    imp.MessageBlock.Offline = 0;
                    imp.MessageBlock.ID = e.IM.IMSessionID;
                    imp.MessageBlock.Timestamp = 0;
                    imp.MessageBlock.FromAgentName = Utils.StringToBytes(Client.Self.Name);
                    imp.MessageBlock.Message = Utils.EmptyBytes;
                    imp.MessageBlock.ParentEstateID = 0;
                    imp.MessageBlock.RegionID = UUID.Zero;
                    imp.MessageBlock.Position = Client.Self.SimPosition;

                    InventoryObjectOfferedEventArgs args = new InventoryObjectOfferedEventArgs(e.IM, type, objectID, fromTask, destinationFolderID);

                    OnInventoryObjectOffered(args);

                    if (args.Accept)
                    {
                        // Accept the inventory offer
                        switch (e.IM.Dialog)
                        {
                            case InstantMessageDialog.InventoryOffered:
                                imp.MessageBlock.Dialog = (byte)InstantMessageDialog.InventoryAccepted;
                                break;
                            case InstantMessageDialog.TaskInventoryOffered:
                                imp.MessageBlock.Dialog = (byte)InstantMessageDialog.TaskInventoryAccepted;
                                break;
                            case InstantMessageDialog.GroupNotice:
                                imp.MessageBlock.Dialog = (byte)InstantMessageDialog.GroupNoticeInventoryAccepted;
                                break;                         
                        }
                        imp.MessageBlock.BinaryBucket = args.FolderID.GetBytes();                        
                    }
                    else
                    {
                        // Decline the inventory offer
                        switch (e.IM.Dialog)
                        {
                            case InstantMessageDialog.InventoryOffered:
                                imp.MessageBlock.Dialog = (byte)InstantMessageDialog.InventoryDeclined;
                                break;
                            case InstantMessageDialog.TaskInventoryOffered:
                                imp.MessageBlock.Dialog = (byte)InstantMessageDialog.TaskInventoryDeclined;
                                break;
                            case InstantMessageDialog.GroupNotice:
                                imp.MessageBlock.Dialog = (byte)InstantMessageDialog.GroupNoticeInventoryDeclined;
                                break;
                        }

                        imp.MessageBlock.BinaryBucket = Utils.EmptyBytes;
                    }

                    Client.Network.SendPacket(imp, e.Simulator);
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex);
                }
            }
        }
示例#2
0
 protected virtual void OnInstantMessageReceived(OpenMetaverse.InstantMessageEventArgs e)
 {
     if (InstantMessageReceived != null)
     {
         InstantMessageReceived(this, e);
     }
 }
示例#3
0
        void Self_IM(object sender, InstantMessageEventArgs e)
        {
            bool groupIM = e.IM.GroupIM && GroupMembers != null && GroupMembers.ContainsKey(e.IM.FromAgentID) ? true : false;

            if (e.IM.FromAgentID == MasterKey || (GroupCommands && groupIM))
            {
                // Received an IM from someone that is authenticated
                Console.WriteLine("<{0} ({1})> {2}: {3} (@{4}:{5})", e.IM.GroupIM ? "GroupIM" : "IM", e.IM.Dialog, e.IM.FromAgentName, e.IM.Message, 
                    e.IM.RegionID, e.IM.Position);

                if (e.IM.Dialog == InstantMessageDialog.RequestTeleport)
                {
                    Console.WriteLine("Accepting teleport lure.");
                    Self.TeleportLureRespond(e.IM.FromAgentID, true);
                }
                else if (
                    e.IM.Dialog == InstantMessageDialog.MessageFromAgent ||
                    e.IM.Dialog == InstantMessageDialog.MessageFromObject)
                {
                    ClientManager.Instance.DoCommandAll(e.IM.Message, e.IM.FromAgentID);
                }
            }
            else
            {
                // Received an IM from someone that is not the bot's master, ignore
                Console.WriteLine("<{0} ({1})> {2} (not master): {3} (@{4}:{5})", e.IM.GroupIM ? "GroupIM" : "IM", e.IM.Dialog, e.IM.FromAgentName, e.IM.Message,
                    e.IM.RegionID, e.IM.Position);
                return;
            }
        }
示例#4
0
        //private FriendsConsole fconsole;
        public FRTabWindow(METAboltInstance instance, InstantMessageEventArgs e)
        {
            InitializeComponent();

            this.instance = instance;
            //netcom = this.instance.Netcom;
            client = this.instance.Client;
            ProcessEventArgs(e);
        }
示例#5
0
 static void Self_IM(object sender, InstantMessageEventArgs e)
 {
     if (e.IM.Dialog == InstantMessageDialog.RequestTeleport)
     {
         if (e.IM.FromAgentID == _MasterID)
         {
             _Client.Self.TeleportLureRespond(e.IM.FromAgentID, true);
         }
     }
 }
示例#6
0
 void Self_IM(object sender, InstantMessageEventArgs e)
 {
     if (e.IM.Dialog == InstantMessageDialog.RequestTeleport)
     {
         this.BeginInvoke((MethodInvoker)delegate
         {
             DialogResult result = MessageBox.Show(this, e.IM.FromAgentName + " has offered you a teleport request:" + Environment.NewLine + e.IM.Message, this.Text, MessageBoxButtons.YesNo);
             if (result == DialogResult.Yes)
                 Client.Self.TeleportLureRespond(e.IM.FromAgentID, true);
         });
     }
 }
示例#7
0
 private void Self_OnInstantMessage(object sender, OpenMetaverse.InstantMessageEventArgs ea)
 {
     try
     {
         if (netcomSync != null)
         {
             netcomSync.BeginInvoke(new OnInstantMessageRaise(OnInstantMessageReceived), new object[] { ea });
         }
         else
         {
             OnInstantMessageReceived(ea);
         }
     }
     catch (Exception exp)
     {
         OpenMetaverse.Logger.Log(exp.Message.ToString(), Helpers.LogLevel.Error);
     }
 }
示例#8
0
 private void IrcBot_IM(object sender, InstantMessageEventArgs im)
 {
     if (!client.IsRegionMaster)
     {
         return;
     }
     var e = im.IM;
     var type = e.Dialog;
     if (type == InstantMessageDialog.StartTyping || type == InstantMessageDialog.StopTyping) return;
     var message = e.Message;
     var id = e.FromAgentID;
     var fromname = e.FromAgentName;
     if (IrcCommand.IsChannelAgent(fromname)) return;
     if ((type == InstantMessageDialog.MessageFromAgent))
     {
         IrcCommand.IrcSend("" + fromname + ": " + message);
         return;
     }
     IrcCommand.IrcSend(fromname + " " + type + ": " + message);     
 }
示例#9
0
        void Self_IM(object sender, InstantMessageEventArgs e)
        {
            // Every event coming from a different thread (almost all of them, most certanly those
            // from libomv) needs to be executed on the GUI thread. This code can be basically
            // copy-pasted on the begining of each libomv event handler that results in update
            // of any GUI element
            //
            // In this case the IM we sent back as a reply is also displayed in the corresponding IM tab
            if (Instance.MainForm.InvokeRequired)
            {
                Instance.MainForm.BeginInvoke(new MethodInvoker(() => Self_IM(sender, e)));
                return;
            }

            // We need to filter out all sorts of things that come in as a instante message
            if (e.IM.Dialog == InstantMessageDialog.MessageFromAgent // Message is not notice, inv. offer, etc etc
                && !Instance.Groups.ContainsKey(e.IM.IMSessionID)  // Message is not group IM (sessionID == groupID)
                && e.IM.BinaryBucket.Length < 2                    // Session is not ad-hoc friends conference
                && e.IM.FromAgentName != "Second Life"             // Not a system message
                )
            {
                if (e.IM.Message == "demo plugin version")
                {
                    Instance.Netcom.SendInstantMessage(
                        string.Format("Hello {0}, my version is {1}", e.IM.FromAgentName, version),
                        e.IM.FromAgentID,
                        e.IM.IMSessionID);
                }
            }
        }
示例#10
0
        private void HandleGroupIM(InstantMessageEventArgs e)
        {
            // Ignore group IM from a muted group
            if (null != client.Self.MuteList.Find(me => me.Type == MuteType.Group && (me.ID == e.IM.IMSessionID || me.ID == e.IM.FromAgentID))) return;

            if (TabExists(e.IM.IMSessionID.ToString()))
            {
                RadegastTab tab = tabs[e.IM.IMSessionID.ToString()];
                if (!tab.Selected) tab.Highlight();
                return;
            }

            instance.MediaManager.PlayUISound(UISounds.IM);

            GroupIMTabWindow imTab = AddGroupIMTab(e);
            tabs[e.IM.IMSessionID.ToString()].Highlight();
        }
示例#11
0
文件: Alice.cs 项目: Nuriat/radegast
        void Self_IM(object sender, InstantMessageEventArgs e)
        {
            // Every event coming from a different thread (almost all of them, most certanly those
            // from libomv) needs to be executed on the GUI thread. This code can be basically
            // copy-pasted on the begining of each libomv event handler that results in update
            // of any GUI element
            //
            // In this case the IM we sent back as a reply is also displayed in the corresponding IM tab
            if (Instance.MainForm.InvokeRequired)
            {
                Instance.MainForm.BeginInvoke(
                    new MethodInvoker(
                        delegate()
                        {
                            Self_IM(sender, e);
                        }
                        ));
                return;
            }

            // We need to filter out all sorts of things that come in as a instante message
            if (e.IM.Dialog == InstantMessageDialog.MessageFromAgent // Message is not notice, inv. offer, etc etc
                && !Instance.Groups.ContainsKey(e.IM.IMSessionID)  // Message is not group IM (sessionID == groupID)
                && e.IM.BinaryBucket.Length < 2                    // Session is not ad-hoc friends conference
                && e.IM.FromAgentName != "Second Life"             // Not a system message
                && Alice.isAcceptingUserInput                    // Alice bot loaded successfully
                && Enabled                                       // Alice bot is enabled
                )
            {
                ThreadPool.QueueUserWorkItem(sync =>
                {
                    lock (syncChat)
                    {
                        Alice.GlobalSettings.updateSetting("location", "region " + Client.Network.CurrentSim.Name);
                        AIMLbot.User user;
                        if (AliceUsers.ContainsKey(e.IM.FromAgentName))
                        {
                            user = (AIMLbot.User)AliceUsers[e.IM.FromAgentName];
                        }
                        else
                        {
                            user = new User(e.IM.FromAgentName, Alice);
                            user.Predicates.removeSetting("name");
                            user.Predicates.addSetting("name", FirstName(e.IM.FromAgentName));
                            AliceUsers[e.IM.FromAgentName] = user;
                        }
                        AIMLbot.Request req = new Request(e.IM.Message, user, Alice);
                        AIMLbot.Result res = Alice.Chat(req);
                        string msg = res.Output;
                        if (msg.Length > 1000)
                        {
                            msg = msg.Substring(0, 1000);
                        }
                        if (EnableRandomDelay) System.Threading.Thread.Sleep(2000 + 1000 * rand.Next(3));
                        Instance.Netcom.SendIMStartTyping(e.IM.FromAgentID, e.IM.IMSessionID);
                        if (EnableRandomDelay)
                        {
                            System.Threading.Thread.Sleep(2000 + 1000 * rand.Next(5));
                        }
                        else
                        {
                            System.Threading.Thread.Sleep(1000);
                        }
                        Instance.Netcom.SendIMStopTyping(e.IM.FromAgentID, e.IM.IMSessionID);
                        if (Instance.MainForm.InvokeRequired)
                        {
                            Instance.MainForm.BeginInvoke(new MethodInvoker(() => Instance.Netcom.SendInstantMessage(msg, e.IM.FromAgentID, e.IM.IMSessionID)));
                        }
                        else
                        {
                            Instance.Netcom.SendInstantMessage(msg, e.IM.FromAgentID, e.IM.IMSessionID);
                        }
                    }
                });
            }
        }
示例#12
0
 void Self_IM(object sender, InstantMessageEventArgs e)
 {
     if (CanSyncInvoke)
         netcomSync.BeginInvoke(new OnInstantMessageRaise(OnInstantMessageReceived), new object[] { e });
     else
         OnInstantMessageReceived(e);
 }
示例#13
0
 private void Self_OnInstantMessage(object sender, InstantMessageEventArgs e)
 {
     InstantMessage im = e.IM;
     WorldObjects.GetMemberValues("", im);
     ChatType Type = ChatType.Normal;
     switch (im.Dialog)
     {
         case InstantMessageDialog.StartTyping:
             Type = ChatType.StartTyping;
             break;
         case InstantMessageDialog.StopTyping:
             Type = ChatType.StopTyping;
             break;
     }
     Self_OnMessage(im.FromAgentName, im.FromAgentID, im.ToAgentID,
                    im.Message, im.IMSessionID, im.GroupIM,
                    im.RegionID, im.Position,
                    im.Dialog, Type, e);
 }
示例#14
0
        private void netcom_InstantMessageReceived(object sender, InstantMessageEventArgs e)
        {
            if (e.IM.IMSessionID != sessionID) return;
            if (e.IM.Dialog == InstantMessageDialog.StartTyping ||
                e.IM.Dialog == InstantMessageDialog.StopTyping)
                return;

            textBuffer.Add(e);
            ProcessIM(e);
        }
示例#15
0
        static void Self_IM(object sender, InstantMessageEventArgs e)
        {
            if (e.IM.Message == "acierto")
            {
                System.Threading.Thread.Sleep(3000);
                Program.bot.decir("Vielen Dank " + Program.bot.nombre_camarero);
                System.Threading.Thread.Sleep(3000);
                Program.bot.cliente.Self.Chat("servido", CANAL_BOT2, OpenMetaverse.ChatType.Shout);

                System.Threading.Thread.Sleep(1000);
                Program.bot.ejecutarGesto(Program.bot.CELEBRACION);
                Program.consola.escribeMensaje("El camarero ha realizado la entrega bien.");
                //Program.bot.estado = 0;
                Program.bot.dejar_atender(); // Deja libre al bot.
            }
            else if (e.IM.Message == "fallo")
            {
                System.Threading.Thread.Sleep(3000);
                Program.bot.decir("Vielen Dank " + Program.bot.nombre_camarero + ", aber die Bestellung ist nicht korrekt.");
                System.Threading.Thread.Sleep(3000);
                Program.bot.cliente.Self.Chat("servido", CANAL_BOT2, OpenMetaverse.ChatType.Shout);

                System.Threading.Thread.Sleep(1000);
                Program.bot.ejecutarGesto(Program.bot.NO);
                Program.consola.escribeMensaje("El camarero ha realizado la entrega mal.");
                Program.bot.dejar_atender(); // Deja libre al bot.
            }
            else
            {
                string csv = e.IM.Message;
                string[] parts = csv.Split(',');

                int tam = parts.GetLength(0);

                if (tam > 1)
                {
                    if (parts[0] == "start")
                    {
                        Program.bot.activo = true;
                        Program.bot.setCamarero((UUID)parts[1], parts[2]);
                        Program.bot.gritar(Program.bot.nombre_camarero + " Entschuldige bitte!");
                        while (Program.bot.estado != 1 && Program.bot.activo != false)
                        {
                            Program.bot.cliente.Self.AnimationStart(Animations.HELLO, true);
                            System.Threading.Thread.Sleep(1000);
                            Program.bot.cliente.Self.AnimationStop(Animations.HELLO, true);
                            System.Threading.Thread.Sleep(1000);
                        }
                    }
                    else if (parts[0] == "resetear")
                    {
                        Program.bot.activo = false;
                        Program.bot.decir(Program.bot.nombre_camarero + " Jetzt habe ich keinen Appetit mehr!!!");
                        Program.bot.dejar_atender();
                    }
                }
                else
                {
                    Program.bot.silla = new UUID(e.IM.Message);
                }
            }
        }
示例#16
0
        void Self_IM(object sender, InstantMessageEventArgs e)
        {
            if(e.IM.Dialog!=OpenMetaverse.InstantMessageDialog.GroupNoticeRequested)
                return;

            textview_notice.Buffer.Text=e.IM.Message;
        }
示例#17
0
        /// <summary>
        /// Handle Instant Messages
        /// </summary>
        /// <param name="im"></param>
        /// <param name="simulator"></param>
        void OnInstantMessage(object sender, InstantMessageEventArgs e)
        {
            ThreadPool.QueueUserWorkItem(sync =>
                {
                    Thread.Sleep(100); // Give tab a chance to show up
                    Conversation.IMSession sess = null;
                    string groupName;

                    // All sorts of things come in as a instant messages. For actual messages
                    // we need to match them up with an existing Conversation.  IM Conversations
                    // are keyed by the name of the group or individual involved.
                    switch (e.IM.Dialog)
                    {
                        case InstantMessageDialog.MessageFromAgent:
                            if (control.instance.Groups.ContainsKey(e.IM.IMSessionID))
                            {
                                // Message from a group member
                                groupName = control.instance.Groups[e.IM.IMSessionID].Name;
                                sess = (IMSession)control.converse.GetConversation(groupName);
                                if (sess != null)
                                    sess.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message);
                                else
                                    Talker.Say(e.IM.FromAgentName + ", " + e.IM.Message);
                            }
                            else if (e.IM.BinaryBucket.Length >= 2)
                            {
                                // Ad-hoc friend conference
                                sess = (IMSession)control.converse.GetConversation(Utils.BytesToString(e.IM.BinaryBucket));
                                if (sess != null)
                                    sess.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message);
                                else
                                    Talker.Say(e.IM.FromAgentName + ", " + e.IM.Message);
                            }
                            else if (e.IM.FromAgentName == "Second Life")
                            {
                                Talker.Say("Second Life says " + e.IM.Message);
                            }
                            else
                            {
                                // Message from an individual
                                sess = (IMSession)control.converse.GetConversation(e.IM.FromAgentName);
                                if (sess != null)
                                    sess.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message);
                                else
                                    Talker.Say(e.IM.FromAgentName + ", " + e.IM.Message);
                            }
                            break;

                        case InstantMessageDialog.SessionSend:
                            if (control.instance.Groups.ContainsKey(e.IM.IMSessionID))
                            {
                                // Message from a group member
                                groupName = control.instance.Groups[e.IM.IMSessionID].Name;
                                sess = (IMSession)control.converse.GetConversation(groupName);
                            }
                            else if (e.IM.BinaryBucket.Length >= 2) // ad hoc friends conference
                            {
                                sess = (IMSession)control.converse.GetConversation(Utils.BytesToString(e.IM.BinaryBucket));
                            }

                            if (sess != null)
                                sess.OnMessage(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message);
                            break;

                        case InstantMessageDialog.FriendshipOffered:
                            Talker.Say(e.IM.FromAgentName + " is offering friendship.");
                            break;

                        default:
                            break;
                    }
                }
            );
        }
示例#18
0
        private void HandleIMFromObject(InstantMessageEventArgs e)
        {
            // Is the object or the owner muted?
            if (null != client.Self.MuteList.Find(m => (m.Type == MuteType.Object && m.ID == e.IM.IMSessionID) // muted object by id
                || (m.Type == MuteType.ByName && m.Name == e.IM.FromAgentName) // object muted by name
                || (m.Type == MuteType.Resident && m.ID == e.IM.FromAgentID) // object's owner muted
                )) return;

            DisplayNotificationInChat(e.IM.FromAgentName + ": " + e.IM.Message);
        }
示例#19
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;
            }
        }
示例#20
0
        private void HandleIM(InstantMessageEventArgs e)
        {
            bool isNew = ShowIMTab(e.IM.FromAgentID, e.IM.FromAgentName, false);
            if (!TabExists(e.IM.IMSessionID.ToString())) return; // this should now exist. sanity check anyway
            RadegastTab tab = tabs[e.IM.IMSessionID.ToString()];
            tab.Highlight();

            if (isNew)
            {
                ((IMTabWindow)tab.Control).TextManager.ProcessIM(e);
            }
        }
示例#21
0
        private void HandleGroupIM(InstantMessageEventArgs e)
        {
            // Ignore group IM from a muted group
            if (null != client.Self.MuteList.Find(me => me.Type == MuteType.Group && (me.ID == e.IM.IMSessionID || me.ID == e.IM.FromAgentID))) return;

            if (TabExists(e.IM.IMSessionID.ToString()))
            {
                RadegastTab tab = tabs[e.IM.IMSessionID.ToString()];
                tab.Highlight();
                return;
            }

            instance.MediaManager.PlayUISound(UISounds.IM);

            Control active = FindFocusedControl(instance.MainForm);

            GroupIMTabWindow imTab = AddGroupIMTab(e.IM.IMSessionID, Utils.BytesToString(e.IM.BinaryBucket));
            imTab.TextManager.ProcessIM(e);
            tabs[e.IM.IMSessionID.ToString()].Highlight();

            if (active != null)
            {
                active.Focus();
            }
        }
示例#22
0
        private void HandleConferenceIM(InstantMessageEventArgs e)
        {
            if (TabExists(e.IM.IMSessionID.ToString()))
            {
                RadegastTab tab = tabs[e.IM.IMSessionID.ToString()];
                tab.Highlight();
                return;
            }

            instance.MediaManager.PlayUISound(UISounds.IM);

            Control active = FindFocusedControl(instance.MainForm);

            ConferenceIMTabWindow imTab = AddConferenceIMTab(e.IM.IMSessionID, Utils.BytesToString(e.IM.BinaryBucket));
            tabs[e.IM.IMSessionID.ToString()].Highlight();
            imTab.TextManager.ProcessIM(e);

            if (active != null)
            {
                active.Focus();
            }
        }
示例#23
0
        private void Self_IM(object sender, InstantMessageEventArgs e)
        {
            if (e.IM.Dialog == InstantMessageDialog.FriendshipOffered)
            {
                if (m_FriendshipOffered != null)
                {
                    if (FriendRequests.ContainsKey(e.IM.FromAgentID))
                        FriendRequests[e.IM.FromAgentID] = e.IM.IMSessionID;
                    else
                        FriendRequests.Add(e.IM.FromAgentID, e.IM.IMSessionID);

                    OnFriendshipOffered(new FriendshipOfferedEventArgs(e.IM.FromAgentID, e.IM.FromAgentName, e.IM.IMSessionID));
                }
            }
            else if (e.IM.Dialog == InstantMessageDialog.FriendshipAccepted)
            {
                FriendInfo friend = new FriendInfo(e.IM.FromAgentID, FriendRights.CanSeeOnline,
                    FriendRights.CanSeeOnline);
                friend.Name = e.IM.FromAgentName;
                lock (FriendList.Dictionary) FriendList[friend.UUID] = friend;

                if (m_FriendshipResponse != null)
                {
                    OnFriendshipResponse(new FriendshipResponseEventArgs(e.IM.FromAgentID, e.IM.FromAgentName, true));
                }
                RequestOnlineNotification(e.IM.FromAgentID);
            }
            else if (e.IM.Dialog == InstantMessageDialog.FriendshipDeclined)
            {
                if (m_FriendshipResponse != null)
                {
                    OnFriendshipResponse(new FriendshipResponseEventArgs(e.IM.FromAgentID, e.IM.FromAgentName, false));
                }
            }
        }
示例#24
0
        private void HandleIM(InstantMessageEventArgs e)
        {
            if (TabExists(e.IM.IMSessionID.ToString()))
            {
                RadegastTab tab = tabs[e.IM.IMSessionID.ToString()];
                if (!tab.Selected) tab.Highlight();
                return;
            }

            instance.MediaManager.PlayUISound(UISounds.IM);

            IMTabWindow imTab = AddIMTab(e);
            tabs[e.IM.IMSessionID.ToString()].Highlight();
        }
示例#25
0
        void Self_IM(object sender, InstantMessageEventArgs e)
        {
            if(m_GroupInvitation != null && e.IM.Dialog == InstantMessageDialog.GroupInvitation)
            {
                GroupInvitationEventArgs args = new GroupInvitationEventArgs(e.Simulator, e.IM.FromAgentID, e.IM.FromAgentName, e.IM.Message);
                OnGroupInvitation(args);

                if (args.Accept)
                {
                    Client.Self.InstantMessage("name", e.IM.FromAgentID, "message", e.IM.IMSessionID, InstantMessageDialog.GroupInvitationAccept,
                         InstantMessageOnline.Online, Client.Self.SimPosition, UUID.Zero, Utils.EmptyBytes);
                }
                else
                {
                    Client.Self.InstantMessage("name", e.IM.FromAgentID, "message", e.IM.IMSessionID, InstantMessageDialog.GroupInvitationDecline,
                         InstantMessageOnline.Online, Client.Self.SimPosition, UUID.Zero, new byte[1] { 0 });
                }
            }
        }
示例#26
0
        private void netcom_InstantMessageReceived(object sender, InstantMessageEventArgs e)
        {
            if (e.IM.IMSessionID != sessionID) return;
            if (e.IM.Dialog == InstantMessageDialog.StartTyping ||
                e.IM.Dialog == InstantMessageDialog.StopTyping)
                return;

            if (instance.Client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == e.IM.FromAgentID) != null)
            {
                return;
            }

            textBuffer.Add(e);
            ProcessIM(e);
        }
示例#27
0
        private void ProcessIncomingIM(InstantMessageEventArgs e)
        {
            string msg = e.IM.Message;

            if (instance.RLV.RestictionActive("recvim", e.IM.FromAgentID.ToString()))
            {
                msg = "*** IM blocked by your viewer";

                if (Type == IMTextManagerType.Agent)
                {
                    instance.Client.Self.InstantMessage(instance.Client.Self.Name,
                            e.IM.FromAgentID,
                            "***  The Resident you messaged is prevented from reading your instant messages at the moment, please try again later.",
                            e.IM.IMSessionID,
                            InstantMessageDialog.BusyAutoResponse,
                            InstantMessageOnline.Offline,
                            instance.Client.Self.RelativePosition,
                            instance.Client.Network.CurrentSim.ID,
                            null);
                }
            }

            if (DingOnAllIncoming)
            {
                instance.MediaManager.PlayUISound(UISounds.IM);
            }
            PrintIM(DateTime.Now, instance.Names.Get(e.IM.FromAgentID, e.IM.FromAgentName), e.IM.FromAgentID, msg);

            if (!AutoResponseSent && Type == IMTextManagerType.Agent && e.IM.FromAgentID != UUID.Zero && e.IM.FromAgentName != "Second Life")
            {
                bool autoRespond = false;
                AutoResponseType art = (AutoResponseType)instance.GlobalSettings["auto_response_type"].AsInteger();

                switch (art)
                {
                    case AutoResponseType.WhenBusy: autoRespond = instance.State.IsBusy; break;
                    case AutoResponseType.WhenFromNonFriend: autoRespond = !instance.Client.Friends.FriendList.ContainsKey(e.IM.FromAgentID); break;
                    case AutoResponseType.Always: autoRespond = true; break;
                }

                if (autoRespond)
                {
                    AutoResponseSent = true;
                    instance.Client.Self.InstantMessage(instance.Client.Self.Name,
                        e.IM.FromAgentID,
                        instance.GlobalSettings["auto_response_text"].AsString(),
                        e.IM.IMSessionID,
                        InstantMessageDialog.BusyAutoResponse,
                        InstantMessageOnline.Online,
                        instance.Client.Self.RelativePosition,
                        instance.Client.Network.CurrentSim.ID,
                        null);

                    PrintIM(DateTime.Now, instance.Client.Self.Name, instance.Client.Self.AgentID, instance.GlobalSettings["auto_response_text"].AsString());
                }
            }
        }
示例#28
0
 protected virtual void OnInstantMessageReceived(InstantMessageEventArgs e)
 {
     if (InstantMessageReceived != null) InstantMessageReceived(this, e);
 }
示例#29
0
        /// <summary>
        /// Dispatcher for incoming IM automation
        /// </summary>
        /// <param name="e">Incoming message</param>
        /// <returns>If message processed correctly, should GUI processing be halted</returns>
        public bool ProcessIM(InstantMessageEventArgs e)
        {
            LoadSettings();

            if (!Enabled)
            {
                return false;
            }

            switch (e.IM.Dialog)
            {
                case InstantMessageDialog.MessageFromObject:
                    {
                        if (e.IM.FromAgentID != AllowedOwner)
                        {
                            return true;
                        }
                        string[] args = e.IM.Message.Trim().Split('^');
                        if (args.Length < 1) return false;

                        switch (args[0].Trim())
                        {
                            case "group_invite":
                                {
                                    if (args.Length < 4) return false;
                                    ProcessInvite(args);
                                    return true;
                                }
                            case "send_im":
                                {
                                    if (args.Length < 3) return false;
                                    UUID sendTo = UUID.Zero;
                                    if (!UUID.TryParse(args[1].Trim(), out sendTo)) return false;
                                    string msg = args[2].Trim();
                                    client.Self.InstantMessage(sendTo, msg);
                                    return true;
                                }
                            case "give_inventory":
                                {
                                    if (args.Length < 3) return false;
                                    UUID sendTo = UUID.Zero;
                                    UUID invItemID = UUID.Zero;
                                    if (!UUID.TryParse(args[1].Trim(), out sendTo)) return false;
                                    if (!UUID.TryParse(args[2].Trim(), out invItemID)) return false;
                                    if (!client.Inventory.Store.Contains(invItemID))
                                    {
                                        instance.TabConsole.DisplayNotificationInChat(
                                            string.Format("Tried to offer {0} but could not find it in my inventory", invItemID),
                                            ChatBufferTextStyle.Error);
                                        return false;
                                    }
                                    InventoryItem item = client.Inventory.Store[invItemID] as InventoryItem;
                                    if (item == null)
                                        return false;
                                    client.Inventory.GiveItem(item.UUID, item.Name, item.AssetType, sendTo, true);
                                    WorkPool.QueueUserWorkItem(sync =>
                                        instance.TabConsole.DisplayNotificationInChat(
                                            string.Format("Gave {0} to {1}", item.Name, instance.Names.Get(sendTo, true)),
                                            ChatBufferTextStyle.ObjectChat)
                                    );
                                    return true;
                                }
                        }
                    }
                    break;
            }

            return false;
        }
示例#30
0
        void Self_IM(object sender, InstantMessageEventArgs e)
        {
            if (e.IM.Dialog != InstantMessageDialog.GroupNoticeRequested || e.IM.FromAgentID != group.ID) return;

            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(() => Self_IM(sender, e)));
                return;
            }

            InstantMessage msg = e.IM;
            AssetType type;

            if (msg.BinaryBucket.Length > 18 && msg.BinaryBucket[0] != 0)
            {
                type = (AssetType)msg.BinaryBucket[1];
                destinationFolderID = client.Inventory.FindFolderForType(type);
                int icoIndx = InventoryConsole.GetItemImageIndex(type.ToString().ToLower());
                if (icoIndx >= 0)
                {
                    icnItem.Image = frmMain.ResourceImages.Images[icoIndx];
                    icnItem.Visible = true;
                }
                txtItemName.Text = Utils.BytesToString(msg.BinaryBucket, 18, msg.BinaryBucket.Length - 19);
                btnSave.Enabled = true;
                btnSave.Visible = icnItem.Visible = txtItemName.Visible = true;
                btnSave.Tag = msg;
            }

            string text = msg.Message.Replace("\n", System.Environment.NewLine);
            int pos = msg.Message.IndexOf('|');
            string title = msg.Message.Substring(0, pos);
            text = text.Remove(0, pos + 1);
            txtNotice.Text = text;
        }
示例#31
0
 /// <summary>Raises the IM event</summary>
 /// <param name="e">A InstantMessageEventArgs object containing the
 /// data returned from the data server</param>
 protected virtual void OnInstantMessage(InstantMessageEventArgs e)
 {
     EventHandler<InstantMessageEventArgs> handler = m_InstantMessage;
     if (handler != null)
         handler(this, e);
 }
示例#32
0
        private void ProcessEventArgs(InstantMessageEventArgs e)
        {
            targetName = e.IM.FromAgentName;
            targetUUID = e.IM.FromAgentID;
            isession = e.IM.IMSessionID;

            lblSubheading.Text =
                "You have received a Friendship invite from " + targetName + "";

            //rtbOfferMessage.AppendText(e.IM.Message);
        }