public void AwayMsg(FriendChatMsg_t param, string msg) { byte[] text = Encoding.ASCII.GetBytes(msg); context.SteamFriends.SendMsgToFriend(param.m_ulSender, EChatEntryType.k_EChatEntryTypeChatMsg, text, text.Length + 1); chatBox.Invoke((MethodInvoker) delegate { chatBox.AppendText(context.SteamFriends.GetPersonaName() + ": " + msg + Environment.NewLine); chatBox.ScrollToCaret(); FlashWindow.Flash(this); }); }
public void RecievedMessage(FriendChatMsg_t param) { byte[] msgData = new byte[1024 * 4]; EChatEntryType type = EChatEntryType.k_EChatEntryTypeChatMsg; int len = context.SteamFriends.GetChatMessage(param.m_ulSender, ( int )param.m_iChatID, msgData, msgData.Length, ref type); if (type == EChatEntryType.k_EChatEntryTypeTyping) { chatBox.Invoke((MethodInvoker) delegate { Text = context.SteamFriends.GetFriendPersonaName(param.m_ulSender) + " is typing a message..."; }); if (typingTimer == null) { typingTimer = new System.Threading.Timer(typingTimer_Tick, null, 10000, Timeout.Infinite); } return; } string text = ""; if (type == EChatEntryType.k_EChatEntryTypeChatMsg) { text = context.SteamFriends.GetFriendPersonaName(param.m_ulSender) + ": " + Encoding.ASCII.GetString(msgData, 0, len - 1) + Environment.NewLine; } else if (type == ( EChatEntryType )6) { text = "* " + context.SteamFriends.GetFriendPersonaName(param.m_ulSender) + " has closed the window." + Environment.NewLine; } else { text = "* " + context.SteamFriends.GetFriendPersonaName(param.m_ulSender) + " " + Encoding.ASCII.GetString(msgData, 0, len - 1) + Environment.NewLine; } chatBox.Invoke((MethodInvoker) delegate { Text = context.SteamFriends.GetFriendPersonaName(param.m_ulSender); }); chatBox.Invoke((MethodInvoker) delegate { chatBox.AppendText(text); chatBox.ScrollToCaret(); FlashWindow.Flash(this); }); if (checkBeeKeeper.Checked && type != EChatEntryType.k_EChatEntryTypeTyping && type != ( EChatEntryType )6) { txtResponses.Invoke((MethodInvoker) delegate { string[] responses = txtResponses.Text.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (responses.Length == 0) { return; } int index = rnd.Next(0, responses.Length); string resp = responses[index]; if (beeKeepTimer == null) { beeKeepTimer = new System.Threading.Timer(BeeKeeper, resp, 2000, Timeout.Infinite); } }); } }