// Outbound Chat or a Console Command public void OnInput(IRCPrivmsgEvent privmsgEvent, PostProcessChatDelegate postProcessChat) { int n = privmsgEvent.Message.IndexOf("/"); int n2 = privmsgEvent.Message.IndexOf("me", 0); //no action? if (n == 0 && n2 != 1) // this is a little hack because /me is not handled like a command { try { ProcessInput(privmsgEvent.Message); } catch (Exception e) { m_lastActiveMessage = e.Message; DispatchEvent(new IRCEvent(IRCEvent.EVENT_ACTIVEMESSAGE)); } } else { IRCPrivmsgEvent newPrivmsgEvent = new IRCPrivmsgEvent(); string str = ""; string finalMesg = ""; if (n2 != 1) { // message finalMesg = (postProcessChat != null) ? postProcessChat(privmsgEvent.Message) : privmsgEvent.Message; str = "PRIVMSG " + privmsgEvent.Channel + " :" + finalMesg; newPrivmsgEvent.Message = finalMesg; } else { // action string sourceMesg = privmsgEvent.Message.Substring(4); str = "PRIVMSG " + privmsgEvent.Channel + " :\u0001ACTION " + sourceMesg + "\u0001"; newPrivmsgEvent.Message = "\u0001ACTION " + sourceMesg + "\u0001"; } m_socket.SendString(str); newPrivmsgEvent.Channel = privmsgEvent.Channel; newPrivmsgEvent.User = new IRCUser(); newPrivmsgEvent.User.Nick = m_nickName; newPrivmsgEvent.User.Ident = ""; newPrivmsgEvent.User.Host = ""; DispatchEvent(newPrivmsgEvent); } }
// Outbound Chat or a Console Command public void OnInput( IRCPrivmsgEvent privmsgEvent, PostProcessChatDelegate postProcessChat) { int n = privmsgEvent.Message.IndexOf( "/" ); int n2 = privmsgEvent.Message.IndexOf( "me", 0 ); //no action? if ( n == 0 && n2 != 1 ) // this is a little hack because /me is not handled like a command { try { ProcessInput( privmsgEvent.Message ); } catch ( Exception e ) { m_lastActiveMessage = e.Message; DispatchEvent( new IRCEvent( IRCEvent.EVENT_ACTIVEMESSAGE ) ); } } else { IRCPrivmsgEvent newPrivmsgEvent = new IRCPrivmsgEvent(); string str= ""; string finalMesg= ""; if ( n2 != 1 ) { // message finalMesg = (postProcessChat != null) ? postProcessChat(privmsgEvent.Message) : privmsgEvent.Message; str = "PRIVMSG " + privmsgEvent.Channel + " :" + finalMesg; newPrivmsgEvent.Message = finalMesg; } else { // action string sourceMesg = privmsgEvent.Message.Substring( 4 ); str = "PRIVMSG " + privmsgEvent.Channel + " :\u0001ACTION " + sourceMesg + "\u0001"; newPrivmsgEvent.Message = "\u0001ACTION " + sourceMesg + "\u0001"; } m_socket.SendString( str ); newPrivmsgEvent.Channel = privmsgEvent.Channel; newPrivmsgEvent.User = new IRCUser(); newPrivmsgEvent.User.Nick = m_nickName; newPrivmsgEvent.User.Ident = ""; newPrivmsgEvent.User.Host = ""; DispatchEvent( newPrivmsgEvent ); } }