ircbot.modules

Class Time

Implemented Interfaces:
Comparable, IRCBotModule

public class Time
extends AbstractIRCBotModule

Field Summary

static long
HOUR
static long
HOUR_2
static long
HOUR_24
static long
HOUR_3
static long
MINUTE
static long
MIN_10
static long
MIN_20
static long
MIN_30
static long
MIN_5

Constructor Summary

Time()

Method Summary

String
action(IRCMessage message)
action is invoked by the bot when someone types a message starting with a member of getCommands().
static String
date2str(Date d)
String
getAuthor()
String
getDescription(String topic, Language lang)
getDescription is called to get the information printed by the !help command.
static int
getHour(Date d)
String
getModuleName()
getModuleName is called to get the name of this module.
int
getProbability()
getProbability is called to determine which module to choose to express a random thought whenever the bot feels like doing that.
String
parseMessage(IRCMessage message)
parseMessage is called by the bot with every message that is sent to the IRC channel with the exception for messages beginning with a command prefix, and messages sent by the bot itself.
String
randomThought(IRCChannel channel, Person sender)
An IRC bot might think that it has been too quiet in a channel for too long, or it may just feel like saying something at any given time.
static String
time2str(long milli)
static String
timeComment(Date d, String nick)

Methods inherited from class ircbot.AbstractIRCBotModule

activateEvent, addCommand, compareTo, getCommands, getModuleHandler, getProbability, loadState, parseMessage, randomThought, saveState, scheduleEvent, scheduleEvent, setModuleHandler, toString

Field Details

HOUR

public static final long HOUR
Field Value:
3600000L

HOUR_2

public static final long HOUR_2
Field Value:
7200000L

HOUR_24

public static final long HOUR_24
Field Value:
86400000L

HOUR_3

public static final long HOUR_3
Field Value:
10800000L

MINUTE

public static final long MINUTE
Field Value:
60000L

MIN_10

public static final long MIN_10
Field Value:
600000L

MIN_20

public static final long MIN_20
Field Value:
1200000L

MIN_30

public static final long MIN_30
Field Value:
1800000L

MIN_5

public static final long MIN_5
Field Value:
300000L

Constructor Details

Time

public Time()

Method Details

action

public String action(IRCMessage message)
action is invoked by the bot when someone types a message starting with a member of getCommands().
Specified by:
action in interface IRCBotModule
Parameters:
message - The original message sent to the channel. Provided if some command needs further information from it, like for instance the nick of the sender.
Returns:
A String containing a message to be sent to the IRC channel as a reply to the command invocation or null if no reply is needed.

date2str

public static String date2str(Date d)

getAuthor

public String getAuthor()
Specified by:
getAuthor in interface IRCBotModule

getDescription

public String getDescription(String topic,
                             Language lang)
getDescription is called to get the information printed by the !help command.
Specified by:
getDescription in interface IRCBotModule
Parameters:
topic - Either the string returned by getModuleName().toLowerCase() or a member of getCommands(). The convention says that the call getDescription(getModuleName().toLowerCase()) should return a brief description about the module. This information should not overlap with information given by calls where the topic is a member of getCommands().
lang - What language to use for the reply.
Returns:
A String containing all the info needed to use this module, tailored to the given topic. If the topic is unexpected, the return value should be null.

getHour

public static int getHour(Date d)

getModuleName

public String getModuleName()
getModuleName is called to get the name of this module. The name is used when building the list of loaded modules. A module name may contain capital letters.
Specified by:
getModuleName in interface IRCBotModule
Returns:
A String containing the name of this module.

getProbability

public int getProbability()
getProbability is called to determine which module to choose to express a random thought whenever the bot feels like doing that.
Specified by:
getProbability in interface IRCBotModule
Overrides:
getProbability in interface AbstractIRCBotModule
Returns:
An integer value between 0 and 100 which represents the probability (percentage) that this module will be chosen to express a random thought. If your module has a broad variety of what is said and can be chosen several times in a row without getting boring, you should return a high probability (100 or just below). If your module does not have any random thoughts return a low probability (0).

parseMessage

public String parseMessage(IRCMessage message)
parseMessage is called by the bot with every message that is sent to the IRC channel with the exception for messages beginning with a command prefix, and messages sent by the bot itself. If the implementing module does not care about the communication in the channel, this method should immediately return null without looking at the message.
Specified by:
parseMessage in interface IRCBotModule
Overrides:
parseMessage in interface AbstractIRCBotModule
Parameters:
message - The message sent to the IRC channel.
Returns:
A String containing a reply to the message, or null if nothing should be sent to the IRC channel.

randomThought

public String randomThought(IRCChannel channel,
                            Person sender)
An IRC bot might think that it has been too quiet in a channel for too long, or it may just feel like saying something at any given time. To get something to say a random module is chosen and its randomThought is invoked.
Specified by:
randomThought in interface IRCBotModule
Overrides:
randomThought in interface AbstractIRCBotModule
Parameters:
channel - The channel that is too quiet.
sender - The bot who asked for this thought.
Returns:
A String containing a random thought or null if this module has nothing nice to say.

time2str

public static String time2str(long milli)

timeComment

public static String timeComment(Date d,
                                 String nick)