irssibot.core
Class Channel

java.lang.Object
  |
  +--irssibot.core.Channel

public class Channel
extends java.lang.Object

Represents an IRC channel the bot is supposed to be on.

Version:
$Name: $ $Revision: 1.9 $
Author:
Matti Dahlbom

Field Summary
private  java.util.Vector banexList
          Contains Strings as ban exception masks
private  java.util.Vector banList
          Contains Strings as banmasks
private  boolean banlistReady
          Indicates whether the MODE #channel b (ban) listing has been completed (set true on RPL_ENDOFBANLIST)
private  java.lang.String channelForcedModes
           
private  java.lang.String channelKey
           
private  java.lang.String channelName
           
private  java.lang.String channelTopic
           
private  java.lang.String forcedModes
          Original string containing forced modes (from config file) in format +abc-de where a,b,c,d,e are mode characters.
private  java.util.Vector invexList
          Contains Strings as need-invite exception masks
private  boolean joined
          true if currently joined on the channel.
private  java.lang.String negModes
          String containing all channel modes that the bot will forcibly keep unset.
private  java.util.Vector nickList
          Contains Nick objects
private  boolean nicklistReady
          Indicates whether the WHO listing has been completed (set true on RPL_ENDOFWHO)
private  java.lang.String posModes
          String containing all channel modes that the bot will forcibly uphold.
private  java.lang.String serverChannelModes
          Allowed channel modes for the server.
private  ServerConnection serverConnection
          Reference to the owning connection
 
Constructor Summary
Channel(java.lang.String channelName, java.lang.String channelKey, java.lang.String forcedModes, ServerConnection serverConnection)
           
 
Method Summary
 void doMaintain()
          Goes through channels nick list and ops/voices channel ops/voices without ops/voices currently.
 Nick findNick(java.lang.String name)
          search nick list for nick with name
 java.util.Vector getBanList()
           
 java.lang.String getChannelKey()
           
 java.lang.String getChannelName()
           
 java.lang.String getChannelTopic()
           
 java.lang.String getNegModes()
          Returns channel modes that the bot will forcibly keep off
 java.util.Vector getNickList()
           
 java.lang.String getPosModes()
          Returns channel modes that the bot will forcibly uphold
private  void invokeBanList()
          Invoke MODE #channel b on channel to retrieve channel's banlist
private  void invokeWho()
          Invoke WHO on channel to retrieve data about nicks on channel
 boolean isJoined()
          Indicates whether the bot is currently on this channel.
 boolean isOp()
          Checks whether bot is op on this channel
 void onBanListMsg(IrcMessage message)
          Handles RPL_BANLIST messages.
 void onChannelModeIs(IrcMessage message)
          On RPL_CHANNELMODEIS reply compare current channel mode to forced modes.
 void onEndOfBanListMsg(IrcMessage message)
          Called on RPL_ENDOFBANLIST.
 void onEndOfWhoMsg(IrcMessage message)
          Called on RPL_ENDOFWHO.
 void onJoin(IrcMessage message)
          Called on JOIN on this channel.
 void onKick(IrcMessage message)
          Called on KICK from this channel.
 void onMode(IrcMessage message)
          Handles mode changes
 void onNick(IrcMessage message)
          handles nick changes :dreami!^matti@777-team.org NICK :dreamiz
 void onPart(IrcMessage message)
          Called on PART from this channel.
 void onQuit(IrcMessage message)
          Called on QUIT from this channel.
 void onTopic(IrcMessage message)
          Called on TOPIC change.
 void onTopicMsg(IrcMessage message)
          Called on RPL_TOPIC.
 boolean parseForcedModes(java.lang.String forcedModesList)
          Parses forcemodes string (for example: +nt-slikm).
 void processWhoReply(IrcMessage message)
          Callback function for processing WHO reply
 void setChannelKey(java.lang.String key)
           
 void setServerChannelModes(java.lang.String serverChannelModes)
          Sets the server's allowed channel modes string.
 void setServerConnection(ServerConnection serverConnection)
           
 java.lang.String toString()
          Returns a String representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

channelName

private java.lang.String channelName

channelForcedModes

private java.lang.String channelForcedModes

channelTopic

private java.lang.String channelTopic

channelKey

private java.lang.String channelKey

serverChannelModes

private java.lang.String serverChannelModes
Allowed channel modes for the server.


forcedModes

private java.lang.String forcedModes
Original string containing forced modes (from config file) in format +abc-de where a,b,c,d,e are mode characters. Will become redundant when server connection has been completed and the parseForcedModes() has been called.

See Also:
parseForcedModes(String)

posModes

private java.lang.String posModes
String containing all channel modes that the bot will forcibly uphold.


negModes

private java.lang.String negModes
String containing all channel modes that the bot will forcibly keep unset.


joined

private boolean joined
true if currently joined on the channel.


nickList

private java.util.Vector nickList
Contains Nick objects


banList

private java.util.Vector banList
Contains Strings as banmasks


banexList

private java.util.Vector banexList
Contains Strings as ban exception masks


invexList

private java.util.Vector invexList
Contains Strings as need-invite exception masks


