예제 #1
0
        /// <summary>
        /// Displays notification in the main chat tab
        /// </summary>
        /// <param name="msg">Message to be printed in the chat tab</param>
        /// <param name="style">Style of the message to be printed, normal, object, etc.</param>
        /// <param name="highlightChatTab">Highligt (and flash in taskbar) chat tab if not selected</param>
        public void DisplayNotificationInChat(string msg, ChatBufferTextStyle style, bool highlightChatTab)
        {
            if (InvokeRequired)
            {
                if (!instance.MonoRuntime || IsHandleCreated)
                {
                    BeginInvoke(new MethodInvoker(() => DisplayNotificationInChat(msg, style, highlightChatTab)));
                }
                return;
            }

            if (style != ChatBufferTextStyle.Invisible)
            {
                ChatBufferItem line = new ChatBufferItem(
                    DateTime.Now,
                    string.Empty,
                    UUID.Zero,
                    msg,
                    style
                    );

                try
                {
                    mainChatManger.ProcessBufferItem(line, true);
                    if (highlightChatTab)
                    {
                        tabs["chat"].Highlight();
                    }
                }
                catch (Exception) { }
            }

            if (OnChatNotification != null)
            {
                try { OnChatNotification(this, new ChatNotificationEventArgs(msg, style)); }
                catch { }
            }
        }
예제 #2
0
 public ChatLineAddedArgs(ChatBufferItem item)
 {
     mItem = item;
 }
예제 #3
0
        private void ProcessIncomingChat(ChatEventArgs e)
        {
            if (string.IsNullOrEmpty(e.Message))
            {
                return;
            }

            // Check if the sender agent is muted
            if (e.SourceType == ChatSourceType.Agent &&
                null != client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == e.SourceID)
                )
            {
                return;
            }

            // Check if it's script debug
            if (e.Type == ChatType.Debug && !instance.GlobalSettings["show_script_errors"])
            {
                return;
            }

            // Check if sender object is muted
            if (e.SourceType == ChatSourceType.Object &&
                null != client.Self.MuteList.Find(me =>
                                                  (me.Type == MuteType.Resident && me.ID == e.OwnerID) || // Owner muted
                                                  (me.Type == MuteType.Object && me.ID == e.SourceID) || // Object muted by ID
                                                  (me.Type == MuteType.ByName && me.Name == e.FromName) // Object muted by name
                                                  ))
            {
                return;
            }

            if (instance.RLV.Enabled && e.Message.StartsWith("@"))
            {
                instance.RLV.TryProcessCMD(e);
#if !DEBUG
                return;
#endif
            }

            ChatBufferItem item = new ChatBufferItem();
            item.ID         = e.SourceID;
            item.RawMessage = e;
            StringBuilder sb = new StringBuilder();

            if (e.SourceType == ChatSourceType.Agent)
            {
                item.From = instance.Names.Get(e.SourceID, e.FromName);
            }
            else
            {
                item.From = e.FromName;
            }

            bool isEmote = e.Message.ToLower().StartsWith("/me ");

            if (!isEmote)
            {
                switch (e.Type)
                {
                case ChatType.Whisper:
                    sb.Append(" whispers");
                    break;

                case ChatType.Shout:
                    sb.Append(" shouts");
                    break;
                }
            }

            if (isEmote)
            {
                if (e.SourceType == ChatSourceType.Agent && instance.RLV.RestictionActive("recvemote", e.SourceID.ToString()))
                {
                    sb.Append(" ...");
                }
                else
                {
                    sb.Append(e.Message.Substring(3));
                }
            }
            else
            {
                sb.Append(": ");
                if (e.SourceType == ChatSourceType.Agent && !e.Message.StartsWith("/") && instance.RLV.RestictionActive("recvchat", e.SourceID.ToString()))
                {
                    sb.Append("...");
                }
                else
                {
                    sb.Append(e.Message);
                }
            }

            item.Timestamp = DateTime.Now;
            item.Text      = sb.ToString();

            switch (e.SourceType)
            {
            case ChatSourceType.Agent:
                item.Style =
                    (e.FromName.EndsWith("Linden") ?
                     ChatBufferTextStyle.LindenChat : ChatBufferTextStyle.Normal);
                break;

            case ChatSourceType.Object:
                if (e.Type == ChatType.OwnerSay)
                {
                    item.Style = ChatBufferTextStyle.OwnerSay;
                }
                else if (e.Type == ChatType.Debug)
                {
                    item.Style = ChatBufferTextStyle.Error;
                }
                else
                {
                    item.Style = ChatBufferTextStyle.ObjectChat;
                }
                break;
            }

            ProcessBufferItem(item, true);
            instance.TabConsole.Tabs["chat"].Highlight();

            sb = null;
        }
예제 #4
0
        public void ProcessBufferItem(ChatBufferItem item, bool addToBuffer)
        {
            if (ChatLineAdded != null)
            {
                ChatLineAdded(this, new ChatLineAddedArgs(item));
            }

            lock (SyncChat)
            {
                instance.LogClientMessage("chat.txt", item.From + item.Text);
                if (addToBuffer)
                {
                    textBuffer.Add(item);
                }

                if (showTimestamps)
                {
                    textPrinter.ForeColor = SystemColors.GrayText;
                    textPrinter.PrintText(item.Timestamp.ToString("[HH:mm] "));
                }

                switch (item.Style)
                {
                case ChatBufferTextStyle.Normal:
                    textPrinter.ForeColor = SystemColors.WindowText;
                    break;

                case ChatBufferTextStyle.StatusBlue:
                    textPrinter.ForeColor = Color.Blue;
                    break;

                case ChatBufferTextStyle.StatusDarkBlue:
                    textPrinter.ForeColor = Color.DarkBlue;
                    break;

                case ChatBufferTextStyle.LindenChat:
                    textPrinter.ForeColor = Color.DarkGreen;
                    break;

                case ChatBufferTextStyle.ObjectChat:
                    textPrinter.ForeColor = Color.DarkCyan;
                    break;

                case ChatBufferTextStyle.StartupTitle:
                    textPrinter.ForeColor = SystemColors.WindowText;
                    textPrinter.Font      = new Font(textPrinter.Font, FontStyle.Bold);
                    break;

                case ChatBufferTextStyle.Alert:
                    textPrinter.ForeColor = Color.DarkRed;
                    break;

                case ChatBufferTextStyle.Error:
                    textPrinter.ForeColor = Color.Red;
                    break;

                case ChatBufferTextStyle.OwnerSay:
                    textPrinter.ForeColor = Color.FromArgb(255, 180, 150, 0);
                    break;
                }

                if (item.Style == ChatBufferTextStyle.Normal && item.ID != UUID.Zero && instance.GlobalSettings["av_name_link"])
                {
                    textPrinter.InsertLink(item.From, string.Format("secondlife:///app/agent/{0}/about", item.ID));
                    textPrinter.PrintTextLine(item.Text);
                }
                else
                {
                    textPrinter.PrintTextLine(item.From + item.Text);
                }
            }
        }