irssibot.modules
Class Alko

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

public class Alko
extends AbstractModule

Includes methods for retrieving infomation from www.alko.fi.

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

Field Summary
private static java.lang.String moduleInfo
          Module info string.
 
Fields inherited from class irssibot.modules.AbstractModule
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Alko()
          Constructs.
 
Method Summary
private  void displayPunkkuInfo(java.lang.String name, java.lang.String url, java.lang.String source, ServerConnection serverConnection)
          Displays info about a red wine.
private  void doPrivmsg(IrcMessage message, ServerConnection serverConnection)
          Handles PRIVMSGs.
private  void doPunkku(java.lang.String name, java.lang.String source, ServerConnection serverConnection)
          Retrieves info about a named red wine.
 java.lang.String getModuleInfo()
          Returns a module info string.
 java.util.Properties getProperties()
          Returns module properties.
 boolean onLoad(java.util.Properties state, Core core)
          Called upon loading the module.
 void onUnload()
          Called upon unloading the module.
protected  void processMessage(IrcMessage message, ServerConnection serverConnection)
          Processes incoming IrcMessages from a ServerConnection.
static java.lang.String readURL(java.lang.String url)
          Reads contents of an URL as a string.
private  void searchPunkkuList(java.lang.String search, java.lang.String list, java.lang.String source, ServerConnection serverConnection)
          Looks through the red wine list for matches.
 
Methods inherited from class irssibot.modules.AbstractModule
addMessage, getState, 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 final java.lang.String moduleInfo
Module info string.

See Also:
Constant Field Values
Constructor Detail

Alko

public Alko()
Constructs.

Method Detail

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)
Called upon loading the module.

 @param state initial module state

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

onUnload

public void onUnload()
Called upon unloading the module.

Overrides:
onUnload in class AbstractModule

getProperties

public java.util.Properties getProperties()
Returns module properties.


readURL

public static java.lang.String readURL(java.lang.String url)
                                throws java.io.IOException
Reads contents of an URL as a string.

##TODO## move to an util class!

Parameters:
url - url of the form http://host/querystring
Returns:
url contents
Throws:
java.io.IOException - if problems reading url

displayPunkkuInfo

private void displayPunkkuInfo(java.lang.String name,
                               java.lang.String url,
                               java.lang.String source,
                               ServerConnection serverConnection)
Displays info about a red wine.

Parameters:
name - wine name or part of name
url - url to the wine
source - source (nick or channel) or the message
serverConnection - calling server connection

searchPunkkuList

private void searchPunkkuList(java.lang.String search,
                              java.lang.String list,
                              java.lang.String source,
                              ServerConnection serverConnection)
Looks through the red wine list for matches.

Parameters:
search - name of wine to look for
list - string containing the wine list html
source - source (nick or channel) or the message
serverConnection - calling server connection

doPunkku

private void doPunkku(java.lang.String name,
                      java.lang.String source,
                      ServerConnection serverConnection)
Retrieves info about a named red wine.

Parameters:
name - wine name or part of name
source - source (nick or channel) or the message
serverConnection - calling server connection

doPrivmsg

private void doPrivmsg(IrcMessage message,
                       ServerConnection serverConnection)
Handles PRIVMSGs.

Parameters:
message - PRIVMSG IrcMessage to process
serverConnection - calling server connection

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


IrssiBot (c) 2000-2002 Matti Dahlbom