f00f.net.irc.martyr.commands
Class CtcpMessage

java.lang.Object
  extended by f00f.net.irc.martyr.commands.AbstractInCommand
      extended by f00f.net.irc.martyr.commands.AbstractCommand
          extended by f00f.net.irc.martyr.commands.MessageCommand
              extended by f00f.net.irc.martyr.commands.CtcpMessage
All Implemented Interfaces:
Command, InCommand, OutCommand
Direct Known Subclasses:
ActionCtcp

public class CtcpMessage
extends MessageCommand

This facilitates the sending and receiving of CTCP messages. Upon receiving a message, MessageCommand checks to see if it is a CTCP, and if it is, it instantiates this class instead of a MessageCommand. You can then use the getAction() and getMessage() methods to retreive the action and payload, respectively.

See Also:
MessageCommand

Field Summary
 
Fields inherited from class f00f.net.irc.martyr.commands.AbstractInCommand
attributes
 
Constructor Summary
protected CtcpMessage(FullNick from, java.lang.String dest, java.lang.String message)
          This is only to be called by MessageCommand, as a way of receiving a Ctcp message.
  CtcpMessage(java.lang.String dest, java.lang.String message)
          Use this to send a CTCP message.
  CtcpMessage(java.lang.String dest, java.lang.String action, java.lang.String message)
           
 
Method Summary
 java.lang.String getAction()
          Returns the action of this CTCP.
static java.lang.String getActionStr(java.lang.String msg)
          Given a stripped CTCP message, returns the ctcp action string.
static java.lang.String getMessageStr(java.lang.String msg)
           
static boolean isCtcpString(java.lang.String msg)
          If the string is wrapped with CTCP signal chars (\001) returns true.
static java.lang.String stripCtcpWrapper(java.lang.String msg)
          Strips a CTCP wrapper, if there is one.
 
Methods inherited from class f00f.net.irc.martyr.commands.MessageCommand
getDest, getIrcIdentifier, getMessage, getSource, isPrivateToUs, parse, renderParams
 
Methods inherited from class f00f.net.irc.martyr.commands.AbstractCommand
render
 
Methods inherited from class f00f.net.irc.martyr.commands.AbstractInCommand
getAttribute, getAttributeKeys, getIntParameter, getParameter, getSourceString, getState, selfRegister, setAttribute, setSourceString, updateClientState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CtcpMessage

public CtcpMessage(java.lang.String dest,
                   java.lang.String message)
Use this to send a CTCP message. This simply wraps the string with the CTCP tags, \001.

Parameters:
dest - Target of CTCP message
message - Actual CTCP message

CtcpMessage

public CtcpMessage(java.lang.String dest,
                   java.lang.String action,
                   java.lang.String message)

CtcpMessage

protected CtcpMessage(FullNick from,
                      java.lang.String dest,
                      java.lang.String message)
This is only to be called by MessageCommand, as a way of receiving a Ctcp message. It strips the \001's off and holds the message left over.

Parameters:
from - Nick that sent the message
dest - Target of the CTCP message
message - Actual CTCP message
Method Detail

getAction

public java.lang.String getAction()
Returns the action of this CTCP. Use getMessage() to retreive the payload of the action.

Returns:
The action specified by the CTCP message

getActionStr

public static java.lang.String getActionStr(java.lang.String msg)
Given a stripped CTCP message, returns the ctcp action string.

Parameters:
msg - Message to be parsed into an action
Returns:
Action string from message

getMessageStr

public static java.lang.String getMessageStr(java.lang.String msg)

isCtcpString

public static boolean isCtcpString(java.lang.String msg)
If the string is wrapped with CTCP signal chars (\001) returns true.

Parameters:
msg - String to check whether it's a CTCP message or not
Returns:
True or false if it's a CTCP message

stripCtcpWrapper

public static java.lang.String stripCtcpWrapper(java.lang.String msg)
Strips a CTCP wrapper, if there is one.

Parameters:
msg - String to be stripped
Returns:
Stripped string


Copyright © 2000-2007 Ben Damm, Daniel Henninger, et al.