irssibot.modules
Class TopicTools

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--irssibot.modules.AbstractModule
              |
              +--irssibot.modules.TopicTools
All Implemented Interfaces:
java.lang.Runnable

public class TopicTools
extends AbstractModule

Implements a series of utilities to edit channel topic.

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

Field Summary
private  Host botHost
           
private  ServerConnection caller
           
private  java.lang.String dateFormatString
           
private  boolean hasChanged
           
private  Host host
           
private static java.lang.String moduleInfo
           
private  java.lang.String source
           
private  java.util.Hashtable topicStore
           
 
Fields inherited from class irssibot.modules.AbstractModule
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TopicTools()
          Default constructor
 
Method Summary
private  void commandTA(Host host, User invoker, java.lang.String[] args, Channel channel)
          appends a new topic
private  void commandTD(Host host, User invoker, java.lang.String[] args, Channel channel)
          deletes a topic
private  void commandTE(Host host, User invoker, java.lang.String[] args, Channel channel)
          Edits a topic
private  void commandTG(Host host, User invoker, java.lang.String[] args, Channel channel)
          gets the current channel topic
private  void commandTI(Host host, User invoker, java.lang.String[] args, Channel channel)
          inserts a new topic
private  void commandTL(Host host, User invoker, java.lang.String[] args, Channel channel)
          lists all topics
private  void commandTOPIC(Host host, User invoker, java.lang.String[] args, Channel channel)
          sets a new topic
private  void commandTR(Host host, User invoker, java.lang.String[] args, Channel channel)
          sets (refreshes) channel topic from store
private  void commandTS(Host host, User invoker, java.lang.String[] args, Channel channel)
          swaps two topics
private  java.util.Properties constructState()
          Constructs a Properties object representing the state of this module.
private  void constructTopic(TopicEntry[] value, Channel channel)
          combine topics and send channel topic to server
private  void doPrivmsg(IrcMessage message)
          Handles PRIVMSGs
private  void getAllTopics(Core core)
          Gets (same as !tg) topics of all channels of all server connections.
 java.lang.String getModuleInfo()
          returns a module info string
 java.util.Properties getState()
          Gets module's state as a Properties object.
private  void loadInitialState(java.util.Properties state, Core core)
          Initializes the module from the given state.
 boolean onLoad(java.util.Properties state, Core core)
          Called upon loading the module.
 void onUnload()
          Called upon unloading the module.
private  void processCmdMsg(Host host, java.lang.String cmd, Channel channel, java.lang.String[] args)
          Processes command message.
protected  void processMessage(IrcMessage message, ServerConnection serverConnection)
          Processes incoming IrcMessages from a ServerConnection.
private  void write(java.lang.String message)
          Sends message to source (channel/user)
 
Methods inherited from class irssibot.modules.AbstractModule
addMessage, killModule, run
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

moduleInfo

private static java.lang.String moduleInfo

topicStore

private java.util.Hashtable topicStore

hasChanged

private boolean hasChanged

dateFormatString

private java.lang.String dateFormatString

botHost

private Host botHost

host

private Host host

source

private java.lang.String source

caller

private ServerConnection caller
Constructor Detail

TopicTools

public TopicTools()
Default constructor

Method Detail

onLoad

public boolean onLoad(java.util.Properties state,
                      Core core)
Description copied from class: AbstractModule
Called upon loading the module.

Overrides:
onLoad in class AbstractModule
Parameters:
state - the initial state of module as an Properties object, or null if no state was saved for module.
core - a Core instance. this can be used to initialize module if no state was retrieved.
Returns:
true if ok, false if error. modules returning false from onLoad() will be unloaded immediately.
See Also:
Core

loadInitialState

private void loadInitialState(java.util.Properties state,
                              Core core)
Initializes the module from the given state.

Parameters:
state - initial state

getAllTopics

private void getAllTopics(Core core)
Gets (same as !tg) topics of all channels of all server connections.

