irssibot.core
Class Core

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

public class Core
extends java.lang.Object

IrssiBot core.

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

Field Summary
static java.lang.String botVersion
           
private  java.lang.String configFileName
          Name of configuration file
private  java.util.ArrayList databases
          Database descriptors.
private  java.lang.String dateFormatString
          General date format string.
private static java.lang.String info
          Module info.
private  java.lang.String moduleBaseDir
          Modules base dir.
private  ModuleHandler moduleHandler
          Handles modules
private  long moduleStateSaved
          Time (in milliseconds, see System.currentTimeMillis()) when the module states were last saved.
private  java.util.Vector serverInstances
          Contains ServerConnection objects
private  long startedTime
          Time (in milliseconds, see System.currentTimeMillis()) when the bot was started.
 
Constructor Summary
Core(java.lang.String configFileName)
          Constructs.
 
Method Summary
private  java.lang.String addChannelConnect(java.lang.String[] params, ServerConnection caller, java.lang.String source)
          Adds a channel connect.
 java.sql.Connection getDatabaseConnection(java.lang.String name)
          Returns a database connection for requested database.
 java.lang.String getDateFormatString()
          Returns the general date format string.
 java.lang.String getModuleBaseDir()
          Returns the module base dir.
 ModuleHandler getModuleHandler()
          Returns the module handler.
 java.util.Vector getServerInstances()
          Returns server instances.
 void globalChannelBroadcast(java.lang.String message)
          Broadcasts a message to all channels of all server instances.
private  java.lang.String info(java.lang.String[] params, ServerConnection caller, java.lang.String source)
          quitted info about bot.
private  void launch()
          Starts the bot.
private  java.lang.String listChannelConnects(java.lang.String[] params, ServerConnection caller, java.lang.String source)
          Lists all callers channel connects
private  java.lang.String listLoadedModules(java.lang.String[] params, ServerConnection caller, java.lang.String source)
          Lists info about loaded modules
private  java.lang.String loadModule(java.lang.String[] params, ServerConnection caller, java.lang.String source)
          Loads a module.
static void main(java.lang.String[] args)
          Runs the bot.
private  java.lang.String notice(java.lang.String[] params, ServerConnection caller, java.lang.String source)
          Sends NOTICE to all users on bot's channels.
 java.lang.String processCoreCall(IrcMessage message, java.lang.String trailing, ServerConnection caller, java.lang.String source)
          Parse and execute a core call.
private  java.lang.String quit(java.lang.String[] params, ServerConnection caller, java.lang.String source)
          Quits the bot.
private  java.lang.String removeChannelConnects(java.lang.String[] params, ServerConnection caller, java.lang.String source)
          Removes all callers channel connects.
private  java.lang.String save(java.lang.String[] params, ServerConnection caller, java.lang.String source)
          Forces the bot to write out its userfile and the state of all loaded modules.
private  void saveConfigFile()
          Requests XML configuration from each server instance and writes the config file.
 void saveModuleStates(boolean force)
          Tells module handler to save all modules' state.
 java.lang.String toString()
          Returns module info.
private  java.lang.String unloadModule(java.lang.String[] params, ServerConnection caller, java.lang.String source)
          Unload a module.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

botVersion

public static final java.lang.String botVersion
See Also:
Constant Field Values

info

private static final java.lang.String info
Module info.

See Also:
Constant Field Values

moduleBaseDir

private java.lang.String moduleBaseDir
Modules base dir.


dateFormatString

private java.lang.String dateFormatString
General date format string.


configFileName

private java.lang.String configFileName
Name of configuration file


serverInstances

private java.util.Vector serverInstances
Contains ServerConnection objects


databases

private java.util.ArrayList databases
Database descriptors.


moduleHandler

private ModuleHandler moduleHandler
Handles modules


startedTime

private long startedTime
Time (in milliseconds, see System.currentTimeMillis()) when the bot was started.


moduleStateSaved

private long moduleStateSaved
Time (in milliseconds, see System.currentTimeMillis()) when the module states were last saved.

Constructor Detail

Core

public Core(java.lang.String configFileName)
Constructs.

Parameters:
configFileName - path to configuration file
Method Detail

toString

public java.lang.String toString()
Returns module info.

