summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/start.jabot.sh2
-rw-r--r--src/org/jogamp/jabot/irc/CatOut.java27
-rw-r--r--src/org/jogamp/jabot/irc/LogBot.java42
3 files changed, 59 insertions, 12 deletions
diff --git a/scripts/start.jabot.sh b/scripts/start.jabot.sh
index 7fbf78f..6dc5c10 100755
--- a/scripts/start.jabot.sh
+++ b/scripts/start.jabot.sh
@@ -8,7 +8,7 @@ export JRE_HOME=/opt-linux-x86_64/jre7
JAVA=$JRE_HOME/bin/java
nohup nice $JAVA \
-cp $JABOT_HOME/build/jabot.jar org.jogamp.jabot.irc.CatOut \
- -login jogamp -name CatOut \
+ -login srvlogin -nick ircnickname -nickpwd nickserv_id_password \
-server irc.freenode.net -channel jogamp \
-logrotate 86400000 \
-logrotateStart 0505 \
diff --git a/src/org/jogamp/jabot/irc/CatOut.java b/src/org/jogamp/jabot/irc/CatOut.java
index 85fac42..07e4ae5 100644
--- a/src/org/jogamp/jabot/irc/CatOut.java
+++ b/src/org/jogamp/jabot/irc/CatOut.java
@@ -38,7 +38,7 @@ public class CatOut extends PircBot {
public static void main(String[] args) throws Exception {
final String joinMessage;
final boolean showHostname = false;
- final String login, name, server, channelNoHash;
+ final String login, nick, nickPwd, server, channelNoHash;
final boolean verbose;
final long logrotate, logrotateStart;
final String logprefix, urlprefix;
@@ -46,7 +46,7 @@ public class CatOut extends PircBot {
final File htmlHeader, htmlFooter;
{
String _joinMessage = "This channel is logged";
- String _login=null, _name=null, _server=null, _channelNoHash=null;
+ String _login=null, _nick=null, _nickPwd=null, _server=null, _channelNoHash=null;
boolean _verbose=false;
long _logrotate = 0, _logrotateStart=System.currentTimeMillis();
String _logprefix="", _urlprefix="";
@@ -59,9 +59,12 @@ public class CatOut extends PircBot {
} else if(args[i].equals("-login")) {
i++;
_login = args[i];
- } else if(args[i].equals("-name")) {
+ } else if( args[i].equals("-name") || args[i].equals("-nick") ) {
i++;
- _name = args[i];
+ _nick = args[i];
+ } else if( args[i].equals("-nickpwd") ) {
+ i++;
+ _nickPwd = args[i];
} else if(args[i].equals("-server")) {
i++;
_server = args[i];
@@ -106,15 +109,15 @@ public class CatOut extends PircBot {
}
}
if( null == _login ||
- null == _name ||
+ null == _nick ||
null == _server ||
null == _channelNoHash ||
( _htmlOut && null == _htmlHeader || null == _htmlFooter ) ) {
- System.err.println("Incomplete commandline, use "+CatOut.class.getName()+" -login VAL -name VAL -server VAL -channel VAL [-verbose] [-joinMessage VAL] [-htmlHeader VAL -htmlFooter VAL] [-logrotate millis [-logrotateStart hhmm] [-logprefix VAL] [-urlprefix VAL]]");
+ System.err.println("Incomplete commandline, use "+CatOut.class.getName()+" -login VAL -nick VAL -server VAL -channel VAL [-verbose] [-joinMessage VAL] [-htmlHeader VAL -htmlFooter VAL] [-logrotate millis [-logrotateStart hhmm] [-logprefix VAL] [-urlprefix VAL]]");
return;
}
joinMessage = _joinMessage;
- login=_login; name=_name;
+ login=_login; nick=_nick; nickPwd=_nickPwd;
server=_server; channelNoHash=_channelNoHash;
verbose=_verbose;
logrotate = _logrotate;
@@ -144,7 +147,8 @@ public class CatOut extends PircBot {
final LogBot bot = new LogBot(showHostname, joinMessage, htmlOut);
bot.setVerbose(verbose);
- bot.setLoginAndName(login, name);
+ bot.setLoginAndNick(login, nick);
+
LogStream logOut;
if ( 0 < logrotate ) {
logOut = new LogStream(bot, logprefix, urlprefix, server, channelNoHash, htmlHeader);
@@ -154,6 +158,13 @@ public class CatOut extends PircBot {
} else {
logOut = null;
}
+ if( null != nickPwd && nickPwd.length() > 0 ) {
+ bot.setPostConnectAction(new Runnable() {
+ public void run() {
+ bot.identify(nickPwd);
+ }
+ });
+ }
bot.connect(server);
bot.joinChannel(HASH+channelNoHash);
if( 0 < logrotate ) {
diff --git a/src/org/jogamp/jabot/irc/LogBot.java b/src/org/jogamp/jabot/irc/LogBot.java
index a4d143f..3f76f61 100644
--- a/src/org/jogamp/jabot/irc/LogBot.java
+++ b/src/org/jogamp/jabot/irc/LogBot.java
@@ -44,6 +44,8 @@ public class LogBot extends PircBot {
private final Object outSync = new Object();
private PrintStream out;
private int lineCount;
+
+ private Runnable postConnectAction;
public LogBot(boolean showHostname, String joinMessage, boolean xmlOut) {
this(showHostname, joinMessage, TimeTool.getNearZuluTimeZone(), Locale.getDefault(), System.out, xmlOut);
@@ -56,6 +58,7 @@ public class LogBot extends PircBot {
this.out = out;
this.joinMessage = joinMessage;
this.lineCount = 0;
+ this.postConnectAction = null;
}
public final void setJoinMessage(String joinMessage) {
@@ -65,11 +68,27 @@ public class LogBot extends PircBot {
return joinMessage;
}
- public final void setLoginAndName(String login, String nick) {
+ /**
+ * <p>
+ * Sets the internal login of the Bot. This should be set before joining
+ * any servers.
+ * </p>
+ * <p>
+ * Sets the internal nick of the bot. This is only to be called by the
+ * PircBot class in response to notification of nick changes that apply
+ * to us.
+ * </p>
+ */
+ public final void setLoginAndNick(String login, String nick) {
super.setLogin(login);
super.setName(nick);
}
-
+
+ /** Sets the action to be performed after each connect, incl. reconnect. */
+ public final void setPostConnectAction(Runnable action) {
+ this.postConnectAction = action;
+ }
+
public final Calendar getCalendar() {
return calendar;
}
@@ -243,6 +262,14 @@ public class LogBot extends PircBot {
}
}
+ @Override
+ public void onConnect() {
+ if( null != postConnectAction ) {
+ postConnectAction.run();
+ }
+ }
+
+ @Override
public void onDisconnect() {
append(NAVY, "* Disconnected.");
while (!isConnected()) {
@@ -258,5 +285,14 @@ public class LogBot extends PircBot {
}
}
}
- }
+ }
+
+ @Override
+ public String toString() {
+ return "Version{" + this.getVersion() + "}" +
+ " Connected{" + this.isConnected() + "}" +
+ " Server{" + this.getServer() + "}" +
+ " Port{" + this.getPort() + "}" +
+ " Password{" + (null != this.getPassword() ) + "}";
+ }
}