ircbot.modules
Class Modules
- Comparable, IRCBotModule
Module handler. This module is responsible for all communication
between the IRC engine and other modules. The IRC engine will only
see one module, preferably this one. The module distributes
commands, IRC messages and events to all modules (including it
self). It also handles loading and unloading of modules. Unloading
this module is a bad idea.
String | action(IRCMessage message) - action is invoked by the bot when someone types a message starting
with a member of getCommands().
|
void | addModule(IRCBotModule mod) -
Module handling
|
String | getAuthor()
|
IRCBot | getBot()
|
String | getDescription(String topic, Language lang) - getDescription is called to get the information printed by the
!help command.
|
IRCBotModule | getModule(String name)
|
String | getModuleName() - getModuleName is called to get the name of this module.
|
Collection | getModules()
|
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 | periodicSave() -
Saving and loading preferences and other stuff.
|
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.
|
String | saveState()
|
activateEvent , addCommand , compareTo , getCommands , getModuleHandler , getProbability , loadState , parseMessage , randomThought , saveState , scheduleEvent , scheduleEvent , setModuleHandler , toString |
Modules
public Modules(IRCBot bot)
action
public String action(IRCMessage message)
action is invoked by the bot when someone types a message starting
with a member of getCommands().
- action in interface IRCBotModule
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.
- 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.
addModule
public void addModule(IRCBotModule mod)
Module handling
getDescription
public String getDescription(String topic,
Language lang)
getDescription is called to get the information printed by the
!help command.
- getDescription in interface IRCBotModule
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.
- 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.
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.
- getModuleName in interface IRCBotModule
- A String containing the name of this module.
getModules
public Collection getModules()
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.
- parseMessage in interface IRCBotModule
- parseMessage in interface AbstractIRCBotModule
message
- The message sent to the IRC channel.
- A String containing a reply to the message, or null if
nothing should be sent to the IRC channel.
periodicSave
public String periodicSave()
Saving and loading preferences and other stuff.
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.
- randomThought in interface IRCBotModule
- randomThought in interface AbstractIRCBotModule
channel
- The channel that is too quiet.sender
- The bot who asked for this thought.
- A String containing a random thought or null if this
module has nothing nice to say.
saveState
public String saveState()