private void AddTextSend(ChatLogEventArgs args)
        {
            var message = new ChatMessage {
                PrevSide = _curside
            };

            if (ChatSettings.IsCustomServerConsoleNameEnabled)
            {
                message.SenderName = string.IsNullOrWhiteSpace(ChatSettings.CustomServerConsoleName) ? "Server Admin" : ChatSettings.CustomServerConsoleName;
            }
            else
            {
                message.SenderName = "Server Admin";
            }
            message.Text = args.Message;
            message.Side = MessageSide.Me;
            if (ChatSettings.IsTimestampingEnabled)
            {
                message.Timestamp = args.Timestamp;
            }
            ChatMessages.Add(message);
            _curside = MessageSide.Me;
            if (ChatSettings.IsAutoScrollEnabled)
            {
                View.ScrollConversationToEnd();
            }
        }
Exemple #2
0
        private void OnRaiseChatLog(ChatLogEventArgs e)
        {
            var handler = OnChatLog;

            if (handler == null)
            {
                return;
            }

            Console.WriteLine("Sending out chat log event for " + e.Channel + " \n" + e);
            handler(this, e);
        }
Exemple #3
0
        /// <summary>
        /// Called when [get chat message].
        /// </summary>
        /// <param name="packet">The packet.</param>
        private void OnGetChatMessage(Packet packet)
        {
            string message = packet.DataAsString();

            if (packet.Opcode == OpcodeEnum.ChatMessage)
            {
                GotChatResponse = true;
                if (message.Trim() == "Server received, But no response!!")
                {
                    return;
                }
                string[] messages = message.Split('\n');
                foreach (string newMessage in messages)
                {
                    if (string.IsNullOrWhiteSpace(newMessage))
                    {
                        continue;
                    }
                    string[] splitMessage = newMessage.Split(new char[] { ':' }, 2);

                    if (newMessage.StartsWith("SERVER:") && newMessage == "SERVER: " + LastSentAdminMessage)
                    {
                        if (SentMessageUpdated != null)
                        {
                            ChatLogEventArgs chatLog = new ChatLogEventArgs
                            {
                                Timestamp = packet.Timestamp,
                                IsAdmin   = true,
                                Message   = newMessage.Replace("SERVER: ", "")
                            };

                            SentMessageUpdated(this, chatLog);
                        }
                    }
                    else
                    {
                        if (ChatLogUpdated != null)
                        {
                            ChatLogEventArgs chatLog = new ChatLogEventArgs()
                            {
                                Message   = splitMessage[1],
                                Sender    = splitMessage[0],
                                Timestamp = packet.Timestamp,
                                IsAdmin   = false
                            };

                            ChatLogUpdated(this, chatLog);
                        }
                    }
                }
            }
        }
        private void AddTextRecieved(ChatLogEventArgs args)
        {
            var message = new ChatMessage
            {
                PrevSide   = _curside,
                SenderName = args.Sender,
                Text       = args.Message,
                Side       = MessageSide.You
            };

            if (ChatSettings.IsTimestampingEnabled)
            {
                message.Timestamp = args.Timestamp;
            }

            ChatMessages.Add(message);
            _curside = MessageSide.You;
            if (ChatSettings.IsAutoScrollEnabled)
            {
                View.ScrollConversationToEnd();
            }

            try
            {
                if (!ChatSettings.IsNotificationsEnabled || ChatSettings.NotificationString == null)
                {
                    return;
                }

                if (ChatSettings.NotificationWords.Any(s => message.Text.Contains(s)))
                {
                    ShowCustomBalloon($"{message.SenderName}: {message.Text}");
                }

                if (ChatSettings.IsFlashWindowNotificationEnabled)
                {
                    Application.Current.MainWindow.FlashWindow();
                }

                if (!ChatSettings.IsNotificationSoundFileEnabled || ChatSettings.NotificationSoundFile == null)
                {
                    return;
                }
                SoundManager.PlayFile(ChatSettings.NotificationSoundFile);
            }
            catch (Exception ex)
            {
                App.LogErrorMessage(ex);
            }
        }