|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.lang.Thread
|
+--irssibot.modules.AbstractModule
|
+--irssibot.modules.Logger
MySQL logging module.
MySQL clauses to initialize the database is as follows. The tables need to be named like this:
quote table: networkname_channelname_quote
nick table: networkname_nick
alias table: networkname_alias
Networkname is the symbolic name given to a network in the bot's configuration
file. It is the name returned by ServerConnection.getInstanceData().getNetwork()
Therefore you need one quote table per channel, and one nick table and alias table per network.
NOTE: you do not need to create any of the tables, this module will automatically create them for you. The SQL code is just supplied here to show the structure of the tables to help the development of 3rd party applications on top of the logging system.
DROP DATABASE IF EXISTS ircstats;
CREATE DATABASE ircstats;
CONNECT ircstats;
DROP TABLE IF EXISTS networkname_alias;
CREATE TABLE networkname_alias
(
alias_id INT( 11 ) NOT NULL AUTO_INCREMENT,
name VARCHAR( 32 ) NOT NULL,
PRIMARY KEY ( alias_id ),
UNIQUE ( name ),
INDEX ( name )
);
DROP TABLE IF EXISTS networkname_nick;
CREATE TABLE networkname_nick
(
nick_id INT( 11 ) NOT NULL AUTO_INCREMENT,
name VARCHAR( 32 ) NOT NULL,
alias_id INT( 11 ) NOT NULL,
status enum(' ','D','U'),
PRIMARY KEY ( nick_id ),
UNIQUE ( name ),
INDEX ( name ),
INDEX ( alias_id )
);
DROP TABLE IF EXISTS networkname_channelname_quote;
CREATE TABLE networkname_channelname_quote
(
nick_id INT( 11 ) NOT NULL,
quoteline MEDIUMTEXT NOT NULL,
created DATETIME NOT NULL,
INDEX ( nick_id )
);
| Field Summary | |
private boolean |
autoNickJoin
Indicates whether to automatically connect nicks on NICK change. |
private boolean |
autoQuote
Indicates whether to automatically quote people on on channel JOINs |
private ServerConnection |
caller
|
private boolean |
changed
Whether the state of the module has changed and needs saving. |
private java.sql.Connection |
connection
Database connection |
private Core |
core
Reference to bot core |
private java.lang.String |
dbName
Name of database descriptor to use. |
private static java.text.SimpleDateFormat |
defaultDateFormat
Default dateformat |
private Host |
host
|
private static java.lang.String |
moduleInfo
Module info |
private java.text.SimpleDateFormat |
sdf
Dateformat to use for displaying quotes |
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 | |
Logger()
Default constructor |
|
| Method Summary | |
private void |
closeConnection()
Disconnects from the database. |
private void |
commandAdd(Host host,
User invoker,
java.lang.String[] args,
Channel channel)
Add command |
private void |
commandEdit(Host host,
User invoker,
java.lang.String[] args,
Channel channel)
Edit command |
private void |
commandLast(Host host,
User invoker,
java.lang.String[] args,
Channel channel)
Last command. |
private void |
commandList(Host host,
User invoker,
java.lang.String[] args,
Channel channel)
List command |
private void |
commandQuote(Host host,
User invoker,
java.lang.String[] args,
Channel channel)
Quote command. |
private boolean |
createAliasTable(java.lang.String tableName)
|
private boolean |
createNickTable(java.lang.String tableName)
|
private boolean |
createQuoteTable(java.lang.String tableName)
|
private void |
deleteFromAliasTable(java.lang.String nick,
java.lang.String aliasTableName)
Deletes an entry from alias table. |
void |
doJoin(IrcMessage message)
Handles JOINs |
private void |
doNick(IrcMessage message)
Handles NICK changes :porkkanaz!^asd@dreamland.tky.hut.fi NICK :testink |
private void |
doPrivmsg(IrcMessage message)
Handles PRIVMSGs. |
private int |
getAliasIdFromAliasTable(java.lang.String nick,
java.lang.String aliasTableName)
Get alias_id corresponding to a certain name in alias table. |
private int |
getAliasIdFromNickTable(java.lang.String nick,
java.lang.String nickTableName)
Get alias_id corresponding to a certain name in nick table. |
java.lang.String |
getModuleInfo()
Returns a module info string. |
private int |
getNickId(java.lang.String nick,
java.lang.String nickTableName)
|
private int |
getNumAliases(int aliasId,
java.lang.String nickTableName)
Get number of alias nicks for an alias_id |
private int |
getNumNicks(java.lang.String nickTableName)
Return the number of nicks in nick table |
private int |
getNumQuotes(java.lang.String nick,
java.lang.String nickTableName,
java.lang.String aliasTableName,
java.lang.String quoteTableName)
Counts number of quotelines for given nickId, or if none given (nick == null), get number of all quotes. |
java.util.Properties |
getState()
Returns module state. |
private void |
insertIntoNickTable(int aliasId,
java.lang.String nick,
java.lang.String nickTableName)
Inserts a new entry in nick table |
private void |
joinNicks(java.lang.String nick1,
java.lang.String nick2,
java.lang.String nickTableName,
java.lang.String aliasTableName,
boolean insert)
Joins two nicks (nick1 to nick2) together by their alias_id's: Gets alias_id from nick2 and sets nick1's alias_id to the value. |
private void |
log(Host host,
Channel channel,
java.lang.String msg)
Insert quote into log |
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 |
setAliasId(java.lang.String nick,
int aliasId,
java.lang.String nickTableName)
Sets the alias_id for given entry in nick table |
private java.lang.String |
strip(java.lang.String input)
Returns a string with non-alphanumerics removed from the input. |
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 |
private static final java.lang.String moduleInfo
private static final java.text.SimpleDateFormat defaultDateFormat
private java.text.SimpleDateFormat sdf
private java.lang.String dbName
Core.getDatabaseConnection(String)private boolean autoQuote
private boolean autoNickJoin
private boolean changed
private Host host
private java.lang.String source
private ServerConnection caller
private java.sql.Connection connection
private Core core
| Constructor Detail |
public Logger()
| Method Detail |
public java.util.Properties getState()
getState in class AbstractModulepublic java.lang.String getModuleInfo()
getModuleInfo in class AbstractModuleprivate void closeConnection()
public boolean onLoad(java.util.Properties state,
Core core)
onLoad in class AbstractModulestate - initial state for the modulecore - refenrece to bot core
Corepublic void onUnload()
onUnload in class AbstractModuleprivate java.lang.String strip(java.lang.String input)
input - the input String
private boolean createQuoteTable(java.lang.String tableName)
private boolean createNickTable(java.lang.String tableName)
private boolean createAliasTable(java.lang.String tableName)
private int getNumAliases(int aliasId,
java.lang.String nickTableName)
aliasId - nickTableName - per-network name of nick table
private int getNickId(java.lang.String nick,
java.lang.String nickTableName)
private int getAliasIdFromAliasTable(java.lang.String nick,
java.lang.String aliasTableName)
nick - Nick whose alias id to look foraliasTableName - per-network name for alias table
private void insertIntoNickTable(int aliasId,
java.lang.String nick,
java.lang.String nickTableName)
aliasId - alias_id to assign to nick entrynick - nick (name) to insertnickTableName - per-network name of nick table
private int getAliasIdFromNickTable(java.lang.String nick,
java.lang.String nickTableName)
nick - Nick whose alias id to look fornickTableName - per-network name for nick table
private void log(Host host,
Channel channel,
java.lang.String msg)
host - Host of nick saying the messagechannel - channel on which the message was saidmsg - the said message
private int getNumQuotes(java.lang.String nick,
java.lang.String nickTableName,
java.lang.String aliasTableName,
java.lang.String quoteTableName)
nick - nick in nick table or null if getting count
for all quotelines in database.nickTableName - name of nick tablealiasTableName - name alias tablequoteTableName - name of quote table
private boolean setAliasId(java.lang.String nick,
int aliasId,
java.lang.String nickTableName)
nick - name entry in nick tablealiasId - new value for alias_idnickTableName - per-network name for nick table
private void deleteFromAliasTable(java.lang.String nick,
java.lang.String aliasTableName)
nick - indicates the entry to be deleted.aliasTableName - per-network name of alias tableprivate int getNumNicks(java.lang.String nickTableName)
private void joinNicks(java.lang.String nick1,
java.lang.String nick2,
java.lang.String nickTableName,
java.lang.String aliasTableName,
boolean insert)
nick1 - nick to assign new alias_id tonick2 - nick to acquire the alias_id fromnickTableName - per-network name of nick tablealiasTableName - per-network name of alias tableinsert - indicates whether to INSERT nick1 into nick table if
it does not exists there. this is used with autoNickJoining on NICK changes.
private void commandQuote(Host host,
User invoker,
java.lang.String[] args,
Channel channel)
host - host of invokerinvoker - invoking Userargs - arguments of commandchannel - target channel
private void commandLast(Host host,
User invoker,
java.lang.String[] args,
Channel channel)
host - host of invokerinvoker - invoking Userargs - arguments of commandchannel - target channel
private void commandEdit(Host host,
User invoker,
java.lang.String[] args,
Channel channel)
host - host of invokerinvoker - invoking Userargs - arguments of commandchannel - target channel
private void commandAdd(Host host,
User invoker,
java.lang.String[] args,
Channel channel)
host - host of invokerinvoker - invoking Userargs - arguments of commandchannel - target channel
private void commandList(Host host,
User invoker,
java.lang.String[] args,
Channel channel)
host - host of invokerinvoker - invoking Userargs - arguments of commandchannel - target channel
private void processCmdMsg(Host host,
java.lang.String cmd,
Channel channel,
java.lang.String[] args)
channel - valid channel nameprivate void doNick(IrcMessage message)
message - NICK IrcMessage to processprivate void doPrivmsg(IrcMessage message)
message - PRIVMSG IrcMessage to processpublic void doJoin(IrcMessage message)
message - the JOIN IrcMessage
protected void processMessage(IrcMessage message,
ServerConnection serverConnection)
processMessage in class AbstractModulemessage - IrcMessage to processserverConnection - invoking ServerConnectionprivate void write(java.lang.String message)
message - message to send
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||