|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jibble.pircbot.PircBot
PircBot is a Java framework for writing IRC bots quickly and easily.
Its features include an event-driven architecture to handle common IRC events, flood protection, DCC support, ident support, and more. Its comprehensive logfile format is suitable for use with pisg to generate channel statistics.
Methods of the PircBot class can be called to send events to the IRC server that it connects to. For example, calling the sendMessage method will send a message to a channel or user on the IRC server.
To perform an action when the PircBot receives a normal message from the IRC server, you would override the onMessage method defined in the PircBot class. All onXYZ methods in the PircBot class are automatically called when the event XYZ happens, so you would override these if you wish to do something when it does happen.
Some event methods, such as onPing, should only really perform a specific function (i.e. return a PING back to the server). For your convenience, such methods are already correctly implemented in the PircBot and should not normally need to be overridden. Please read the full documentation for each method to see which ones are already implemented by the PircBot class.
Field Summary | |
static String |
VERSION
The definitive version number of this release of PircBot. |
Constructor Summary | |
PircBot()
Constructs a PircBot with the default settings. |
Method Summary | |
void |
ban(String channel,
String hostmask)
Bans a user from a channel. |
void |
changeNick(String newNick)
Attempt to change the current nick of this user. |
void |
connect(String hostname)
Attempt to connect to the specified IRC server. |
void |
connect(String hostname,
int port)
Attempt to connect to the specified IRC server and port number. |
void |
connect(String hostname,
int port,
String password)
Attempt to connect to the specified IRC server using the supplied password. |
protected DccChat |
dccAcceptChatRequest(String sourceNick,
long address,
int port)
Attempts to accept a DCC CHAT request by a client. |
protected void |
dccReceiveFile(File file,
long address,
int port,
int size)
Receives a file that is being sent to us by a DCC SEND request. |
void |
dccSendFile(File file,
String nick,
int timeout)
Issues a DCC SEND request to the specified nick. |
void |
deOp(String channel,
String nick)
Removes operator privilidges from a user on a channel. |
void |
deVoice(String channel,
String nick)
Removes voice privilidges from a user on a channel. |
void |
disconnect()
This method disconnects from the server by closing the socket and ending the threads that read from and write to the server. |
String |
getFinger()
Gets the internal finger message of the PircBot. |
String |
getLogin()
Gets the internal login of the PircBot. |
int |
getMaxLineLength()
Gets the maximum length of any line that is sent via the IRC protocol. |
long |
getMessageDelay()
Returns the number of milliseconds that will be used to separate consecutive messages to the server from the outgoing message queue. |
String |
getName()
Gets the internal name of the PircBot. |
String |
getServer()
Returns the name of the last IRC server the PircBot tried to connect to. |
String |
getVersion()
Gets the internal version of the PircBot. |
protected void |
handleLine(String line)
This method handles events when any line of text arrives from the server, then calling the appropriate method in the PircBot. |
boolean |
isConnected()
Returns whether or not the PircBot is currently connected to a server. |
void |
joinChannel(String channel)
Joins a channel. |
void |
joinChannel(String channel,
String key)
Joins a channel with a key. |
void |
kick(String channel,
String nick)
Kicks a user from a channel. |
void |
kick(String channel,
String nick,
String reason)
Kicks a user from a channel, giving a reason. |
void |
log(String line)
Adds a line to the log. |
int[] |
longToIp(long address)
A convenient method that accepts an I.P. |
protected void |
onAction(String sender,
String login,
String hostname,
String target,
String action)
This method is called whenever an ACTION is sent from a user. |
protected void |
onConnect()
This method is called once the PircBot has successfully connected to the IRC server. |
protected void |
onDccChatRequest(String sourceNick,
String sourceLogin,
String sourceHostname,
long address,
int port)
This method is called whenever a DCC CHAT request is sent to the PircBot. |
protected void |
onDccSendRequest(String sourceNick,
String sourceLogin,
String sourceHostname,
String filename,
long address,
int port,
int size)
This method is called whenever a DCC SEND request is sent to the PircBot. |
protected void |
onDeop(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname,
String recipient)
Called when a user (possibly us) gets operator status taken away. |
protected void |
onDeVoice(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname,
String recipient)
Called when a user (possibly us) gets voice status removed. |
protected void |
onDisconnect()
This method carries out the actions to be performed when the PircBot gets disconnected. |
protected void |
onFinger(String sourceNick,
String sourceLogin,
String sourceHostname,
String target)
This method is called whenever we receive a FINGER request. |
protected void |
onInvite(String targetNick,
String sourceNick,
String sourceLogin,
String sourceHostname,
String channel)
Called when we are invited to a channel by a user. |
protected void |
onJoin(String channel,
String sender,
String login,
String hostname)
This method is called whenever someone (possibly us) joins a channel which we are on. |
protected void |
onKick(String channel,
String kickerNick,
String kickerLogin,
String kickerHostname,
String recipientNick,
String reason)
This method is called whenever someone (possibly us) is kicked from any of the channels that we are in. |
protected void |
onMessage(String channel,
String sender,
String login,
String hostname,
String message)
This method is called whenever a message is sent to a channel. |
protected void |
onMode(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname,
String mode)
Called when the mode of a channel is set. |
protected void |
onNickChange(String oldNick,
String login,
String hostname,
String newNick)
This method is called whenever someone (possibly us) changes nick on any of the channels that we are on. |
protected void |
onNotice(String sourceNick,
String sourceLogin,
String sourceHostname,
String target,
String notice)
This method is called whenever we receive a notice. |
protected void |
onOp(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname,
String recipient)
Called when a user (possibly us) gets granted operator status for a channel. |
protected void |
onPart(String channel,
String sender,
String login,
String hostname)
This method is called whenever someone (possibly us) parts a channel which we are on. |
protected void |
onPing(String sourceNick,
String sourceLogin,
String sourceHostname,
String target,
String pingValue)
This method is called whenever we receive a PING request. |
protected void |
onPrivateMessage(String sender,
String login,
String hostname,
String message)
This method is called whenever a private message is sent to the PircBot. |
protected void |
onQuit(String sourceNick,
String sourceLogin,
String sourceHostname,
String reason)
This method is called whenever someone (possibly us) quits from the server. |
protected void |
onRemoveChannelBan(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname,
String hostmask)
Called when a hostmask ban is removed from a channel. |
protected void |
onRemoveChannelKey(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname,
String key)
Called when a channel key is removed. |
protected void |
onRemoveChannelLimit(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname)
Called when the user limit is removed for a channel. |
protected void |
onRemoveInviteOnly(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname)
Called when a channel has 'invite only' removed. |
protected void |
onRemoveModerated(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname)
Called when a channel has moderated mode removed. |
protected void |
onRemoveNoExternalMessages(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname)
Called when a channel is set to allow messages from any user, even if they are not actually in the channel. |
protected void |
onRemovePrivate(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname)
Called when a channel is marked as not being in private mode. |
protected void |
onRemoveSecret(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname)
Called when a channel has 'secret' mode removed. |
protected void |
onRemoveTopicProtection(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname)
Called when topic protection is removed for a channel. |
protected void |
onServerPing(String response)
The actions to perform when a PING request comes from the server. |
protected void |
onServerResponse(int code,
String response)
This method is called when we receive a numeric response from the IRC server. |
protected void |
onSetChannelBan(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname,
String hostmask)
Called when a user (possibly us!) gets banned from a channel. |
protected void |
onSetChannelKey(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname,
String key)
Called when a channel key is set. |
protected void |
onSetChannelLimit(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname,
int limit)
Called when a user limit is set for a channel. |
protected void |
onSetInviteOnly(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname)
Called when a channel is set to 'invite only' mode. |
protected void |
onSetModerated(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname)
Called when a channel is set to 'moderated' mode. |
protected void |
onSetNoExternalMessages(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname)
Called when a channel is set to only allow messages from users that are in the channel. |
protected void |
onSetPrivate(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname)
Called when a channel is marked as being in private mode. |
protected void |
onSetSecret(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname)
Called when a channel is set to be in 'secret' mode. |
protected void |
onSetTopicProtection(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname)
Called when topic protection is enabled for a channel. |
protected void |
onTime(String sourceNick,
String sourceLogin,
String sourceHostname,
String target)
This method is called whenever we receive a TIME request. |
protected void |
onUnknown(String line)
This method is called whenever we receive a line from the server that the PircBot has not been programmed to recognise. |
protected void |
onVersion(String sourceNick,
String sourceLogin,
String sourceHostname,
String target)
This method is called whenever we receive a VERSION request. |
protected void |
onVoice(String channel,
String sourceNick,
String sourceLogin,
String sourceHostname,
String recipient)
Called when a user (possibly us) gets voice status granted in a channel. |
void |
op(String channel,
String nick)
Grants operator privilidges to a user on a channel. |
void |
partChannel(String channel)
Parts a channel. |
void |
partChannel(String channel,
String reason)
Parts a channel, giving a reason. |
void |
quitServer()
Quits from the IRC server. |
void |
quitServer(String reason)
Quits from the IRC server with a reason. |
void |
sendAction(String target,
String action)
Sends an action to the channel or to a user. |
void |
sendCTCPCommand(String target,
String command)
Sends a CTCP command to a channel or user. |
void |
sendInvite(String nick,
String channel)
Sends an invitation to join a channel. |
void |
sendMessage(String target,
String message)
Sends a message to a channel or a private message to a user. |
void |
sendNotice(String target,
String notice)
Sends a notice to the channel or to a user. |
void |
sendRawLine(String line)
Sends a raw line to the IRC server as soon as possible, bypassing the outgoing message queue. |
protected void |
setFinger(String finger)
Sets the interal finger message. |
protected void |
setLogin(String login)
Sets the interal login of the Bot. |
void |
setMessageDelay(long delay)
Sets the number of milliseconds to delay between consecutive messages when there are multiple messages waiting in the outgoing message queue. |
void |
setMode(String channel,
String mode)
Set the mode of a channel. |
protected void |
setName(String name)
Sets the internal name of the Bot. |
void |
setTopic(String channel,
String topic)
Set the topic for a channel. |
void |
setVerbose(boolean verbose)
Sets the verbose mode. |
protected void |
setVersion(String version)
Sets the internal version of the Bot. |
void |
startIdentServer()
Starts an ident server (Identification Protocol Server, RFC 1413). |
void |
unBan(String channel,
String hostmask)
Unbans a user from a channel. |
void |
voice(String channel,
String nick)
Grants voice privilidges to a user on a channel. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String VERSION
Constructor Detail |
public PircBot()
Method Detail |
public final void connect(String hostname) throws IOException, IrcException, NickAlreadyInUseException
hostname
- The hostname of the server to connect to.
IOException
- if it was not possible to connect to the server.
IrcException
- if the server would not let us join it.
NickAlreadyInUseException
- if our nick is already in use on the server.public final void connect(String hostname, int port) throws IOException, IrcException, NickAlreadyInUseException
hostname
- The hostname of the server to connect to.port
- The port number to connect to on the server.
IOException
- if it was not possible to connect to the server.
IrcException
- if the server would not let us join it.
NickAlreadyInUseException
- if our nick is already in use on the server.public final void connect(String hostname, int port, String password) throws IOException, IrcException, NickAlreadyInUseException
hostname
- The hostname of the server to connect to.port
- The port number to connect to on the server.password
- The password to use to join the server.
IOException
- if it was not possible to connect to the server.
IrcException
- if the server would not let us join it.
NickAlreadyInUseException
- if our nick is already in use on the server.public final void disconnect()
public void startIdentServer()
Most IRC servers attempt to contact the ident server on connecting hosts in order to determine the user's identity. A few IRC servers will not allow you to connect unless this information is provided.
So when a PircBot is run on a machine that does not run an ident server, it may be necessary to call this method to start one up.
Calling this method starts up an ident server which will respond with the login provided by calling getLogin() and then shut down immediately. It will also be shut down if it has not been contacted within 60 seconds of creation.
If you require an ident response, then the correct procedure is to start the ident server and then connect to the IRC server. The IRC server may then contact the ident server to get the information it needs.
The ident server will fail to start if there is already an ident server running on port 113, or if you are running as an unprivileged user who is unable to create a server socket on that port number.
If it is essential for you to use an ident server when connecting to an IRC server, then make sure that port 113 on your machine is visible to the IRC server so that it may contact the ident server.
public final void joinChannel(String channel)
channel
- The name of the channel to join (eg "#cs").public final void joinChannel(String channel, String key)
channel
- The name of the channel to join (eg "#cs").key
- The key that will be used to join the channel.public final void partChannel(String channel)
channel
- The name of the channel to leave.public final void partChannel(String channel, String reason)
channel
- The name of the channel to leave.reason
- The reason for parting the channel.public final void quitServer()
public final void quitServer(String reason)
reason
- The reason for quitting the server.public final void sendRawLine(String line)
line
- The raw line to send to the IRC server.public final void sendMessage(String target, String message)
target
- The name of the channel or user nick to send to.message
- The message to send.public final void sendAction(String target, String action)
target
- The name of the channel or user nick to send to.action
- The action to send.public final void sendNotice(String target, String notice)
target
- The name of the channel or user nick to send to.notice
- The notice to send.public final void sendCTCPCommand(String target, String command)
sendCTCPCommand("Dave", "PING");
. The type of response to
such commands is largely dependant on the target client software.
target
- The name of the channel or user to send the CTCP message to.command
- The CTCP command to send.public final void changeNick(String newNick)
newNick
- The new nick to use.public final void setMode(String channel, String mode)
channel
- The channel on which to perform the mode change.mode
- The new mode to apply to the channel. This may include
zero or more arguments if necessary.public final void sendInvite(String nick, String channel)
nick
- The nick of the user to invitechannel
- The channel you are inviting the user to join.public final void ban(String channel, String hostmask)
channel
- The channel to ban the user from.hostmask
- A hostmask representing the user we're banning.public final void unBan(String channel, String hostmask)
channel
- The channel to unban the user from.hostmask
- A hostmask representing the user we're unbanning.public final void op(String channel, String nick)
channel
- The channel we're opping the user on.nick
- The nick of the user we are opping.public final void deOp(String channel, String nick)
channel
- The channel we're deopping the user on.nick
- The nick of the user we are deopping.public final void voice(String channel, String nick)
channel
- The channel we're voicing the user on.nick
- The nick of the user we are voicing.public final void deVoice(String channel, String nick)
channel
- The channel we're devoicing the user on.nick
- The nick of the user we are devoicing.public final void setTopic(String channel, String topic)
channel
- The channel on which to perform the mode change.topic
- The new topic for the channel.public final void kick(String channel, String nick)
channel
- The channel to kick the user from.nick
- The nick of the user to kick.public final void kick(String channel, String nick, String reason)
channel
- The channel to kick the user from.nick
- The nick of the user to kick.reason
- A description of the reason for kicking a user.public final void dccSendFile(File file, String nick, int timeout)
nick
- The nick of the recipient.timeout
- The number of milliseconds to wait for the recipient to
accept the file (we recommend about 120000ms).protected final void dccReceiveFile(File file, long address, int port, int size)
address
- The host address of the initiator as an integer.port
- The port number to connect to in order to download the file.size
- The size of the file. If not known, this must be -1.protected final DccChat dccAcceptChatRequest(String sourceNick, long address, int port)
public void log(String line)
This implementation of the method will only cause log entries to be output if the PircBot has had its verbose mode turned on by calling setVerbose(true);
line
- The line to add to the log.protected final void handleLine(String line)
line
- The raw line of text from the server.protected void onConnect()
protected void onDisconnect()
protected void onServerResponse(int code, String response)
Numerics in the range from 001 to 099 are used for client-server connections only and should never travel between servers. Replies generated in response to commands are found in the range from 200 to 399. Error replies are found in the range from 400 to 599.
For example, we can use this method to discover the topic of a
channel when we join it. If we join the channel #test which
has a topic of "I am King of Test" then the response
will be "PircBot #test :I Am King of Test
"
with a code of 332 to signify that this is a topic. Check the
IRC RFC for the full list of command response codes.
The implementation of this method in the PircBot abstract class performs no actions and may be overridden as required.
code
- The three-digit numerical code for the response.response
- The full response from the IRC server.protected void onServerPing(String response)
response
- The response that should be given back in your PONG.protected void onMessage(String channel, String sender, String login, String hostname, String message)
channel
- The channel to which the message was sent.sender
- The nick of the person who sent the message.login
- The login of the person who sent the message.hostname
- The hostname of the person who sent the message.message
- The actual message sent to the channel.protected void onPrivateMessage(String sender, String login, String hostname, String message)
sender
- The nick of the person who sent the private message.login
- The login of the person who sent the private message.hostname
- The hostname of the person who sent the private message.message
- The actual message.protected void onAction(String sender, String login, String hostname, String target, String action)
sender
- The nick of the user that sent the action.login
- The login of the user that sent the action.hostname
- The hostname of the user that sent the action.target
- The target of the action, be it a channel or our nick.action
- The action carried out by the user.protected void onJoin(String channel, String sender, String login, String hostname)
channel
- The channel which somebody joined.sender
- The nick of the user who joined the channel.login
- The login of the user who joined the channel.hostname
- The hostname of the user who joined the channel.protected void onPart(String channel, String sender, String login, String hostname)
channel
- The channel which somebody parted from.sender
- The nick of the user who parted from the channel.login
- The login of the user who parted from the channel.hostname
- The hostname of the user who parted from the channel.protected void onNickChange(String oldNick, String login, String hostname, String newNick)
oldNick
- The old nick.login
- The login of the user.hostname
- The hostname of the user.newNick
- The new nick.protected void onKick(String channel, String kickerNick, String kickerLogin, String kickerHostname, String recipientNick, String reason)
channel
- The channel from which the recipient was kicked.kickerNick
- The nick of the user who performed the kick.kickerLogin
- The login of the user who performed the kick.kickerHostname
- The hostname of the user who performed the kick.reason
- The reason given by the user who performed the kick.protected void onQuit(String sourceNick, String sourceLogin, String sourceHostname, String reason)
sourceNick
- The nick of the user that quit from the server.sourceLogin
- The login of the user that quit from the server.sourceHostname
- The hostname of the user that quit from the server.reason
- The reason given for quitting the server.protected void onMode(String channel, String sourceNick, String sourceLogin, String sourceHostname, String mode)
If you override this method, be sure to call super.onMode(...) in order to make sure that the appropriate onXxx methods are also called.
channel
- The channel that the mode operation applies to.sourceNick
- The nick of the user that set the mode.sourceLogin
- The login of the user that set the mode.sourceHostname
- The hostname of the user that set the mode.mode
- The mode that has been set.protected void onOp(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.recipient
- The nick of the user that got 'opped'.protected void onDeop(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.recipient
- The nick of the user that got 'deopped'.protected void onVoice(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.recipient
- The nick of the user that got 'voiced'.protected void onDeVoice(String channel, String sourceNick, String sourceLogin, String sourceHostname, String recipient)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.recipient
- The nick of the user that got 'devoiced'.protected void onSetChannelKey(String channel, String sourceNick, String sourceLogin, String sourceHostname, String key)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.key
- The new key for the channel.protected void onRemoveChannelKey(String channel, String sourceNick, String sourceLogin, String sourceHostname, String key)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.key
- The key that was in use before the channel key was removed.protected void onSetChannelLimit(String channel, String sourceNick, String sourceLogin, String sourceHostname, int limit)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.limit
- The maximum number of users that may be in this channel at the same time.protected void onRemoveChannelLimit(String channel, String sourceNick, String sourceLogin, String sourceHostname)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.protected void onSetChannelBan(String channel, String sourceNick, String sourceLogin, String sourceHostname, String hostmask)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.hostmask
- The hostmask of the user that has been banned.protected void onRemoveChannelBan(String channel, String sourceNick, String sourceLogin, String sourceHostname, String hostmask)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.hostmask
- protected void onSetTopicProtection(String channel, String sourceNick, String sourceLogin, String sourceHostname)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.protected void onRemoveTopicProtection(String channel, String sourceNick, String sourceLogin, String sourceHostname)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.protected void onSetNoExternalMessages(String channel, String sourceNick, String sourceLogin, String sourceHostname)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.protected void onRemoveNoExternalMessages(String channel, String sourceNick, String sourceLogin, String sourceHostname)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.protected void onSetInviteOnly(String channel, String sourceNick, String sourceLogin, String sourceHostname)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.protected void onRemoveInviteOnly(String channel, String sourceNick, String sourceLogin, String sourceHostname)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.protected void onSetModerated(String channel, String sourceNick, String sourceLogin, String sourceHostname)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.protected void onRemoveModerated(String channel, String sourceNick, String sourceLogin, String sourceHostname)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.protected void onSetPrivate(String channel, String sourceNick, String sourceLogin, String sourceHostname)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.protected void onRemovePrivate(String channel, String sourceNick, String sourceLogin, String sourceHostname)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.protected void onSetSecret(String channel, String sourceNick, String sourceLogin, String sourceHostname)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.protected void onRemoveSecret(String channel, String sourceNick, String sourceLogin, String sourceHostname)
channel
- The channel in which the mode change took place.sourceNick
- The nick of the user that performed the mode change.sourceLogin
- The login of the user that performed the mode change.sourceHostname
- The hostname of the user that performed the mode change.protected void onInvite(String targetNick, String sourceNick, String sourceLogin, String sourceHostname, String channel)
targetNick
- The nick of the user being invited - should be us!sourceNick
- The nick of the user that sent the invitation.sourceLogin
- The login of the user that sent the invitation.sourceHostname
- The hostname of the user that sent the invitation.channel
- The channel that we're being invited to.protected void onDccSendRequest(String sourceNick, String sourceLogin, String sourceHostname, String filename, long address, int port, int size)
public void onDccSendRequest(String sender, String login, String hostname, String filename, int address, int port, int size) {
// Check to see if we trust the sender first?
// Check that the filename isn't going to overwrite anything important?
dccReceiveFile(new File(filename), address, port, size);
// Method finishes when the download completes or if it fails.
}
Each time this method is called, it is called from within a new Thread in order to allow multiple files to be downloaded by the PircBot at the same time. Warning: Implementing this method and subsequently calling the dccReceiveFile method will cause a file to be written to disk. Please ensure that you make adequate security checks to make sure that this file will not overwrite anything important! The implementation of this method in the PircBot abstract class performs no actions and may be overridden as required.
filename
- The suggested filename to be used when saving the file.address
- The host address of the initiator as an integer.port
- The port number to connect to if we want to receive the file.size
- The size of the file in bytes. Older clients do not support
this, in which case a value of -1 will be used.protected void onDccChatRequest(String sourceNick, String sourceLogin, String sourceHostname, long address, int port)
public void onDccChatRequest(String sourceNick, String sourceLogin, String sourceHostname, long address, int port) {
// Check to see if we want to accept the chat connection first?
DccChat chat = dccAcceptChatRequest(sourceNick, address, port);
if (chat != null) {
try {
chat.sendLine(Hi, what's your name?");
String name = chat.readLine();
chat.sendLine("Hello, " + name);
chat.close();
}
catch (IOException e) {
// The connection was lost
}
}
}
Each time this method is called, it is called from within a new Thread in order to allow multiple DCC Chat sessions to run at the same time.
The implementation of this method in the PircBot abstract class performs no actions and may be overridden as required.
address
- The host address of the initiator as an integer.port
- The port number to connect to if we want to chat.protected void onVersion(String sourceNick, String sourceLogin, String sourceHostname, String target)
sourceNick
- The nick of the user that sent the VERSION request.sourceLogin
- The login of the user that sent the VERSION request.sourceHostname
- The hostname of the user that sent the VERSION request.target
- The target of the VERSION request, be it our nick or a channel name.protected void onPing(String sourceNick, String sourceLogin, String sourceHostname, String target, String pingValue)
sourceNick
- The nick of the user that sent the PING request.sourceLogin
- The login of the user that sent the PING request.sourceHostname
- The hostname of the user that sent the PING request.target
- The target of the PING request, be it our nick or a channel name.pingValue
- The value that was supplied as an argument to the PING command.protected void onTime(String sourceNick, String sourceLogin, String sourceHostname, String target)
sourceNick
- The nick of the user that sent the TIME request.sourceLogin
- The login of the user that sent the TIME request.sourceHostname
- The hostname of the user that sent the TIME request.target
- The target of the TIME request, be it our nick or a channel name.protected void onFinger(String sourceNick, String sourceLogin, String sourceHostname, String target)
sourceNick
- The nick of the user that sent the FINGER request.sourceLogin
- The login of the user that sent the FINGER request.sourceHostname
- The hostname of the user that sent the FINGER request.target
- The target of the FINGER request, be it our nick or a channel name.protected void onNotice(String sourceNick, String sourceLogin, String sourceHostname, String target, String notice)
sourceNick
- The nick of the user that sent the notice.sourceLogin
- The login of the user that sent the notice.sourceHostname
- The hostname of the user that sent the notice.target
- The target of the notice, be it our nick or a channel name.notice
- The notice message.protected void onUnknown(String line)
line
- The raw line that was received from the server.public final void setVerbose(boolean verbose)
verbose
- true if verbose mode is to be used. Default is false.protected final void setName(String name)
name
- The new name of the Bot.protected final void setLogin(String login)
login
- The new login of the Bot.protected final void setVersion(String version)
version
- The new version of the Bot.protected final void setFinger(String finger)
finger
- The new finger message for the Bot.public final String getName()
public final String getLogin()
public final String getVersion()
public final String getFinger()
public final boolean isConnected()
public final void setMessageDelay(long delay)
delay
- The number of milliseconds between each outgoing message.public final long getMessageDelay()
public final int getMaxLineLength()
public final String getServer()
public int[] longToIp(long address)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |