diff options
Diffstat (limited to 'src/org/jogamp/jabot/irc/LogBot.java')
-rw-r--r-- | src/org/jogamp/jabot/irc/LogBot.java | 42 |
1 files changed, 39 insertions, 3 deletions
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() ) + "}";
+ }
}
|