//chat message event fires whenever we receive an actual message
        private static void OnChatMessage(object sender, ChatMessageArgs e)
        {
            switch (e.ChatMessage.Text.ToLower())
            {
                case "!utc":
                    ChatHandler.Message(IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom), "saytext",
                        "The current UTC timestamp is: " + e.ChatMessage.UtcTimestamp);
                    return;
                case "!timestamp":
                    ChatHandler.Message(IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom), "saytext",
                        "The current timestamp is: " + e.ChatMessage.Timestamp);
                    return;
                case "!myfriendcount":
                    List<Friend> friends = SteamUserHandler.GetFriendList(IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom), "friend");
                    if (friends == null) throw new ArgumentNullException(nameof(friends));
                    ChatHandler.Message(IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom), "saytext",
                        "You have " + friends.Count + " friends.");
                    return;
                case "!logoff":
                    ChatEventsManager.EndMessageLoop();
                    ChatHandler.Logoff();
                    return;
                //more commands...
            }

            //actual messages etc...
            ChatHandler.Message(IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom), "saytext",
                "Hello!");
        }
 void OnChatMessage(object sender, ChatMessageArgs e)
 {
     ChatControl control = FindMatchingChatControl(IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom));
     if (control == null) return;
     InvokeHandleMessage(control, e.ChatMessage.Text);
 }
        void OnMessage(object sender, ChatMessageArgs e)
        {
            CheckCreateChatWindow();

            PlayerSummary summary =
                FriendSummaries.FirstOrDefault(
                    x => x.SteamId == IdConversions.AccountIdToUlong(e.ChatMessage.AccountIdFrom));

            if (summary == null)
            {
                MessageBox.Show("I was lazy and I don't poll for new friends. They attempted to send you a message.");
                return;
            }

            List<FriendControl> friendControls = new List<FriendControl>();
            ChatUser friend = null;

            friendsStackPanel.Dispatcher.Invoke(() =>
            {
                friendControls = friendsStackPanel.Children.Cast<FriendControl>().ToList();
            });

            foreach (FriendControl control in friendControls)
            {
                ulong steamId = 0;
                control.Dispatcher.Invoke(() => { steamId = control.Friend.Summary.SteamId; });
                if (steamId != summary.SteamId) continue;
                control.Dispatcher.Invoke(() => { friend = control.Friend; });
                break;
            }

            if (friend == null) throw new Exception("Could not locate friend, please report this!");

            ChatWindow.AddChatWindow(friend, e.ChatMessage.Text);
        }