irssibot.modules
Class SodexHo

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

public class SodexHo
extends AbstractModule

Includes methods for retirieving information about Sodex Ho restaurants from the WWW.

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

Field Summary
private  ServerConnection caller
           
private  Host host
           
private static java.lang.String moduleInfo
           
private  java.lang.String source
           
 
Fields inherited from class irssibot.modules.AbstractModule
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
SodexHo()
          Default constructor
 
Method Summary
private  void commandList(Host host, User user, java.lang.String[] args, Channel channel)
          Handles command 'list'
private  void commandSodexho(Host host, User user, java.lang.String[] args, Channel channel)
          Handles command 'sodexho'
private  void doPrivmsg(IrcMessage message)
          Handles PRIVMSGs
private  java.util.Vector getLocations()
          Retrieves list of all SodexHo restaurants
 java.lang.String getModuleInfo()
          returns a module info string
 java.util.Properties getState()
          Gets module's state as a Properties object.
 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)
          Process command message.
protected  void processMessage(IrcMessage message, ServerConnection serverConnection)
          Processes incoming IrcMessages from a ServerConnection
private  boolean showMenu(LocationDescriptor location, java.lang.String date)
          Displays menu for given Sodex Ho restaurant
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

host

private Host host

source

private java.lang.String source

caller

private ServerConnection caller
Constructor Detail

SodexHo

public SodexHo()
Default constructor

Method Detail

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

getModuleInfo

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

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

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

onUnload

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

Overrides:
onUnload in class AbstractModule

showMenu

private boolean showMenu(LocationDescriptor location,
                         java.lang.String date)
                  throws java.net.MalformedURLException,
                         java.io.IOException
Displays menu for given Sodex Ho restaurant

Parameters:
location - LocationDescriptor for the location
date - desired date in the form of DD.MM.
Returns:
true if menu found and shown, false if not found
java.net.MalformedURLException
java.io.IOException

commandSodexho

private void commandSodexho(Host host,
                            User user,
                            java.lang.String[] args,
                            Channel channel)
Handles command 'sodexho'

Parameters:
host - Host of invoker
args - command arguments
channel - Channel where command takes place *

getLocations

private java.util.Vector getLocations()
                               throws java.net.MalformedURLException,
                                      java.io.IOException
Retrieves list of all SodexHo restaurants

Returns:
list of locations as a Vector. The elements are of type LocationDescriptor.
java.net.MalformedURLException
java.io.IOException

commandList

private void commandList(Host host,
                         User user,
                         java.lang.String[] args,
                         Channel channel)
Handles command 'list'

Parameters:
host - Host of invoker
args - command arguments
channel - Channel where command takes place *

processCmdMsg

private void processCmdMsg(Host host,
                           java.lang.String cmd,
                           Channel channel,
                           java.lang.String[] args)
Process 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