Overrides:
toString in class java.lang.Object

getServerInstances

public java.util.Vector getServerInstances()
Returns server instances.


getModuleHandler

public ModuleHandler getModuleHandler()
Returns the module handler.


getDateFormatString

public java.lang.String getDateFormatString()
Returns the general date format string.

Returns:
date format string
See Also:
SimpleDateFormat

getModuleBaseDir

public java.lang.String getModuleBaseDir()
Returns the module base dir.

The returned path does not include trailing path separator.


globalChannelBroadcast

public void globalChannelBroadcast(java.lang.String message)
Broadcasts a message to all channels of all server instances.

Parameters:
message - message to broadcast

saveModuleStates

public void saveModuleStates(boolean force)
Tells module handler to save all modules' state.

Parameters:
force - if true, disregard the 5min timelimit and save anyhow. If false, don't save unless 5 minutes has passed from last save.

getDatabaseConnection

public java.sql.Connection getDatabaseConnection(java.lang.String name)
Returns a database connection for requested database.

Parameters:
name - database descriptor name
Returns:
database connection, or null if could not estabilish one

saveConfigFile

private void saveConfigFile()
Requests XML configuration from each server instance and writes the config file.


loadModule

private java.lang.String loadModule(java.lang.String[] params,
                                    ServerConnection caller,
                                    java.lang.String source)
Loads a module.

Parameters:
params - array of String parameters
caller - calling server instance
source - nick or channel where call originated from

listLoadedModules

private java.lang.String listLoadedModules(java.lang.String[] params,
                                           ServerConnection caller,
                                           java.lang.String source)
Lists info about loaded modules

Parameters:
params - array of String parameters
caller - calling server instance
source - nick or channel where call originated from

unloadModule

private java.lang.String unloadModule(java.lang.String[] params,
                                      ServerConnection caller,
                                      java.lang.String source)
Unload a module.

Parameters:
params - array of String parameters
caller - calling server instance
source - nick or channel where call originated from

listChannelConnects

private java.lang.String listChannelConnects(java.lang.String[] params,
                                             ServerConnection caller,
                                             java.lang.String source)
Lists all callers channel connects

Parameters:
params - array of String parameters
caller - calling server instance
source - nick or channel where call originated from

removeChannelConnects

private java.lang.String removeChannelConnects(java.lang.String[] params,
                                               ServerConnection caller,
                                               java.lang.String source)
Removes all callers channel connects.

Parameters:
params - array of String parameters
caller - calling server instance
source - nick or channel where call originated from

addChannelConnect

private java.lang.String addChannelConnect(java.lang.String[] params,
                                           ServerConnection caller,
                                           java.lang.String source)
Adds a channel connect.

Parameters:
params - array of String parameters
caller - calling server instance
source - nick or channel where call originated from

save

private java.lang.String save(java.lang.String[] params,
                              ServerConnection caller,
                              java.lang.String source)
Forces the bot to write out its userfile and the state of all loaded modules.

Parameters:
params - array of String parameters
caller - calling server instance
source - nick or channel where call originated from

notice

private java.lang.String notice(java.lang.String[] params,
                                ServerConnection caller,
                                java.lang.String source)
Sends NOTICE to all users on bot's channels.

Parameters:
params - array of String parameters
caller - calling server instance
source - nick or channel where call originated from

quit

private java.lang.String quit(java.lang.String[] params,
                              ServerConnection caller,
                              java.lang.String source)
Quits the bot.

Parameters:
params - array of String parameters
caller - calling server instance
source - nick or channel where call originated from

info

private java.lang.String info(java.lang.String[] params,
                              ServerConnection caller,
                              java.lang.String source)
quitted info about bot.

Parameters:
params - array of String parameters
caller - calling server instance
source - nick or channel where call originated from

processCoreCall

public java.lang.String processCoreCall(IrcMessage message,
                                        java.lang.String trailing,
                                        ServerConnection caller,
                                        java.lang.String source)
Parse and execute a core call.

Parameters:
message - message defining the call
Returns:
null on success; error description otherwise

launch

private void launch()
Starts the bot.


main

public static void main(java.lang.String[] args)
Runs the bot.

Parameters:
args - the command line arguments


IrssiBot (c) 2000-2002 Matti Dahlbom