Parameters:
core - Core instance

onUnload

public void onUnload()
Description copied from class: AbstractModule
Called upon unloading the module.

Overrides:
onUnload in class AbstractModule

getState

public java.util.Properties getState()
Description copied from class: AbstractModule
Gets module's state as a Properties object. If module does not wish to save state OR its state has not been changed since last getState(), it should return null. This is to minimize disk access.

Overrides:
getState in class AbstractModule
Returns:
state of module as a Properties object

constructState

private java.util.Properties constructState()
Constructs a Properties object representing the state of this module. Stored in the Properties for each channel of each server connection:

Returns:
the constructed Properties object

getModuleInfo

public java.lang.String getModuleInfo()
returns a module info string

Specified by:
getModuleInfo in class AbstractModule
Returns:
module info string

constructTopic

private void constructTopic(TopicEntry[] value,
                            Channel channel)
combine topics and send channel topic to server

Parameters:
value - entries of topic
channel - to set topic on

commandTD

private void commandTD(Host host,
                       User invoker,
                       java.lang.String[] args,
                       Channel channel)
deletes a topic

Parameters:
host - host of invoker
invoker - invoking User
args - arguments of command
channel - target channel

commandTL

private void commandTL(Host host,
                       User invoker,
                       java.lang.String[] args,
                       Channel channel)
lists all topics

Parameters:
host - host of invoker
invoker - invoking User
args - arguments of command
channel - target channel

commandTI

private void commandTI(Host host,
                       User invoker,
                       java.lang.String[] args,
                       Channel channel)
inserts a new topic

Parameters:
host - host of invoker
invoker - invoking User
args - arguments of command
channel - target channel

commandTS

private void commandTS(Host host,
                       User invoker,
                       java.lang.String[] args,
                       Channel channel)
swaps two topics

Parameters:
host - host of invoker
invoker - invoking User
args - arguments of command
channel - target channel

commandTOPIC

private void commandTOPIC(Host host,
                          User invoker,
                          java.lang.String[] args,
                          Channel channel)
sets a new topic

Parameters:
host - host of invoker
invoker - invoking User
args - arguments of command
channel - target channel

commandTA

private void commandTA(Host host,
                       User invoker,
                       java.lang.String[] args,
                       Channel channel)
appends a new topic

Parameters:
host - host of invoker
invoker - invoking User
args - arguments of command
channel - target channel

commandTE

private void commandTE(Host host,
                       User invoker,
                       java.lang.String[] args,
                       Channel channel)
Edits a topic

Parameters:
host - host of invoker
invoker - invoking User
args - arguments of command
channel - target channel

commandTR

private void commandTR(Host host,
                       User invoker,
                       java.lang.String[] args,
                       Channel channel)
sets (refreshes) channel topic from store

Parameters:
host - host of invoker
invoker - invoking User
args - arguments of command
channel - target channel

commandTG

private void commandTG(Host host,
                       User invoker,
                       java.lang.String[] args,
                       Channel channel)
gets the current channel topic

Parameters:
host - host of invoker
invoker - invoking User
args - arguments of command
channel - target channel

processCmdMsg

private void processCmdMsg(Host host,
                           java.lang.String cmd,
                           Channel channel,
                           java.lang.String[] args)
Processes command message. assuming valid channel argument.

Parameters:
channel - valid channel name

doPrivmsg

private void doPrivmsg(IrcMessage message)
Handles PRIVMSGs

Parameters:
message - PRIVMSG IrcMessage to process

processMessage

protected void processMessage(IrcMessage message,
                              ServerConnection serverConnection)
Processes incoming IrcMessages from a ServerConnection.

Specified by:
processMessage in class AbstractModule
Parameters:
message - IrcMessage to process
serverConnection - invoking ServerConnection

write

private void write(java.lang.String message)
Sends message to source (channel/user)

Parameters:
message - message to send


IrssiBot (c) 2000-2002 Matti Dahlbom