void chatMessage(FriendChatMsg_t chatMsg) { byte[] msgData = new byte[1024 * 4]; EChatEntryType chatType = EChatEntryType.k_EChatEntryTypeChatMsg; int len = steamFriends.GetChatMessage(chatMsg.m_ulReceiver, (int)chatMsg.m_iChatID, msgData, msgData.Length, ref chatType); if (chatType == EChatEntryType.k_EChatEntryTypeTyping) return; len = Clamp(len, 1, msgData.Length); ipgnBotParser.IsGroupMsg = false; ipgnBotParser.Sender = new CSteamID(chatMsg.m_ulSender); ipgnBotParser.SenderName = steamFriends.GetFriendPersonaName(ipgnBotParser.Sender); ipgnBotParser.Receiver = new CSteamID(chatMsg.m_ulReceiver); ipgnBotParser.ReceiverName = steamFriends.GetFriendPersonaName(ipgnBotParser.Receiver); ipgnBotParser.Message = Encoding.UTF8.GetString(msgData, 0, len); ipgnBotParser.Message = ipgnBotParser.Message.Substring(0, ipgnBotParser.Message.Length - 1).ToLower(); ipgnBotParser.MessageType = chatType; ipgnBotParser.MessageTime = DateTime.Now; if (!ipgnPugInterface.ipgnPugInterfaceSocket.Connected) { this.sendMessage(ipgnBotParser.Sender, "The bot is currently unavailable. Try again soon", false); return; } ipgnBotParser.parseMessage(ipgnBotParser.Message); if (ipgnBotParser.replyMessage != null) this.sendMessage(ipgnBotParser.Sender, ipgnBotParser.replyMessage, false); }
void ChatMsg( FriendChatMsg_t chatMsg ) { byte[] msgData = new byte[ 1024 * 4 ]; EChatEntryType type = EChatEntryType.k_EChatEntryTypeChatMsg; CSteamID reciever = new CSteamID( chatMsg.m_ulReceiver ); int msgLength = steamFriends.GetChatMessage( chatMsg.m_ulReceiver, ( int )chatMsg.m_iChatID, msgData, msgData.Length, ref type ); if ( type == EChatEntryType.k_EChatEntryTypeTyping ) return; msgLength = Clamp( msgLength, 1, msgData.Length ); LogMessage log = new LogMessage(); log.Sender = new CSteamID( chatMsg.m_ulSender ); log.SenderName = steamFriends.GetFriendPersonaName( log.Sender ); log.Reciever = reciever; log.RecieverName = steamFriends.GetFriendPersonaName( log.Reciever ); log.Message = Encoding.UTF8.GetString( msgData, 0, msgLength ); log.Message = log.Message.Substring( 0, log.Message.Length - 1 ); log.MessageTime = DateTime.Now; log.MessageType = type; AddLog( log ); }
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 ); } ); } }
void FriendChatMsg_OnRun( FriendChatMsg_t param ) { if ( context.SteamUser.GetSteamID() == param.m_ulSender ) return; EChatEntryType type = EChatEntryType.k_EChatEntryTypeChatMsg; context.SteamFriends.GetChatMessage( param.m_ulSender, ( int )param.m_iChatID, new byte[ 0 ], 0, ref type ); foreach ( MessageForm msgForm in this.OwnedForms ) { if ( msgForm.FriendID.SteamID == param.m_ulSender ) { msgForm.RecievedMessage( param ); if ( chkNoEscape.Checked ) { if ( type == ( EChatEntryType )6 ) { msgForm.AwayMsg( param, awayMessageBox.Text ); return; } } if ( isAway && type != EChatEntryType.k_EChatEntryTypeTyping && type != ( EChatEntryType )6 ) { msgForm.AwayMsg( param, awayMessageBox.Text ); return; } return; } } if ( type == EChatEntryType.k_EChatEntryTypeTyping || type == ( EChatEntryType )6 ) return; Friend friend = new Friend(); friend.SteamID = param.m_ulSender; friend.PersonaName = context.SteamFriends.GetFriendPersonaName( friend.SteamID ); MessageForm mf = new MessageForm( context, friend, sets ); this.Invoke( ( MethodInvoker )delegate { mf.Show( this ); mf.RecievedMessage( param ); if ( isAway ) mf.AwayMsg( param, awayMessageBox.Text ); } ); }