uk.org.iscream.cms.server.client.alerters
Class IRC__Alerter.IRCBot
java.lang.Object
|
+--org.jibble.pircbot.PircBot
|
+--uk.org.iscream.cms.server.client.alerters.IRC__Alerter.IRCBot
- All Implemented Interfaces:
- ReplyConstants, Runnable
- Enclosing class:
- IRC__Alerter
- class IRC__Alerter.IRCBot
- extends PircBot
- implements Runnable
Fields inherited from interface org.jibble.pircbot.ReplyConstants |
ERR_ALREADYREGISTRED, ERR_BADCHANMASK, ERR_BADCHANNELKEY, ERR_BANNEDFROMCHAN, ERR_CANNOTSENDTOCHAN, ERR_CANTKILLSERVER, ERR_CHANNELISFULL, ERR_CHANOPRIVSNEEDED, ERR_ERRONEUSNICKNAME, ERR_FILEERROR, ERR_INVITEONLYCHAN, ERR_KEYSET, ERR_NEEDMOREPARAMS, ERR_NICKCOLLISION, ERR_NICKNAMEINUSE, ERR_NOADMININFO, ERR_NOLOGIN, ERR_NOMOTD, ERR_NONICKNAMEGIVEN, ERR_NOOPERHOST, ERR_NOORIGIN, ERR_NOPERMFORHOST, ERR_NOPRIVILEGES, ERR_NORECIPIENT, ERR_NOSERVICEHOST, ERR_NOSUCHCHANNEL, ERR_NOSUCHNICK, ERR_NOSUCHSERVER, ERR_NOTEXTTOSEND, ERR_NOTONCHANNEL, ERR_NOTOPLEVEL, ERR_NOTREGISTERED, ERR_PASSWDMISMATCH, ERR_SUMMONDISABLED, ERR_TOOMANYCHANNELS, ERR_TOOMANYTARGETS, ERR_UMODEUNKNOWNFLAG, ERR_UNKNOWNCOMMAND, ERR_UNKNOWNMODE, ERR_USERNOTINCHANNEL, ERR_USERONCHANNEL, ERR_USERSDISABLED, ERR_USERSDONTMATCH, ERR_WASNOSUCHNICK, ERR_WILDTOPLEVEL, ERR_YOUREBANNEDCREEP, ERR_YOUWILLBEBANNED, RPL_ADMINEMAIL, RPL_ADMINLOC1, RPL_ADMINLOC2, RPL_ADMINME, RPL_AWAY, RPL_BANLIST, RPL_CHANNELMODEIS, RPL_CLOSEEND, RPL_CLOSING, RPL_ENDOFBANLIST, RPL_ENDOFINFO, RPL_ENDOFLINKS, RPL_ENDOFMOTD, RPL_ENDOFNAMES, RPL_ENDOFSERVICES, RPL_ENDOFSTATS, RPL_ENDOFUSERS, RPL_ENDOFWHO, RPL_ENDOFWHOIS, RPL_ENDOFWHOWAS, RPL_INFO, RPL_INFOSTART, RPL_INVITING, RPL_ISON, RPL_KILLDONE, RPL_LINKS, RPL_LIST, RPL_LISTEND, RPL_LISTSTART, RPL_LUSERCHANNELS, RPL_LUSERCLIENT, RPL_LUSERME, RPL_LUSEROP, RPL_LUSERUNKNOWN, RPL_MOTD, RPL_MOTDSTART, RPL_MYPORTIS, RPL_NAMREPLY, RPL_NONE, RPL_NOTOPIC, RPL_NOUSERS, RPL_NOWAWAY, RPL_REHASHING, RPL_SERVICE, RPL_SERVICEINFO, RPL_SERVLIST, RPL_SERVLISTEND, RPL_STATSCLINE, RPL_STATSCOMMANDS, RPL_STATSHLINE, RPL_STATSILINE, RPL_STATSKLINE, RPL_STATSLINKINFO, RPL_STATSLLINE, RPL_STATSNLINE, RPL_STATSOLINE, RPL_STATSQLINE, RPL_STATSUPTIME, RPL_STATSYLINE, RPL_SUMMONING, RPL_TIME, RPL_TOPIC, RPL_TRACECLASS, RPL_TRACECONNECTING, RPL_TRACEHANDSHAKE, RPL_TRACELINK, RPL_TRACELOG, RPL_TRACENEWTYPE, RPL_TRACEOPERATOR, RPL_TRACESERVER, RPL_TRACEUNKNOWN, RPL_TRACEUSER, RPL_UMODEIS, RPL_UNAWAY, RPL_USERHOST, RPL_USERS, RPL_USERSSTART, RPL_VERSION, RPL_WHOISCHANNELS, RPL_WHOISCHANOP, RPL_WHOISIDLE, RPL_WHOISOPERATOR, RPL_WHOISSERVER, RPL_WHOISUSER, RPL_WHOREPLY, RPL_WHOWASUSER, RPL_YOUREOPER |
Method Summary |
private String |
getRevision()
Returns the revision of the bot. |
private void |
handleInput(String message,
String source)
This method handles input directed to us, and
responds accordingly if required. |
private void |
init()
Connects the bot to an irc server and joins a channel,
using details supplied from the i-scream configuration
system. |
private String |
isForMe(String message)
Quick method to check if the message appears
to be directed at us. |
void |
onDisconnect()
If we get disconnected this method will be
called, so we must take action. |
void |
onKick(String channel,
String kickerNick,
String kickerLogin,
String kickerHostname,
String recipientNick,
String reason)
If we receive a kick message this method
gets called. |
void |
onMessage(String channel,
String sender,
String login,
String hostname,
String message)
If we receive a message this method will
be called. |
void |
onNickChange(String oldNick,
String login,
String hostname,
String newNick)
If we receive a nick change message, this
method gets called. |
void |
onPrivateMessage(String sender,
String login,
String hostname,
String message)
If we receive a private message this method
will be called. |
private void |
reconnectSleep()
Sleep for a configurable amount of time and
then return. |
void |
run()
Attempt to kick-start the IRCBot into action. |
private void |
sendMessage(String message)
Send a message to the current channel. |
String |
toString()
Overrides the Object.toString()
method to provide clean logging (every class should have this). |
Methods inherited from class org.jibble.pircbot.PircBot |
ban, changeNick, connect, connect, connect, dccAcceptChatRequest, dccReceiveFile, dccSendChatRequest, dccSendFile, deOp, deVoice, disconnect, equals, getChannels, getFinger, getLogin, getMaxLineLength, getMessageDelay, getName, getNick, getOutgoingQueueSize, getPassword, getPort, getServer, getUsers, getVersion, handleLine, hashCode, ipToLong, isConnected, joinChannel, joinChannel, kick, kick, listChannels, listChannels, log, longToIp, onAction, onChannelInfo, onConnect, onDccChatRequest, onDccSendRequest, onDeop, onDeVoice, onFinger, onInvite, onJoin, onMode, onNotice, onOp, onPart, onPing, onQuit, onRemoveChannelBan, onRemoveChannelKey, onRemoveChannelLimit, onRemoveInviteOnly, onRemoveModerated, onRemoveNoExternalMessages, onRemovePrivate, onRemoveSecret, onRemoveTopicProtection, onServerPing, onServerResponse, onSetChannelBan, onSetChannelKey, onSetChannelLimit, onSetInviteOnly, onSetModerated, onSetNoExternalMessages, onSetPrivate, onSetSecret, onSetTopicProtection, onTime, onTopic, onUnknown, onUserList, onVersion, onVoice, op, partChannel, partChannel, quitServer, quitServer, reconnect, sendAction, sendCTCPCommand, sendInvite, sendMessage, sendNotice, sendRawLine, setFinger, setLogin, setMessageDelay, setMode, setName, setTopic, setVerbose, setVersion, startIdentServer, unBan, voice |
DEFAULT_RECONNECT_DELAY
public final int DEFAULT_RECONNECT_DELAY
- The default reconnect delay in seconds
- See Also:
- Constant Field Values
_channel
private String _channel
- Just a reminder to what channel we're on...
this can't be dynamic :)
_nickname
private String _nickname
- A reminder of our current nickname...
IRC__Alerter.IRCBot
IRC__Alerter.IRCBot()
run
public void run()
- Attempt to kick-start the IRCBot into action. Will
keep calling init() until it doesn't throw an
an IOException (which will only be thrown if there
is an error initialising). After a successful call
to init() the method finishes.
- Specified by:
run
in interface Runnable
init
private void init()
throws IOException
- Connects the bot to an irc server and joins a channel,
using details supplied from the i-scream configuration
system. If this method completes without an exception
one can presume the bot is ready for use.
- Throws:
IOException
- if there is any problem initialising
sendMessage
private void sendMessage(String message)
- Send a message to the current channel.
- Parameters:
message
- The message to send
onDisconnect
public void onDisconnect()
- If we get disconnected this method will be
called, so we must take action. We'll simply
keep trying to reinitialise, and thus
reconnect to the server.
- Overrides:
onDisconnect
in class PircBot
onMessage
public void onMessage(String channel,
String sender,
String login,
String hostname,
String message)
- If we receive a message this method will
be called. We'll check if the message is
for us, and call handleInput if it is.
- Overrides:
onMessage
in class PircBot
- Parameters:
channel
- The channel the message came fromsender
- The sender of the messagelogin
- The login of the senderhostname
- The hostname of the sendermessage
- The message sent
onPrivateMessage
public void onPrivateMessage(String sender,
String login,
String hostname,
String message)
- If we receive a private message this method
will be called. No need to check if it's for
us -- it has to be if it's a private message.
- Overrides:
onPrivateMessage
in class PircBot
- Parameters:
sender
- The sender of the messagelogin
- The login of the senderhostname
- The hostname of the sendermessage
- The message sent
onNickChange
public void onNickChange(String oldNick,
String login,
String hostname,
String newNick)
- If we receive a nick change message, this
method gets called. We don't care about
other users changing their nick, so we only
take notice if our nick changes. If it does
we need to change our internal nickname
state.
- Overrides:
onNickChange
in class PircBot
- Parameters:
oldNick
- the old nicknamelogin
- the login of the nick changerhostname
- the hostname of the nick changernewNick
- the new nickname
onKick
public void onKick(String channel,
String kickerNick,
String kickerLogin,
String kickerHostname,
String recipientNick,
String reason)
- If we receive a kick message this method
gets called. We only take notice if it's
us getting kicked, and then we'll rejoin
the channel after a short wait.
- Overrides:
onKick
in class PircBot
- Parameters:
channel
- the channel the kick happened onkickerNick
- the person who performed the kickkickerLogin
- the login of the person who performed the kickkickerHostname
- the hostname of the person who performed the kickrecipientNick
- the nickname of the person being kickedreason
- the reason for the kick
handleInput
private void handleInput(String message,
String source)
- This method handles input directed to us, and
responds accordingly if required.
- Parameters:
message
- the message from someonesource
- where the message came from, so we know where to send the response
isForMe
private String isForMe(String message)
- Quick method to check if the message appears
to be directed at us. We simply check to see
if it starts with our nick in some fashion.
This will return null if the message is not
for us - thus allowing this method to perform
two tasks at once.
- Parameters:
message
- the message to check
- Returns:
- the message (with our nick removed), or null if it's not for us.
reconnectSleep
private void reconnectSleep()
- Sleep for a configurable amount of time and
then return. This is used when reconnecting
to the server or a channel.
getRevision
private String getRevision()
- Returns the revision of the bot.
- Returns:
- the revision of this bot
toString
public String toString()
- Overrides the
Object.toString()
method to provide clean logging (every class should have this).
This uses the uk.org.iscream.cms.util.NameFormat class
to format the toString()
- Overrides:
toString
in class PircBot
- Returns:
- the name of this class and its CVS revision
Copyright © 2000-2003 i-scream. All Rights Reserved.