serverConnection

private ServerConnection serverConnection
Reference to the owning connection


nicklistReady

private boolean nicklistReady
Indicates whether the WHO listing has been completed (set true on RPL_ENDOFWHO)


banlistReady

private boolean banlistReady
Indicates whether the MODE #channel b (ban) listing has been completed (set true on RPL_ENDOFBANLIST)

Constructor Detail

Channel

public Channel(java.lang.String channelName,
               java.lang.String channelKey,
               java.lang.String forcedModes,
               ServerConnection serverConnection)
Method Detail

getPosModes

public java.lang.String getPosModes()
Returns channel modes that the bot will forcibly uphold


getNegModes

public java.lang.String getNegModes()
Returns channel modes that the bot will forcibly keep off


getChannelName

public java.lang.String getChannelName()

getChannelKey

public java.lang.String getChannelKey()

getChannelTopic

public java.lang.String getChannelTopic()

getBanList

public java.util.Vector getBanList()

getNickList

public java.util.Vector getNickList()

isJoined

public boolean isJoined()
Indicates whether the bot is currently on this channel.

Returns:
true is bot is on this channel

setChannelKey

public void setChannelKey(java.lang.String key)

toString

public java.lang.String toString()
Returns a String representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
a String representation of the Channel object

setServerChannelModes

public void setServerChannelModes(java.lang.String serverChannelModes)
Sets the server's allowed channel modes string. Calls parseForcedModes() to init the lists of upheld and kept off modes.

Parameters:
serverChannelModes - list of allowed channel modes

setServerConnection

public void setServerConnection(ServerConnection serverConnection)

onChannelModeIs

public void onChannelModeIs(IrcMessage message)
On RPL_CHANNELMODEIS reply compare current channel mode to forced modes. MODES #channel is invoked on joining the channel to retrieve the channel modes.

example:
:irc.cs.hut.fi 324 dasd #777-team +tn

Parameters:
message - IrcMessage the RPL_CHANNELMODEIS message

parseForcedModes

public boolean parseForcedModes(java.lang.String forcedModesList)
Parses forcemodes string (for example: +nt-slikm).

Parameters:
forcedModesList - the mode string
Returns:
true if ok. false if attempting to set unsupported mode char or passed null argument.

onEndOfWhoMsg

public void onEndOfWhoMsg(IrcMessage message)
Called on RPL_ENDOFWHO. If ban list also done, sends fake JOIN messages to modules.

Parameters:
message - the RPL_ENDOFWHO message

onEndOfBanListMsg

public void onEndOfBanListMsg(IrcMessage message)
Called on RPL_ENDOFBANLIST. If who list also done, sends fake JOIN messages to modules.

Parameters:
message - the RPL_ENDOFBANLIST message

onJoin

public void onJoin(IrcMessage message)
Called on JOIN on this channel. If joiner is self (bot), invoke a WHO query to retrieve nameslist.

Parameters:
message - the JOIN message

onTopic

public void onTopic(IrcMessage message)
Called on TOPIC change.

example:
:reaperi!~EvilEd@fisherman.tky.hut.fi TOPIC #777-team :http://777-team.org/Ircstats/ | or or

Parameters:
message - the TOPIC change message

onTopicMsg

public void onTopicMsg(IrcMessage message)
Called on RPL_TOPIC.

Parameters:
message - the TOPIC message

onPart

public void onPart(IrcMessage message)
Called on PART from this channel.

Parameters:
message - the PART message

onKick

public void onKick(IrcMessage message)
Called on KICK from this channel.

Parameters:
message - the KICK message

onQuit

public void onQuit(IrcMessage message)
Called on QUIT from this channel.

Parameters:
message - the QUIT message

doMaintain

public void doMaintain()
Goes through channels nick list and ops/voices channel ops/voices without ops/voices currently. Also forces the channel modes on the forcelist.


onMode

public void onMode(IrcMessage message)
Handles mode changes

example:
:dreami!^matti@xxx-team.org MODE #777-team +vo-o latex sintetik latex

Parameters:
message - the NICK message

isOp

public boolean isOp()
Checks whether bot is op on this channel

Returns:
  • true if op
  • false if not op

onNick

public void onNick(IrcMessage message)
handles nick changes :dreami!^matti@777-team.org NICK :dreamiz

Parameters:
message - the NICK message

onBanListMsg

public void onBanListMsg(IrcMessage message)
Handles RPL_BANLIST messages.

:irc.cs.hut.fi 367 asdasd #777-team *!*@*.pl

Parameters:
message - the RPL_BANLIST message

findNick

public Nick findNick(java.lang.String name)
search nick list for nick with name

Parameters:
name - nickname to look for
Returns:
correct Nick object or null if not found

invokeWho

private void invokeWho()
Invoke WHO on channel to retrieve data about nicks on channel


invokeBanList

private void invokeBanList()
Invoke MODE #channel b on channel to retrieve channel's banlist


processWhoReply

public void processWhoReply(IrcMessage message)
Callback function for processing WHO reply

Parameters:
message - WHO message


IrssiBot (c) 2000-2002 Matti Dahlbom