cherbot-commit Mailing List for CherBot (Page 4)
Status: Alpha
Brought to you by:
christianhujer
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(39) |
Nov
(1) |
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
|
Feb
(4) |
Mar
|
Apr
|
May
|
Jun
(67) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(1) |
Nov
|
Dec
|
| 2008 |
Jan
(3) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(6) |
Dec
(19) |
| 2009 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <chr...@us...> - 2007-06-17 13:08:24
|
Revision: 74
http://svn.sourceforge.net/cherbot/?rev=74&view=rev
Author: christianhujer
Date: 2007-06-17 06:08:22 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Added a Q/A-pair.
Modified Paths:
--------------
trunk/FAQ
Modified: trunk/FAQ
===================================================================
--- trunk/FAQ 2007-06-17 13:07:49 UTC (rev 73)
+++ trunk/FAQ 2007-06-17 13:08:22 UTC (rev 74)
@@ -1,6 +1,12 @@
FAQ
---
+Q: How do I run CherBot?
+A: Currently CherBot cannot be really run yet. There are only three test modules that you can run:
+* net.sf.cherbot.CherBot
+* net.sf.cherbot.metaserver.MetaServerInfo
+* net.sf.cherbot.IRCConnection
+
Q: When I try to run CherBot I get java.sql.SQLException: No suitable driver found for jdbc:derby:cherbotdb;create=true
A: You need to have derby.jar on your class path. Try this:
java -cp CherBot.jar:$JAVA_HOME/db/lib/derby.jar net.sf.cherbot.CherBot
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-17 13:07:56
|
Revision: 73
http://svn.sourceforge.net/cherbot/?rev=73&view=rev
Author: christianhujer
Date: 2007-06-17 06:07:49 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Changed symbol names to more standard names for later extraction of common super classes for different connection implementations.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/IRCConnection.java
Modified: trunk/src/net/sf/cherbot/IRCConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-17 10:22:10 UTC (rev 72)
+++ trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-17 13:07:49 UTC (rev 73)
@@ -27,6 +27,9 @@
*/
public class IRCConnection extends BasicCommand {
+ /** The default IRC port. */
+ public static final int DEFAULT_IRC_PORT = 6667;
+
/** The username to use for IRC authentication.
* This is the IRC username, not the IRC nick.
*/
@@ -44,10 +47,10 @@
@Nullable private String nickPassword;
/** The IRC server host to connect to. */
- @NotNull private String ircHost;
+ @NotNull private String host;
/** The IRC server port to connect to. */
- private int ircPort = 6667;
+ private int port = DEFAULT_IRC_PORT;
/** The Socket for communication. */
@Nullable private Socket socket;
@@ -75,7 +78,7 @@
* @throws IOException In case of connection problems.
*/
private void connect() throws IOException {
- final Socket socket = new Socket(ircHost, ircPort);
+ final Socket socket = new Socket(host, port);
this.socket = socket;
final PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), "utf-8"));
this.out = out;
@@ -176,19 +179,19 @@
}
/** Sets the host of the IRC server to connect to.
- * @param ircHost Host of the IRC server.
+ * @param host Host of the IRC server.
*/
- @Option(type = OptionType.REQUIRED, value = {"ircHost"})
- public void setIrcHost(@NotNull final String ircHost) {
- this.ircHost = ircHost;
+ @Option(type = OptionType.REQUIRED, value = {"host"})
+ public void setHost(@NotNull final String host) {
+ this.host = host;
}
/** Sets the port of the IRC server to connect to.
- * @param ircPort Port of the IRC server.
+ * @param port Port of the IRC server.
*/
- @Option({"ircPort"})
- public void setIrcPort(@NotNull final Integer ircPort) {
- this.ircPort = ircPort;
+ @Option({"port"})
+ public void setPort(@NotNull final Integer port) {
+ this.port = port;
}
} // class IRCConnection
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-17 10:22:12
|
Revision: 72
http://svn.sourceforge.net/cherbot/?rev=72&view=rev
Author: christianhujer
Date: 2007-06-17 03:22:10 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Made ircHost option a required option.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/IRCConnection.java
Modified: trunk/src/net/sf/cherbot/IRCConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-17 10:19:54 UTC (rev 71)
+++ trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-17 10:22:10 UTC (rev 72)
@@ -18,6 +18,7 @@
import net.sf.japi.io.args.BasicCommand;
import net.sf.japi.io.args.ArgParser;
import net.sf.japi.io.args.Option;
+import net.sf.japi.io.args.OptionType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -177,7 +178,7 @@
/** Sets the host of the IRC server to connect to.
* @param ircHost Host of the IRC server.
*/
- @Option({"ircHost"})
+ @Option(type = OptionType.REQUIRED, value = {"ircHost"})
public void setIrcHost(@NotNull final String ircHost) {
this.ircHost = ircHost;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-17 10:19:56
|
Revision: 71
http://svn.sourceforge.net/cherbot/?rev=71&view=rev
Author: christianhujer
Date: 2007-06-17 03:19:54 -0700 (Sun, 17 Jun 2007)
Log Message:
-----------
Turned IRCConnection into a command bean. That allows for better testing.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/IRCConnection.java
Modified: trunk/src/net/sf/cherbot/IRCConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-16 22:26:06 UTC (rev 70)
+++ trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-17 10:19:54 UTC (rev 71)
@@ -12,53 +12,109 @@
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
+import java.util.List;
+import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.util.regex.Matcher;
+import net.sf.japi.io.args.BasicCommand;
+import net.sf.japi.io.args.ArgParser;
+import net.sf.japi.io.args.Option;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
/** An IRCConnection represents a connection to an IRC server.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
-public class IRCConnection extends AbstractConnection implements Runnable {
+public class IRCConnection extends BasicCommand {
+ /** The username to use for IRC authentication.
+ * This is the IRC username, not the IRC nick.
+ */
+ @NotNull private String username = "cherbot";
+
+ /** The realname to use for IRC authentication.
+ * This is the realname, not the IRC nick.
+ */
+ @NotNull private String realname = "CherBot";
+
+ /** The nickname to use for IRC. */
+ @NotNull private String nickname = "CherBot";
+
+ /** The password to authenticate with NickServ or <code>null</code> if no authentication is desired. */
+ @Nullable private String nickPassword;
+
+ /** The IRC server host to connect to. */
+ @NotNull private String ircHost;
+
+ /** The IRC server port to connect to. */
+ private int ircPort = 6667;
+
/** The Socket for communication. */
- @NotNull private final Socket socket;
+ @Nullable private Socket socket;
/** The PrintStream to write to. */
- @NotNull private final PrintWriter out;
+ @Nullable private PrintWriter out;
/** The BufferedReader to read from. */
- @NotNull private final BufferedReader in;
+ @Nullable private BufferedReader in;
- /** Creates an IRCConnecntion.
- * @param socket Socket
+ /** Creates an IRCConnection. */
+ public IRCConnection() {
+ }
+
+ /** Main program.
+ * For testing purposes.
+ * @param args Command line arguments
* @throws IOException In case of I/O problems.
*/
- public IRCConnection(@NotNull final Socket socket) throws IOException {
- this.socket = socket;
- out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), "utf-8"));
- in = new BufferedReader(new InputStreamReader(socket.getInputStream(), "utf-8"));
- new Thread(this).start();
+ public static void main(final String... args) throws IOException {
+ ArgParser.simpleParseAndRun(new IRCConnection(), args);
}
- /** {@inheritDoc} */
- public void run() {
- final String username = "cherbot";
- final String realname = "CherBot";
- final String nick = "CherBot";
- final String password = "foobar";
- final boolean registerWithNickServ = true;
- final String[] initialChannels = { "#cherbot" };
+ /** Establishes a connection.
+ * @throws IOException In case of connection problems.
+ */
+ private void connect() throws IOException {
+ final Socket socket = new Socket(ircHost, ircPort);
+ this.socket = socket;
+ final PrintWriter out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), "utf-8"));
+ this.out = out;
+ this.in = new BufferedReader(new InputStreamReader(socket.getInputStream(), "utf-8"));
out.println("USER " + username + " 0 * :" + realname);
- out.println("NICK " + nick);
- for (final String initialChannel : initialChannels) {
- out.println("JOIN " + initialChannel);
+ out.println("NICK " + nickname);
+ if (nickPassword != null) {
+ out.println("PRIVMSG NICKSERV :IDENTIFY " + nickPassword);
}
- if (registerWithNickServ) {
- out.println("PRIVMSG NICKSERV :IDENTIFY " + password);
- }
out.flush();
+ }
+
+ /** Closes a connection.
+ * @throws IOException In case of connection problems.
+ */
+ private void disconnect() throws IOException {
try {
+ final Socket socket = this.socket;
+ if (socket != null) {
+ socket.close();
+ }
+ } finally {
+ socket = null;
+ in = null;
+ out = null;
+ }
+ }
+
+ /** {@inheritDoc} */
+ public int run(@NotNull final List<String> args) throws Exception {
+ connect();
+ try {
+ final PrintWriter out = this.out;
+ assert out != null;
+ final BufferedReader in = this.in;
+ assert in != null;
+ for (final String initialChannel : args) {
+ out.println("JOIN " + initialChannel);
+ out.flush();
+ }
final Pattern pattern = Pattern.compile("^:([^!]+)!([^ ]+) PRIVMSG ([^ ]+) :(.*)$");
final Matcher matcher = pattern.matcher("");
for (String line; (line = in.readLine()) != null;) {
@@ -66,29 +122,72 @@
matcher.reset(line);
if (matcher.matches()) {
final String actor = matcher.group(1);
- if (nick.equals(actor)) {
+ if (nickname.equals(actor)) {
continue;
}
- final String actorIdentity = matcher.group(2);
- final String channel = matcher.group(3);
+ //final String actorIdentity = matcher.group(2);
+ //final String channel = matcher.group(3);
final String message = matcher.group(4);
System.out.println("<" + actor + "> " + message);
- out.println("PRIVMSG " + (channel.startsWith("#") ? channel : actor) + " :" + "you said: " + message);
- out.flush();
+ //out.println("PRIVMSG " + (channel.startsWith("#") ? channel : actor) + " :" + "you said: " + message);
+ //out.flush();
}
}
- } catch (final IOException e) {
- System.err.println(e);
+ return 0;
+ } finally {
+ disconnect();
}
}
- /** Main program.
- * For testing purposes.
- * @param args Command line arguments
- * @throws IOException In case of I/O problems.
+ /** Sets the username to use for connecting to the IRC server.
+ * Note that this is the IRC username, not the nick.
+ * @param username Username to use for IRC.
*/
- public static void main(final String... args) throws IOException {
- new IRCConnection(new Socket(args[0], Integer.parseInt(args[1])));
+ @Option({"username"})
+ public void setUsername(@NotNull final String username) {
+ this.username = username;
}
+ /** Sets the realname to use for connecting to the IRC server.
+ * Note that this is the IRC realname, not the nick.
+ * @param realname Realname to use for IRC.
+ */
+ @Option({"realname"})
+ public void setRealname(@NotNull final String realname) {
+ this.realname = realname;
+ }
+
+ /** Sets the nickname to use for connecting to the IRC server.
+ * @param nickname Nickname to use for IRC.
+ */
+ @Option({"nickname"})
+ public void setNickname(@NotNull final String nickname) {
+ this.nickname = nickname;
+ }
+
+ /** Sets the password to use for authentication with NickServ.
+ * Setting it to <code>null</code> means to not authenticate with NickServ.
+ * @param nickPassword Password to use for authentication with NickServ.
+ */
+ @Option({"nickPassword"})
+ public void setNickPassword(@Nullable final String nickPassword) {
+ this.nickPassword = nickPassword;
+ }
+
+ /** Sets the host of the IRC server to connect to.
+ * @param ircHost Host of the IRC server.
+ */
+ @Option({"ircHost"})
+ public void setIrcHost(@NotNull final String ircHost) {
+ this.ircHost = ircHost;
+ }
+
+ /** Sets the port of the IRC server to connect to.
+ * @param ircPort Port of the IRC server.
+ */
+ @Option({"ircPort"})
+ public void setIrcPort(@NotNull final Integer ircPort) {
+ this.ircPort = ircPort;
+ }
+
} // class IRCConnection
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-16 22:26:07
|
Revision: 70
http://svn.sourceforge.net/cherbot/?rev=70&view=rev
Author: christianhujer
Date: 2007-06-16 15:26:06 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Added MetaServerInfo.properties for MetaServerInfo built-in help.
Added Paths:
-----------
trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.properties
Added: trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.properties
===================================================================
--- trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.properties (rev 0)
+++ trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.properties 2007-06-16 22:26:06 UTC (rev 70)
@@ -0,0 +1,7 @@
+#
+# Copyright \xA9 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+# License: GNU General Public License v2.0 or newer.
+# See file COPYING in the root directory of this project.
+#
+setHost=Metaserver host.
+setPort=Metaserver port.
Property changes on: trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-16 22:23:09
|
Revision: 69
http://svn.sourceforge.net/cherbot/?rev=69&view=rev
Author: christianhujer
Date: 2007-06-16 15:23:07 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Started implementation of PlayerModel as first PersistentModule implementation.
Added Paths:
-----------
trunk/src/net/sf/cherbot/Player.java
trunk/src/net/sf/cherbot/PlayerModule.java
Added: trunk/src/net/sf/cherbot/Player.java
===================================================================
--- trunk/src/net/sf/cherbot/Player.java (rev 0)
+++ trunk/src/net/sf/cherbot/Player.java 2007-06-16 22:23:07 UTC (rev 69)
@@ -0,0 +1,55 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+/** Represents a single player.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class Player {
+
+ /** The id of this player. */
+ private final int id;
+
+ /** The serverId of this player. */
+ private final int serverId;
+
+ /** The name of this player. */
+ private final String name;
+
+ /** Create a Player.
+ * @param id Id of this player.
+ * @param serverId ServerId of this player.
+ * @param name Name of this player.
+ */
+ public Player(final int id, final int serverId, final String name) {
+ this.id = id;
+ this.serverId = serverId;
+ this.name = name;
+ }
+
+ /** Returns the id of this player.
+ * @return The id of this player.
+ */
+ public int getId() {
+ return id;
+ }
+
+ /** Returns the server id of this player.
+ * @return The server id of this player.
+ */
+ public int getServerId() {
+ return serverId;
+ }
+
+ /** Returns the name of this player.
+ * @return The name of this player.
+ */
+ public String getName() {
+ return name;
+ }
+
+} // class Player
Property changes on: trunk/src/net/sf/cherbot/Player.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/net/sf/cherbot/PlayerModule.java
===================================================================
--- trunk/src/net/sf/cherbot/PlayerModule.java (rev 0)
+++ trunk/src/net/sf/cherbot/PlayerModule.java 2007-06-16 22:23:07 UTC (rev 69)
@@ -0,0 +1,62 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+import org.jetbrains.annotations.NotNull;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.ResultSet;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Created by IntelliJ IDEA.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class PlayerModule implements PersistentModule {
+
+ private final List<Player> players = new ArrayList<Player>();
+
+ /** {@inheritDoc} */
+ public void load(@NotNull final Connection con) throws SQLException {
+ final PreparedStatement stmt = con.prepareStatement("SELECT id, serverId, name FROM Player");
+ final ResultSet result = stmt.executeQuery();
+ while (result.next()) {
+ final int id = result.getInt(1);
+ final int serverId = result.getInt(2);
+ final String name = result.getString(3);
+ players.add(new Player(id, serverId, name));
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void save(@NotNull final Connection con) throws SQLException {
+ createTables(con);
+ final PreparedStatement lookup = con.prepareStatement("SELECT id FROM Player WHERE id = ?");
+ final PreparedStatement update = con.prepareStatement("UPDATE Player SET id = ?, serverId = ?, name = ? WHERE id = ?");
+ final PreparedStatement insert = con.prepareStatement("INSERT INTO Player (id, serverId, name) VALUES (?, ?, ?)");
+ }
+
+ /** Creates the tables if they don't exist.
+ * @param con Connection to use for creating the tables.
+ * @throws SQLException In case of persistence problems.
+ */
+ private void createTables(@NotNull final Connection con) throws SQLException {
+ try {
+ final PreparedStatement stmt = con.prepareStatement("CREATE TABLE Player (id INT, serverId INT, name VARCHAR(32)");
+ stmt.execute();
+ } catch (final SQLException ignore) {
+ System.err.println(ignore);
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void parseMessage(@NotNull final Channel channel, @NotNull final String msg) {
+ }
+
+} // class PlayerModule
Property changes on: trunk/src/net/sf/cherbot/PlayerModule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-16 22:13:33
|
Revision: 68
http://svn.sourceforge.net/cherbot/?rev=68&view=rev
Author: christianhujer
Date: 2007-06-16 15:13:30 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Added SQLException to persistence methods.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/PersistentModule.java
Modified: trunk/src/net/sf/cherbot/PersistentModule.java
===================================================================
--- trunk/src/net/sf/cherbot/PersistentModule.java 2007-06-16 21:29:50 UTC (rev 67)
+++ trunk/src/net/sf/cherbot/PersistentModule.java 2007-06-16 22:13:30 UTC (rev 68)
@@ -8,6 +8,7 @@
import org.jetbrains.annotations.NotNull;
import java.sql.Connection;
+import java.sql.SQLException;
/** A module provides a specific feature for CherBot.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
@@ -16,12 +17,14 @@
/** Instructs this module to load its data.
* @param con Database connection for persistence.
+ * @throws SQLException in case of persistence problems.
*/
- void load(@NotNull Connection con);
+ void load(@NotNull Connection con) throws SQLException;
/** Instructs this module to save its data.
* @param con Database connection for persistence.
+ * @throws SQLException in case of persistence problems.
*/
- void save(@NotNull Connection con);
+ void save(@NotNull Connection con) throws SQLException;
} // interface Module
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-16 21:29:54
|
Revision: 67
http://svn.sourceforge.net/cherbot/?rev=67&view=rev
Author: christianhujer
Date: 2007-06-16 14:29:50 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Updated FAQ.
Modified Paths:
--------------
trunk/FAQ
Modified: trunk/FAQ
===================================================================
--- trunk/FAQ 2007-06-16 21:17:54 UTC (rev 66)
+++ trunk/FAQ 2007-06-16 21:29:50 UTC (rev 67)
@@ -1,4 +1,6 @@
FAQ
---
-No faq yet.
+Q: When I try to run CherBot I get java.sql.SQLException: No suitable driver found for jdbc:derby:cherbotdb;create=true
+A: You need to have derby.jar on your class path. Try this:
+java -cp CherBot.jar:$JAVA_HOME/db/lib/derby.jar net.sf.cherbot.CherBot
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-16 21:17:56
|
Revision: 66
http://svn.sourceforge.net/cherbot/?rev=66&view=rev
Author: christianhujer
Date: 2007-06-16 14:17:54 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Fixed serial version missing warnings.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java
trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java
Modified: trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java
===================================================================
--- trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java 2007-06-16 21:17:46 UTC (rev 65)
+++ trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java 2007-06-16 21:17:54 UTC (rev 66)
@@ -16,6 +16,9 @@
*/
public class MetaServerEntry implements Serializable {
+ /** Serial Version. */
+ private static final long serialVersionUID = 1L;
+
/** The pattern for parsing an entryString from the metaserver. */
@NotNull private static final Pattern entryPattern = Pattern.compile("(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)");
Modified: trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java
===================================================================
--- trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java 2007-06-16 21:17:46 UTC (rev 65)
+++ trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java 2007-06-16 21:17:54 UTC (rev 66)
@@ -25,6 +25,9 @@
*/
public class MetaServerInfo extends BasicCommand implements Iterable<MetaServerEntry>, Serializable, Updatable {
+ /** Serial Version. */
+ private static final long serialVersionUID = 1L;
+
/** The default meta server. */
@NotNull public static final String DEFAULT_META_SERVER_HOST = "damn.informatik.uni-bremen.de";
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-16 21:17:47
|
Revision: 65
http://svn.sourceforge.net/cherbot/?rev=65&view=rev
Author: christianhujer
Date: 2007-06-16 14:17:46 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Adding missing argparser stuff to jar.
Modified Paths:
--------------
trunk/build.xml
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2007-06-16 21:10:22 UTC (rev 64)
+++ trunk/build.xml 2007-06-16 21:17:46 UTC (rev 65)
@@ -125,6 +125,7 @@
<attribute name="Main-Class" value="net.sf.cherbot.CherBot" />
</manifest>
<fileset dir="classes" />
+ <zipfileset src="lib/japi-lib-argparser-0.1.jar" />
</jar>
</target>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-16 21:10:24
|
Revision: 64
http://svn.sourceforge.net/cherbot/?rev=64&view=rev
Author: christianhujer
Date: 2007-06-16 14:10:22 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Fixed classpath in build.xml.
Modified Paths:
--------------
trunk/build.xml
Modified: trunk/build.xml
===================================================================
--- trunk/build.xml 2007-06-16 20:57:56 UTC (rev 63)
+++ trunk/build.xml 2007-06-16 21:10:22 UTC (rev 64)
@@ -37,6 +37,7 @@
<classpath>
<pathelement location="lib/annotations.jar" />
<pathelement location="lib/junit-4.1.jar" />
+ <pathelement location="lib/japi-lib-argparser-0.1.jar" />
</classpath>
<compilerarg line="-Xlint:all"/>
<compilerarg line="-Xmaxerrs 400"/>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-16 20:58:01
|
Revision: 63
http://svn.sourceforge.net/cherbot/?rev=63&view=rev
Author: christianhujer
Date: 2007-06-16 13:57:56 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Updated documentation about how to access CherBot's Subversion Repository.
Modified Paths:
--------------
trunk/src/doc/subversion.xhtml
Modified: trunk/src/doc/subversion.xhtml
===================================================================
--- trunk/src/doc/subversion.xhtml 2007-06-16 20:52:33 UTC (rev 62)
+++ trunk/src/doc/subversion.xhtml 2007-06-16 20:57:56 UTC (rev 63)
@@ -13,7 +13,7 @@
To checkout a normal working copy of the latest development, checkout the trunk.
This is what's called HEAD or MAIN/LATEST in other version control systems.
</p>
- <p><code>svn co https://svn.sourceforge.net/svnroot/cherbot/trunk cherbot</code></p>
+ <p><code>svn co https://cherbot.svn.sourceforge.net/svnroot/cherbot/trunk cherbot</code></p>
<h2>Rules</h2>
<p>
Current rules are this:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-16 20:52:45
|
Revision: 62
http://svn.sourceforge.net/cherbot/?rev=62&view=rev
Author: christianhujer
Date: 2007-06-16 13:52:33 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Finished implementation of EchoModule.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/EchoModule.java
Modified: trunk/src/net/sf/cherbot/EchoModule.java
===================================================================
--- trunk/src/net/sf/cherbot/EchoModule.java 2007-06-16 20:51:19 UTC (rev 61)
+++ trunk/src/net/sf/cherbot/EchoModule.java 2007-06-16 20:52:33 UTC (rev 62)
@@ -15,7 +15,7 @@
/** {@inheritDoc} */
public void parseMessage(@NotNull final Channel channel, @NotNull final String msg) {
- //To change body of implemented methods use File | Settings | File Templates.
+ channel.send(msg);
}
} // class EchoModule
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-16 20:51:24
|
Revision: 61
http://svn.sourceforge.net/cherbot/?rev=61&view=rev
Author: christianhujer
Date: 2007-06-16 13:51:19 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Added package documentation. Improved javadoc comments and documentation.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/AbstractConnection.java
trunk/src/net/sf/cherbot/ClanModule.java
trunk/src/net/sf/cherbot/Module.java
Added Paths:
-----------
trunk/src/net/sf/cherbot/metaserver/package-info.java
trunk/src/net/sf/cherbot/package-info.java
Modified: trunk/src/net/sf/cherbot/AbstractConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/AbstractConnection.java 2007-06-16 20:22:54 UTC (rev 60)
+++ trunk/src/net/sf/cherbot/AbstractConnection.java 2007-06-16 20:51:19 UTC (rev 61)
@@ -6,7 +6,7 @@
package net.sf.cherbot;
-/** A AbstractConnection represents the connection to a server and has one or more channels.
+/** An AbstractConnection represents the connection to a server and has one or more channels.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public abstract class AbstractConnection {
Modified: trunk/src/net/sf/cherbot/ClanModule.java
===================================================================
--- trunk/src/net/sf/cherbot/ClanModule.java 2007-06-16 20:22:54 UTC (rev 60)
+++ trunk/src/net/sf/cherbot/ClanModule.java 2007-06-16 20:51:19 UTC (rev 61)
@@ -9,8 +9,7 @@
import org.jetbrains.annotations.NotNull;
import java.sql.Connection;
-/**
- * Created by IntelliJ IDEA.
+/** Module for Clans.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class ClanModule implements PersistentModule {
@@ -23,7 +22,8 @@
public void save(@NotNull final Connection con) {
}
- public void parseMessage(@NotNull Channel channel, @NotNull String msg) {
- //To change body of implemented methods use File | Settings | File Templates.
+ /** {@inheritDoc} */
+ public void parseMessage(@NotNull final Channel channel, @NotNull final String msg) {
}
+
} // class ClanModule
Modified: trunk/src/net/sf/cherbot/Module.java
===================================================================
--- trunk/src/net/sf/cherbot/Module.java 2007-06-16 20:22:54 UTC (rev 60)
+++ trunk/src/net/sf/cherbot/Module.java 2007-06-16 20:51:19 UTC (rev 61)
@@ -1,3 +1,9 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
package net.sf.cherbot;
import org.jetbrains.annotations.NotNull;
@@ -2,4 +8,3 @@
-/**
- * Created by IntelliJ IDEA.
+/** Interface for Modules.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
@@ -13,4 +18,5 @@
* @param msg Message to parse
*/
void parseMessage(@NotNull Channel channel, @NotNull String msg);
-}
+
+} // interface Module
Added: trunk/src/net/sf/cherbot/metaserver/package-info.java
===================================================================
--- trunk/src/net/sf/cherbot/metaserver/package-info.java (rev 0)
+++ trunk/src/net/sf/cherbot/metaserver/package-info.java 2007-06-16 20:51:19 UTC (rev 61)
@@ -0,0 +1,10 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+/** The package net.sf.cherbot.metaserver contains metaserver access.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+package net.sf.cherbot.metaserver;
Property changes on: trunk/src/net/sf/cherbot/metaserver/package-info.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/net/sf/cherbot/package-info.java
===================================================================
--- trunk/src/net/sf/cherbot/package-info.java (rev 0)
+++ trunk/src/net/sf/cherbot/package-info.java 2007-06-16 20:51:19 UTC (rev 61)
@@ -0,0 +1,10 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+/** The package net.sf.cherbot contains the main classes of CherBot.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+package net.sf.cherbot;
Property changes on: trunk/src/net/sf/cherbot/package-info.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-16 20:22:59
|
Revision: 60
http://svn.sourceforge.net/cherbot/?rev=60&view=rev
Author: christianhujer
Date: 2007-06-16 13:22:54 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Added unfinnished framework for servers, channels, modules and commands.
Modified Paths:
--------------
trunk/cherbot.iml
trunk/cherbot.ipr
trunk/src/doc/requirements2.0.xhtml
trunk/src/net/sf/cherbot/CherBot.java
Added Paths:
-----------
trunk/src/doc/datamodel.xhtml
trunk/src/net/sf/cherbot/AbstractConnection.java
trunk/src/net/sf/cherbot/Channel.java
trunk/src/net/sf/cherbot/ClanModule.java
trunk/src/net/sf/cherbot/Command.java
trunk/src/net/sf/cherbot/EchoModule.java
trunk/src/net/sf/cherbot/IRCConnection.java
trunk/src/net/sf/cherbot/Module.java
trunk/src/net/sf/cherbot/PersistentModule.java
Modified: trunk/cherbot.iml
===================================================================
--- trunk/cherbot.iml 2007-06-16 11:07:54 UTC (rev 59)
+++ trunk/cherbot.iml 2007-06-16 20:22:54 UTC (rev 60)
@@ -39,6 +39,7 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="library" name="derby" level="project" />
<orderEntryProperties />
</component>
<component name="copyright">
Modified: trunk/cherbot.ipr
===================================================================
--- trunk/cherbot.ipr 2007-06-16 11:07:54 UTC (rev 59)
+++ trunk/cherbot.ipr 2007-06-16 20:22:54 UTC (rev 60)
@@ -1110,6 +1110,13 @@
<JAVADOC />
<SOURCES />
</library>
+ <library name="derby">
+ <CLASSES>
+ <root url="jar://$PROJECT_DIR$/../../../Documents/Downloads/jdk1.6.0_01/db/lib/derby.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
</component>
<component name="uidesigner-configuration" />
</project>
Added: trunk/src/doc/datamodel.xhtml
===================================================================
--- trunk/src/doc/datamodel.xhtml (rev 0)
+++ trunk/src/doc/datamodel.xhtml 2007-06-16 20:22:54 UTC (rev 60)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ ~ License: GNU General Public License v2.0 or newer.
+ ~ See file COPYING in the root directory of this project.
+ -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
+ <head>
+ <title>CherBot 2.0 Datamodel</title>
+ </head>
+ <body>
+ <h1>CherBot 2.0 Datamodel</h1>
+ <p>
+ This is a description of the data model of CherBot 2.0.
+ </p>
+ </body>
+</html>
Property changes on: trunk/src/doc/datamodel.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/html
Name: svn:eol-style
+ LF
Modified: trunk/src/doc/requirements2.0.xhtml
===================================================================
--- trunk/src/doc/requirements2.0.xhtml 2007-06-16 11:07:54 UTC (rev 59)
+++ trunk/src/doc/requirements2.0.xhtml 2007-06-16 20:22:54 UTC (rev 60)
@@ -31,9 +31,15 @@
<li>CherBot must work for Daimonin.</li>
<li>CherBot must work for Crossfire.</li>
<li>CherBot must work for IRC.</li>
- <li>CherBot must be able to connect to more than one server.</li>
+ <li>CherBot must be able to connect to more than one daimonin server.</li>
+ <li>CherBot must be able to connect to more than one crossfire server.</li>
+ <li>CherBot must be able to connect to more than one irc server.</li>
+ <li>CherBot must be able to join more than one IRC channel.</li>
<li>CherBot must maintain groups called clans.</li>
<li>CherBot must be able to act as a communication proxy / multiplexer for members of a clan.</li>
+ <li>It must be possible to ask CherBot when a player was last seen on a specific server.</li>
+ <li>It must be possible to ask CherBot whether a player is currently online on a specific server.</li>
+ <li>CherBot must be able to log all communication.</li>
</ul>
</body>
</html>
Added: trunk/src/net/sf/cherbot/AbstractConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/AbstractConnection.java (rev 0)
+++ trunk/src/net/sf/cherbot/AbstractConnection.java 2007-06-16 20:22:54 UTC (rev 60)
@@ -0,0 +1,14 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+/** A AbstractConnection represents the connection to a server and has one or more channels.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public abstract class AbstractConnection {
+
+} // class AbstractConnection
Property changes on: trunk/src/net/sf/cherbot/AbstractConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/net/sf/cherbot/Channel.java
===================================================================
--- trunk/src/net/sf/cherbot/Channel.java (rev 0)
+++ trunk/src/net/sf/cherbot/Channel.java 2007-06-16 20:22:54 UTC (rev 60)
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.NotNull;
+
+/** A Channel uniquely identifies a protocol (type) / server / channel combination.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public abstract class Channel {
+
+ /** The types of channels. */
+ public static enum Type {
+
+ /** A Crossfire channel. */
+ CROSSFIRE,
+
+ /** A Daimonin channel. */
+ DAIMONIN,
+
+ /** An IRC channel. */
+ IRC
+ } // enum Type
+
+ /** The type of this channel. */
+ @NotNull private Type type;
+
+ /** The server of this channel. */
+ @NotNull private String server;
+
+ /** The channel of this channel.
+ * Maybe <code>null</code> if it's the default / no channel.
+ */
+ @Nullable private String channel;
+
+ /** Sends a message to this channel.
+ * @param msg Message to send
+ */
+ public abstract void send(@NotNull final String msg);
+
+} // class Channel
Property changes on: trunk/src/net/sf/cherbot/Channel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Modified: trunk/src/net/sf/cherbot/CherBot.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBot.java 2007-06-16 11:07:54 UTC (rev 59)
+++ trunk/src/net/sf/cherbot/CherBot.java 2007-06-16 20:22:54 UTC (rev 60)
@@ -8,6 +8,8 @@
import java.io.IOException;
import java.util.List;
+import java.sql.DriverManager;
+import java.sql.Connection;
import net.sf.japi.io.args.ArgParser;
import net.sf.japi.io.args.BasicCommand;
import org.jetbrains.annotations.NotNull;
@@ -24,8 +26,14 @@
ArgParser.simpleParseAndRun(new CherBot(), args);
}
+ /** The JDBC connection for data persistence. */
+ @NotNull private Connection con;
+
/** {@inheritDoc} */
public int run(@NotNull final List<String> strings) throws Exception {
+ //DriverManager.registerDriver(new org.apache.derby.jdbc.EmbeddedDriver());
+ con = DriverManager.getConnection("jdbc:derby:cherbotdb;create=true");
+ System.out.println(con);
return 0;
}
Added: trunk/src/net/sf/cherbot/ClanModule.java
===================================================================
--- trunk/src/net/sf/cherbot/ClanModule.java (rev 0)
+++ trunk/src/net/sf/cherbot/ClanModule.java 2007-06-16 20:22:54 UTC (rev 60)
@@ -0,0 +1,29 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+import org.jetbrains.annotations.NotNull;
+import java.sql.Connection;
+
+/**
+ * Created by IntelliJ IDEA.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class ClanModule implements PersistentModule {
+
+ /** {@inheritDoc} */
+ public void load(@NotNull final Connection con) {
+ }
+
+ /** {@inheritDoc} */
+ public void save(@NotNull final Connection con) {
+ }
+
+ public void parseMessage(@NotNull Channel channel, @NotNull String msg) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+} // class ClanModule
Property changes on: trunk/src/net/sf/cherbot/ClanModule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/net/sf/cherbot/Command.java
===================================================================
--- trunk/src/net/sf/cherbot/Command.java (rev 0)
+++ trunk/src/net/sf/cherbot/Command.java 2007-06-16 20:22:54 UTC (rev 60)
@@ -0,0 +1,37 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.annotation.ElementType;
+
+/** Annotation that marks a method as command method.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.METHOD})
+public @interface Command {
+
+ /** The regular expressions for executing this command.
+ * The number of groups must match the parameter count of the annotated method after its two mandatory parameters server and actor.
+ * @return Regular expressions for executing this command.
+ */
+ String[] values();
+
+ /** The description of this command.
+ * @return Description of this command.
+ */
+ String description();
+
+ /** The examples for this command.
+ * @return Examples for this command.
+ */
+ String examples();
+
+} // @interface Command
Property changes on: trunk/src/net/sf/cherbot/Command.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/net/sf/cherbot/EchoModule.java
===================================================================
--- trunk/src/net/sf/cherbot/EchoModule.java (rev 0)
+++ trunk/src/net/sf/cherbot/EchoModule.java 2007-06-16 20:22:54 UTC (rev 60)
@@ -0,0 +1,21 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+import org.jetbrains.annotations.NotNull;
+
+/** Module that simply echoes a message.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class EchoModule implements Module {
+
+ /** {@inheritDoc} */
+ public void parseMessage(@NotNull final Channel channel, @NotNull final String msg) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+} // class EchoModule
Property changes on: trunk/src/net/sf/cherbot/EchoModule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/net/sf/cherbot/IRCConnection.java
===================================================================
--- trunk/src/net/sf/cherbot/IRCConnection.java (rev 0)
+++ trunk/src/net/sf/cherbot/IRCConnection.java 2007-06-16 20:22:54 UTC (rev 60)
@@ -0,0 +1,94 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.net.Socket;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import org.jetbrains.annotations.NotNull;
+
+/** An IRCConnection represents a connection to an IRC server.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class IRCConnection extends AbstractConnection implements Runnable {
+
+ /** The Socket for communication. */
+ @NotNull private final Socket socket;
+
+ /** The PrintStream to write to. */
+ @NotNull private final PrintWriter out;
+
+ /** The BufferedReader to read from. */
+ @NotNull private final BufferedReader in;
+
+ /** Creates an IRCConnecntion.
+ * @param socket Socket
+ * @throws IOException In case of I/O problems.
+ */
+ public IRCConnection(@NotNull final Socket socket) throws IOException {
+ this.socket = socket;
+ out = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), "utf-8"));
+ in = new BufferedReader(new InputStreamReader(socket.getInputStream(), "utf-8"));
+ new Thread(this).start();
+ }
+
+ /** {@inheritDoc} */
+ public void run() {
+ final String username = "cherbot";
+ final String realname = "CherBot";
+ final String nick = "CherBot";
+ final String password = "foobar";
+ final boolean registerWithNickServ = true;
+ final String[] initialChannels = { "#cherbot" };
+ out.println("USER " + username + " 0 * :" + realname);
+ out.println("NICK " + nick);
+ for (final String initialChannel : initialChannels) {
+ out.println("JOIN " + initialChannel);
+ }
+ if (registerWithNickServ) {
+ out.println("PRIVMSG NICKSERV :IDENTIFY " + password);
+ }
+ out.flush();
+ try {
+ final Pattern pattern = Pattern.compile("^:([^!]+)!([^ ]+) PRIVMSG ([^ ]+) :(.*)$");
+ final Matcher matcher = pattern.matcher("");
+ for (String line; (line = in.readLine()) != null;) {
+ System.out.println(line);
+ matcher.reset(line);
+ if (matcher.matches()) {
+ final String actor = matcher.group(1);
+ if (nick.equals(actor)) {
+ continue;
+ }
+ final String actorIdentity = matcher.group(2);
+ final String channel = matcher.group(3);
+ final String message = matcher.group(4);
+ System.out.println("<" + actor + "> " + message);
+ out.println("PRIVMSG " + (channel.startsWith("#") ? channel : actor) + " :" + "you said: " + message);
+ out.flush();
+ }
+ }
+ } catch (final IOException e) {
+ System.err.println(e);
+ }
+ }
+
+ /** Main program.
+ * For testing purposes.
+ * @param args Command line arguments
+ * @throws IOException In case of I/O problems.
+ */
+ public static void main(final String... args) throws IOException {
+ new IRCConnection(new Socket(args[0], Integer.parseInt(args[1])));
+ }
+
+} // class IRCConnection
Property changes on: trunk/src/net/sf/cherbot/IRCConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/net/sf/cherbot/Module.java
===================================================================
--- trunk/src/net/sf/cherbot/Module.java (rev 0)
+++ trunk/src/net/sf/cherbot/Module.java 2007-06-16 20:22:54 UTC (rev 60)
@@ -0,0 +1,16 @@
+package net.sf.cherbot;
+
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Created by IntelliJ IDEA.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public interface Module {
+
+ /** Parses a message from a channel.
+ * @param channel Channel this message comes from
+ * @param msg Message to parse
+ */
+ void parseMessage(@NotNull Channel channel, @NotNull String msg);
+}
Property changes on: trunk/src/net/sf/cherbot/Module.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/net/sf/cherbot/PersistentModule.java
===================================================================
--- trunk/src/net/sf/cherbot/PersistentModule.java (rev 0)
+++ trunk/src/net/sf/cherbot/PersistentModule.java 2007-06-16 20:22:54 UTC (rev 60)
@@ -0,0 +1,27 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+import org.jetbrains.annotations.NotNull;
+import java.sql.Connection;
+
+/** A module provides a specific feature for CherBot.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public interface PersistentModule extends Module {
+
+ /** Instructs this module to load its data.
+ * @param con Database connection for persistence.
+ */
+ void load(@NotNull Connection con);
+
+ /** Instructs this module to save its data.
+ * @param con Database connection for persistence.
+ */
+ void save(@NotNull Connection con);
+
+} // interface Module
Property changes on: trunk/src/net/sf/cherbot/PersistentModule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-16 11:07:58
|
Revision: 59
http://svn.sourceforge.net/cherbot/?rev=59&view=rev
Author: christianhujer
Date: 2007-06-16 04:07:54 -0700 (Sat, 16 Jun 2007)
Log Message:
-----------
Fixed some wrong documentation.
Fixed MetaServerInfo options bug (-h declared twice).
Changed default MetaServerInfo to be daimonin metaserver, not empty.
Adopted the unit test accordingly.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java
trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java
trunk/src/test/net/sf/cherbot/metaserver/MetaServerInfoTest.java
Modified: trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java
===================================================================
--- trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java 2007-06-10 10:12:30 UTC (rev 58)
+++ trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java 2007-06-16 11:07:54 UTC (rev 59)
@@ -11,8 +11,7 @@
import java.util.regex.Matcher;
import java.io.Serializable;
-/**
- * Created by IntelliJ IDEA.
+/** Represents a single entry in the meta server.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class MetaServerEntry implements Serializable {
@@ -44,7 +43,7 @@
/** Unknown3. */
@NotNull private final String unknown3;
- /** Unknown3. */
+ /** Unknown4. */
@NotNull private final String unknown4;
/** Create a MetaServerEntry.
Modified: trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java
===================================================================
--- trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java 2007-06-10 10:12:30 UTC (rev 58)
+++ trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java 2007-06-16 11:07:54 UTC (rev 59)
@@ -25,21 +25,27 @@
*/
public class MetaServerInfo extends BasicCommand implements Iterable<MetaServerEntry>, Serializable, Updatable {
+ /** The default meta server. */
+ @NotNull public static final String DEFAULT_META_SERVER_HOST = "damn.informatik.uni-bremen.de";
+
+ /** The default meta port. */
+ public static final int DEFAULT_META_SERVER_PORT = 13326;
+
/** The entries of this MetaServerInfo. */
@NotNull private List<MetaServerEntry> metaServerEntries = new ArrayList<MetaServerEntry>();
/** The address (ip address or hostname) of the meta server to query. */
- @NotNull private String host;
+ @NotNull private String host = DEFAULT_META_SERVER_HOST;
/** The port of the meta server to query. */
- private int port;
+ private int port = DEFAULT_META_SERVER_PORT;
/** Creates a MetaServerInfo.
* This constructor creates an initially empty meta server info with a non functional host and port.
* This is useful for testing and for using {@link MetaServerInfo} as a bean.
*/
public MetaServerInfo() {
- this("", 0);
+ this(DEFAULT_META_SERVER_HOST, DEFAULT_META_SERVER_PORT);
}
/** Creates a MetaServerInfo.
@@ -88,7 +94,7 @@
/** Sets the host of the meta server to query.
* @param host The host of the meta server to query.
*/
- @Option({"h", "host"})
+ @Option({"host"})
public void setHost(@NotNull final String host) {
this.host = host;
}
@@ -96,7 +102,7 @@
/** Sets the port of the meta server to query.
* @param port The port of the meta server to query.
*/
- @Option({"p", "port"})
+ @Option({"port"})
public void setPort(final int port) {
this.port = port;
}
Modified: trunk/src/test/net/sf/cherbot/metaserver/MetaServerInfoTest.java
===================================================================
--- trunk/src/test/net/sf/cherbot/metaserver/MetaServerInfoTest.java 2007-06-10 10:12:30 UTC (rev 58)
+++ trunk/src/test/net/sf/cherbot/metaserver/MetaServerInfoTest.java 2007-06-16 11:07:54 UTC (rev 59)
@@ -57,7 +57,7 @@
@Test public void testUpdate() throws IOException {
final String metaServerString = "192.168.0.1|177|riedquat|20|0.9.7|My own Daimonin server.|02|03|04\n" +
"192.168.0.2|177|lave|20|0.9.7|My other Daimonin server.|02|03|04\n";
- final MetaServerInfo testling = new MetaServerInfo();
+ final MetaServerInfo testling = new MetaServerInfo("", 0);
testling.parse(new BufferedReader(new StringReader(metaServerString)));
Assert.assertEquals("MetaServerInfo now must contain 2 entries.", 2, testling.size());
Assert.assertEquals("ip address of first entry must be 192.168.0.1.", "192.168.0.1", testling.get(0).getIpaddress());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-10 10:12:32
|
Revision: 58
http://svn.sourceforge.net/cherbot/?rev=58&view=rev
Author: christianhujer
Date: 2007-06-10 03:12:30 -0700 (Sun, 10 Jun 2007)
Log Message:
-----------
Added missing @NotNull annotations.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java
Modified: trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java
===================================================================
--- trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java 2007-06-09 17:47:23 UTC (rev 57)
+++ trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java 2007-06-10 10:12:30 UTC (rev 58)
@@ -58,7 +58,7 @@
* @param unknown3 Unknown3.
* @param unknown4 Unknown4.
*/
- public MetaServerEntry(final String ipaddress, final String unknown1, final String hostname, final int playerCount, final String version, final String description, final String unknown2, final String unknown3, final String unknown4) {
+ public MetaServerEntry(@NotNull final String ipaddress, @NotNull final String unknown1, @NotNull final String hostname, final int playerCount, @NotNull final String version, @NotNull final String description, @NotNull final String unknown2, @NotNull final String unknown3, @NotNull final String unknown4) {
this.ipaddress = ipaddress;
this.unknown1 = unknown1;
this.hostname = hostname;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-09 17:47:25
|
Revision: 57
http://svn.sourceforge.net/cherbot/?rev=57&view=rev
Author: christianhujer
Date: 2007-06-09 10:47:23 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Improved meta server stuff: Made implementation serializable, improved constructor documentation (JavaBean), added main method.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java
trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java
Modified: trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java
===================================================================
--- trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java 2007-06-09 17:20:42 UTC (rev 56)
+++ trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java 2007-06-09 17:47:23 UTC (rev 57)
@@ -9,12 +9,13 @@
import org.jetbrains.annotations.NotNull;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
+import java.io.Serializable;
/**
* Created by IntelliJ IDEA.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
-public class MetaServerEntry {
+public class MetaServerEntry implements Serializable {
/** The pattern for parsing an entryString from the metaserver. */
@NotNull private static final Pattern entryPattern = Pattern.compile("(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)");
Modified: trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java
===================================================================
--- trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java 2007-06-09 17:20:42 UTC (rev 56)
+++ trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java 2007-06-09 17:47:23 UTC (rev 57)
@@ -9,6 +9,7 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
@@ -17,11 +18,12 @@
import net.sf.cherbot.Updatable;
import net.sf.japi.io.args.BasicCommand;
import net.sf.japi.io.args.Option;
+import net.sf.japi.io.args.ArgParser;
/** Represents the information stored in a MetaServer.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
-public class MetaServerInfo extends BasicCommand implements Iterable<MetaServerEntry>, Updatable {
+public class MetaServerInfo extends BasicCommand implements Iterable<MetaServerEntry>, Serializable, Updatable {
/** The entries of this MetaServerInfo. */
@NotNull private List<MetaServerEntry> metaServerEntries = new ArrayList<MetaServerEntry>();
@@ -33,11 +35,11 @@
private int port;
/** Creates a MetaServerInfo.
- * This constructor creates a dummy meta server with no functional host and port.
- * It cannot be used for querying and exists for testing purposes only.
+ * This constructor creates an initially empty meta server info with a non functional host and port.
+ * This is useful for testing and for using {@link MetaServerInfo} as a bean.
*/
public MetaServerInfo() {
- this("dummy", 0);
+ this("", 0);
}
/** Creates a MetaServerInfo.
@@ -136,4 +138,11 @@
return 0;
}
+ /** Main program.
+ * @param args Command line arguments (try --help).
+ */
+ public static void main(final String... args) {
+ ArgParser.simpleParseAndRun(new MetaServerInfo(), args);
+ }
+
} // class MetaServerInfo
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-09 17:20:44
|
Revision: 56
http://svn.sourceforge.net/cherbot/?rev=56&view=rev
Author: christianhujer
Date: 2007-06-09 10:20:42 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Removed unused field that shouldn't be there anyway.
Modified Paths:
--------------
trunk/src/net/sf/cherbot/CherBot.java
Modified: trunk/src/net/sf/cherbot/CherBot.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBot.java 2007-06-09 17:19:23 UTC (rev 55)
+++ trunk/src/net/sf/cherbot/CherBot.java 2007-06-09 17:20:42 UTC (rev 56)
@@ -6,12 +6,11 @@
package net.sf.cherbot;
-import net.sf.japi.io.args.BasicCommand;
+import java.io.IOException;
+import java.util.List;
import net.sf.japi.io.args.ArgParser;
+import net.sf.japi.io.args.BasicCommand;
import org.jetbrains.annotations.NotNull;
-import java.util.List;
-import java.io.OutputStream;
-import java.io.IOException;
/** Main class of Cherbot.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
@@ -25,8 +24,6 @@
ArgParser.simpleParseAndRun(new CherBot(), args);
}
- private OutputStream out;
-
/** {@inheritDoc} */
public int run(@NotNull final List<String> strings) throws Exception {
return 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-09 17:19:24
|
Revision: 55
http://svn.sourceforge.net/cherbot/?rev=55&view=rev
Author: christianhujer
Date: 2007-06-09 10:19:23 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Added skeleton CherBot + Test.
Added Paths:
-----------
trunk/src/net/sf/cherbot/CherBot.java
trunk/src/test/net/sf/cherbot/CherBotTest.java
Added: trunk/src/net/sf/cherbot/CherBot.java
===================================================================
--- trunk/src/net/sf/cherbot/CherBot.java (rev 0)
+++ trunk/src/net/sf/cherbot/CherBot.java 2007-06-09 17:19:23 UTC (rev 55)
@@ -0,0 +1,71 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+import net.sf.japi.io.args.BasicCommand;
+import net.sf.japi.io.args.ArgParser;
+import org.jetbrains.annotations.NotNull;
+import java.util.List;
+import java.io.OutputStream;
+import java.io.IOException;
+
+/** Main class of Cherbot.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class CherBot extends BasicCommand {
+
+ /** Main program.
+ * @param args Command line arguments (currently ignored).
+ */
+ public static void main(final String... args) {
+ ArgParser.simpleParseAndRun(new CherBot(), args);
+ }
+
+ private OutputStream out;
+
+ /** {@inheritDoc} */
+ public int run(@NotNull final List<String> strings) throws Exception {
+ return 0;
+ }
+
+ public void metaserver() throws IOException {
+ // read "62.75.224.80|177|daimonin.game-server.cc|52|0.9.7|This is the Daimonin 0.9.7 server.|0|0|0\n"
+ }
+
+ public void connect() throws IOException {
+ // write 0x00 0x29 "version 991023 991023 Daimonin SDL Client"
+ // read 0x00 0x1e 0x02 "991023 991023 Daimonin Server"
+ // write 0x00 0x99 "setup sound 1 map2 cmd 1 mapsize 17x17 darkness 1 facecache 1 skf 3386|dd257ea spf 2737|404f6ead bpf 227483|8ab2a06 stf 2253|16d49f0f amf 262790|ec2627ee"
+ // read 0x00 0x75 0x17 " sound 1 map2cmd 1 mapsize 17x17 darkness 1 facecache 1 skf OK spf OK bpf 227639|117ae13a stf OK amf 263415|ec0d5f79"
+ // write 0x00 0x04 "rf 4"
+ // read lots of data
+ // write 0x00 0x04 "rf 3"
+ // read lots of data
+ // write 0x00 0x05 "addme"
+ // read 0x00 0x06 0x18 "4 QN0" 0x00 0x01 0x15
+ // write 0x00 0x12 "reply LFoobuzzer49" // L not part of name
+ // read 0x00 0x06 0x18 "4 QP0"
+ // write 0x00 0x0E "reply xxxxxxxx"
+ // read 0x00 0x10 0x06 0x00 0x00 "Welcome Back!"
+ // read 0x00 0x24 0x06 0x00 0x00 "Cheristheus has entered the game."
+ // read 0x00 0x19 0x11 0x00 0x4e 0x01 0x60 0x00 0x02 0x27 0x2a 0x00 0x00 0x10 0xec 0x0b "Cheristheus"
+ // read lots of data
+ // read 0x00 0x16 0x05 0x00 0x07 0x02 0x42 0x21 0x80 0x01 "Cheristheus" 0x00 0x90 0xea
+ // read 0x00 0x16 0x05 0x00 0x07 0x02 0x42 0x21 0x80 0x01 "Cheristheus" 0x00 0x90 0xeb
+ // read 0x00 0x16 0x05 0x00 0x07 0x02 0x42 0x21 0x80 0x01 "Cheristheus" 0x00 0x90 0xec
+ // write 0x00 0x0d "ncom " 0x00 0x01 0xff 0xff 0xff 0xff "/n" // north
+ // write 0x00 0x0d "ncom " 0x00 0x02 0xff 0xff 0xff 0xff "/n" // north
+ // write 0x00 0x0d "ncom " 0x00 0x03 0xff 0xff 0xff 0xff "/e" // east
+ // write 0x00 0x0d "ncom " 0x00 0x04 0xff 0xff 0xff 0xff "/s" // south
+ // write 0x00 0x0d "ncom " 0x00 0x05 0xff 0xff 0xff 0xff "/w" // west
+ // write 0x00 0x0e "ncom " 0x00 0x06 0xff 0xff 0xff 0xff "/sw" // southwest
+ // write 0x00 0x0e "ncom " 0x00 0x07 0xff 0xff 0xff 0xff "/se" // southeast
+ // write 0x00 0x0e "ncom " 0x00 0x08 0xff 0xff 0xff 0xff "/nw" // northwest
+ // write 0x00 0x0e "ncom " 0x00 0x09 0xff 0xff 0xff 0xff "/ne" // northeast
+ // write 0x00 0x0f "ncom " 0x00 0x0A 0xff 0xff 0xff 0xff "/who" // /who
+ }
+} // class CherBot
Property changes on: trunk/src/net/sf/cherbot/CherBot.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/test/net/sf/cherbot/CherBotTest.java
===================================================================
--- trunk/src/test/net/sf/cherbot/CherBotTest.java (rev 0)
+++ trunk/src/test/net/sf/cherbot/CherBotTest.java 2007-06-09 17:19:23 UTC (rev 55)
@@ -0,0 +1,21 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package test.net.sf.cherbot;
+
+import net.sf.cherbot.CherBot;
+import org.junit.Test;
+
+/** Unit-Test for {@link CherBot}
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class CherBotTest {
+
+ /** Tests whether {@link CherBot#run(java.util.List)} works. */
+ @Test public void testRun() {
+ }
+
+} // class CherBotTest
Property changes on: trunk/src/test/net/sf/cherbot/CherBotTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-09 17:18:11
|
Revision: 54
http://svn.sourceforge.net/cherbot/?rev=54&view=rev
Author: christianhujer
Date: 2007-06-09 10:18:08 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Ignore this one.
Modified Paths:
--------------
trunk/cherbot.ipr
Modified: trunk/cherbot.ipr
===================================================================
--- trunk/cherbot.ipr 2007-06-09 17:17:38 UTC (rev 53)
+++ trunk/cherbot.ipr 2007-06-09 17:18:08 UTC (rev 54)
@@ -1111,10 +1111,6 @@
<SOURCES />
</library>
</component>
- <component name="uidesigner-configuration">
- <option name="INSTRUMENT_CLASSES" value="true" />
- <option name="COPY_FORMS_RUNTIME_TO_OUTPUT" value="true" />
- <option name="DEFAULT_LAYOUT_MANAGER" value="GridLayoutManager" />
- </component>
+ <component name="uidesigner-configuration" />
</project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-09 17:17:41
|
Revision: 53
http://svn.sourceforge.net/cherbot/?rev=53&view=rev
Author: christianhujer
Date: 2007-06-09 10:17:38 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Cosmetic: Fixed formatting.
Modified Paths:
--------------
trunk/src/test/net/sf/cherbot/metaserver/MetaServerInfoTest.java
Modified: trunk/src/test/net/sf/cherbot/metaserver/MetaServerInfoTest.java
===================================================================
--- trunk/src/test/net/sf/cherbot/metaserver/MetaServerInfoTest.java 2007-06-09 17:15:40 UTC (rev 52)
+++ trunk/src/test/net/sf/cherbot/metaserver/MetaServerInfoTest.java 2007-06-09 17:17:38 UTC (rev 53)
@@ -73,4 +73,5 @@
Assert.assertEquals("ip address of first entry still must be 192.168.0.1.", "192.168.0.1", testling.get(0).getIpaddress());
Assert.assertEquals("ip address of second entry still must be 192.168.0.2.", "192.168.0.2", testling.get(1).getIpaddress());
}
+
} // class MetaServerInfoTest
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-09 17:15:42
|
Revision: 52
http://svn.sourceforge.net/cherbot/?rev=52&view=rev
Author: christianhujer
Date: 2007-06-09 10:15:40 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Added updatable interface.
Added Paths:
-----------
trunk/src/net/sf/cherbot/Updatable.java
Added: trunk/src/net/sf/cherbot/Updatable.java
===================================================================
--- trunk/src/net/sf/cherbot/Updatable.java (rev 0)
+++ trunk/src/net/sf/cherbot/Updatable.java 2007-06-09 17:15:40 UTC (rev 52)
@@ -0,0 +1,22 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot;
+
+/** Interface for classes that hold information which can be updated on demand.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public interface Updatable {
+
+ /** Update information.
+ * An update must be performed atomically.
+ * That means if this method returns normally, the implementing object must reflect the new state only.
+ * If this method throws an exception, the implementing object must remain unchanged and reflect its state prior to the failed update invocation.
+ * @throws Exception When the update couldn't be performed due to errors.
+ */
+ void update() throws Exception;
+
+} // interface Updatable
Property changes on: trunk/src/net/sf/cherbot/Updatable.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-09 17:14:37
|
Revision: 51
http://svn.sourceforge.net/cherbot/?rev=51&view=rev
Author: christianhujer
Date: 2007-06-09 10:14:35 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Added MetaServer stuff.
Added Paths:
-----------
trunk/src/net/sf/cherbot/metaserver/
trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java
trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java
trunk/src/test/net/sf/cherbot/metaserver/
trunk/src/test/net/sf/cherbot/metaserver/MetaServerEntryTest.java
trunk/src/test/net/sf/cherbot/metaserver/MetaServerInfoTest.java
Added: trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java
===================================================================
--- trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java (rev 0)
+++ trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java 2007-06-09 17:14:35 UTC (rev 51)
@@ -0,0 +1,162 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot.metaserver;
+
+import org.jetbrains.annotations.NotNull;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
+/**
+ * Created by IntelliJ IDEA.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class MetaServerEntry {
+
+ /** The pattern for parsing an entryString from the metaserver. */
+ @NotNull private static final Pattern entryPattern = Pattern.compile("(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)\\|(.*?)");
+
+ /** The ip address of this entry. */
+ @NotNull private final String ipaddress;
+
+ /** Unknown1. */
+ @NotNull private final String unknown1;
+
+ /** The host name of this entry. */
+ @NotNull private final String hostname;
+
+ /** The number of currently logged in players. */
+ private final int playerCount;
+
+ /** The version string of this entry's server. */
+ @NotNull private final String version;
+
+ /** The description of this entry. */
+ @NotNull private final String description;
+
+ /** Unknown2. */
+ @NotNull private final String unknown2;
+
+ /** Unknown3. */
+ @NotNull private final String unknown3;
+
+ /** Unknown3. */
+ @NotNull private final String unknown4;
+
+ /** Create a MetaServerEntry.
+ * @param ipaddress The ip address of this entry.
+ * @param unknown1 Unknown1.
+ * @param hostname The host name of this entry.
+ * @param playerCount The number of currently logged in players.
+ * @param version The version string of this entry's server.
+ * @param description The description of this entry.
+ * @param unknown2 Unknown2.
+ * @param unknown3 Unknown3.
+ * @param unknown4 Unknown4.
+ */
+ public MetaServerEntry(final String ipaddress, final String unknown1, final String hostname, final int playerCount, final String version, final String description, final String unknown2, final String unknown3, final String unknown4) {
+ this.ipaddress = ipaddress;
+ this.unknown1 = unknown1;
+ this.hostname = hostname;
+ this.playerCount = playerCount;
+ this.version = version;
+ this.description = description;
+ this.unknown2 = unknown2;
+ this.unknown3 = unknown3;
+ this.unknown4 = unknown4;
+ }
+
+ /** Creates a MetaServerEntry by parsing a single entry String as returned by the metaserer.
+ * @param entryString String of the metaserver entry.
+ * @return MetaServerEntry created by parsing <var>entryString</var>.
+ */
+ @NotNull public static MetaServerEntry parse(@NotNull final String entryString) {
+ final Matcher matcher = entryPattern.matcher(entryString);
+ if (matcher.matches()) {
+ return new MetaServerEntry(
+ matcher.group(1),
+ matcher.group(2),
+ matcher.group(3),
+ Integer.parseInt(matcher.group(4)),
+ matcher.group(5),
+ matcher.group(6),
+ matcher.group(7),
+ matcher.group(8),
+ matcher.group(9)
+ );
+ }
+ throw new IllegalArgumentException("supplied String is not a MetaServer string.");
+ }
+
+ /** Returns the ip address of this entry.
+ * @return The ip address of this entry.
+ */
+ @NotNull public String getIpaddress() {
+ return ipaddress;
+ }
+
+ /** Returns the Unkown1.
+ * @return The Unknown1.
+ */
+ @NotNull public String getUnknown1() {
+ return unknown1;
+ }
+
+ /** Returns the host name of this entry.
+ * @return The host name of this entry.
+ */
+ @NotNull public String getHostname() {
+ return hostname;
+ }
+
+ /** Returns the number of currently logged in players.
+ * @return The number of currently logged in players.
+ */
+ public int getPlayerCount() {
+ return playerCount;
+ }
+
+ /** Returns the version string of this entry's server.
+ * @return The version string of this entry's server.
+ */
+ @NotNull public String getVersion() {
+ return version;
+ }
+
+ /** Returns the description of this entry.
+ * @return The description of this entry.
+ */
+ @NotNull public String getDescription() {
+ return description;
+ }
+
+ /** Returns the Unkown2.
+ * @return The Unknown2.
+ */
+ @NotNull public String getUnknown2() {
+ return unknown2;
+ }
+
+ /** Returns the Unkown3.
+ * @return The Unknown3.
+ */
+ @NotNull public String getUnknown3() {
+ return unknown3;
+ }
+
+ /** Returns the Unkown4.
+ * @return The Unknown4.
+ */
+ @NotNull public String getUnknown4() {
+ return unknown4;
+ }
+
+ /** {@inheritDoc} */
+ @NotNull public String toString() {
+ return hostname + " (" + version + ") " + playerCount + " players. (" + description + ")";
+ }
+
+} // class MetaServerEntry
Property changes on: trunk/src/net/sf/cherbot/metaserver/MetaServerEntry.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java
===================================================================
--- trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java (rev 0)
+++ trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java 2007-06-09 17:14:35 UTC (rev 51)
@@ -0,0 +1,139 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package net.sf.cherbot.metaserver;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+import java.net.Socket;
+import org.jetbrains.annotations.NotNull;
+import net.sf.cherbot.Updatable;
+import net.sf.japi.io.args.BasicCommand;
+import net.sf.japi.io.args.Option;
+
+/** Represents the information stored in a MetaServer.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class MetaServerInfo extends BasicCommand implements Iterable<MetaServerEntry>, Updatable {
+
+ /** The entries of this MetaServerInfo. */
+ @NotNull private List<MetaServerEntry> metaServerEntries = new ArrayList<MetaServerEntry>();
+
+ /** The address (ip address or hostname) of the meta server to query. */
+ @NotNull private String host;
+
+ /** The port of the meta server to query. */
+ private int port;
+
+ /** Creates a MetaServerInfo.
+ * This constructor creates a dummy meta server with no functional host and port.
+ * It cannot be used for querying and exists for testing purposes only.
+ */
+ public MetaServerInfo() {
+ this("dummy", 0);
+ }
+
+ /** Creates a MetaServerInfo.
+ * The MetaServerInfo is initially empty.
+ * Invoke the query() method to update information.
+ * @param host address (ip address or hostname) of the meta server to query.
+ * @param port port of the meta server to query
+ */
+ public MetaServerInfo(@NotNull final String host, final int port) {
+ this.host = host;
+ this.port = port;
+ }
+
+ /** Parse meta server information from the specified BufferedReader.
+ * @param in BufferedReader to parse information from.
+ * @throws IOException In case of I/O problems while reading from <var>in</var>.
+ */
+ public void parse(final BufferedReader in) throws IOException {
+ final List<MetaServerEntry> metaServerEntries = new ArrayList<MetaServerEntry>();
+ for (String line; (line = in.readLine()) != null;) {
+ metaServerEntries.add(MetaServerEntry.parse(line));
+ }
+ this.metaServerEntries = metaServerEntries;
+ }
+
+ /** Returns the MetaServerEntry with the specified index.
+ * @param index Index of the MetaServerEntry to return.
+ * @return MetaServerEntry with the specified index.
+ */
+ public MetaServerEntry get(final int index) {
+ return metaServerEntries.get(index);
+ }
+
+ /** Returns the number of MetaServerEntries for this MetaServerInfo.
+ * @return Number of MetaServerEntries.
+ */
+ public int size() {
+ return metaServerEntries.size();
+ }
+
+ /** {@inheritDoc} */
+ @NotNull public Iterator<MetaServerEntry> iterator() {
+ return metaServerEntries.iterator();
+ }
+
+ /** Sets the host of the meta server to query.
+ * @param host The host of the meta server to query.
+ */
+ @Option({"h", "host"})
+ public void setHost(@NotNull final String host) {
+ this.host = host;
+ }
+
+ /** Sets the port of the meta server to query.
+ * @param port The port of the meta server to query.
+ */
+ @Option({"p", "port"})
+ public void setPort(final int port) {
+ this.port = port;
+ }
+
+ /** Returns the host of the meta server to query.
+ * @return The host of the meta server to query.
+ */
+ @NotNull public String getHost() {
+ return host;
+ }
+
+ /** Returns the port of the meta server to query.
+ * @return The port of the meta server to query.
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /** {@inheritDoc} */
+ public void update() throws Exception {
+ final Socket s = new Socket(host, port);
+ try {
+ final BufferedReader in = new BufferedReader(new InputStreamReader(s.getInputStream()));
+ parse(in);
+ } finally {
+ s.close();
+ }
+ }
+
+ /** {@inheritDoc} */
+ public int run(@NotNull final List<String> args) throws Exception {
+ if (args.size() > 0) {
+ throw new Exception("Wrong usage. Try --help.");
+ }
+ update();
+ for (final MetaServerEntry entry : this) {
+ System.out.println(entry);
+ }
+ return 0;
+ }
+
+} // class MetaServerInfo
Property changes on: trunk/src/net/sf/cherbot/metaserver/MetaServerInfo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/test/net/sf/cherbot/metaserver/MetaServerEntryTest.java
===================================================================
--- trunk/src/test/net/sf/cherbot/metaserver/MetaServerEntryTest.java (rev 0)
+++ trunk/src/test/net/sf/cherbot/metaserver/MetaServerEntryTest.java 2007-06-09 17:14:35 UTC (rev 51)
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package test.net.sf.cherbot.metaserver;
+
+import org.junit.Test;
+import org.junit.Assert;
+import net.sf.cherbot.metaserver.MetaServerEntry;
+
+/** Unit-Test for {@link MetaServerEntry}.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class MetaServerEntryTest {
+
+ /** Tests the constructor {@link net.sf.cherbot.metaserver.MetaServerEntry#MetaServerEntry(String, String, String, int, String, String, String, String, String)} and all related getters. */
+ @Test public void testMetaServerEntry() {
+ final MetaServerEntry testling = new MetaServerEntry("192.168.0.1", "177", "localhost", 20, "0.9.7", "My own Daimonin server.", "02", "03", "04");
+ Assert.assertEquals("ipaddress must be stored.", "192.168.0.1", testling.getIpaddress());
+ Assert.assertEquals("unknown1 must be stored.", "177", testling.getUnknown1());
+ Assert.assertEquals("hostname must be stored.", "localhost", testling.getHostname());
+ Assert.assertEquals("playercount must be stored.", 20, testling.getPlayerCount());
+ Assert.assertEquals("version must be stored.", "0.9.7", testling.getVersion());
+ Assert.assertEquals("description must be stored.", "My own Daimonin server.", testling.getDescription());
+ Assert.assertEquals("unknown2 must be stored.", "02", testling.getUnknown2());
+ Assert.assertEquals("unknown3 must be stored.", "03", testling.getUnknown3());
+ Assert.assertEquals("unknown4 must be stored.", "04", testling.getUnknown4());
+ }
+
+ /** Tests the method {@link MetaServerEntry#parse(String)}. */
+ @Test public void testParse() {
+ final MetaServerEntry testling = MetaServerEntry.parse("192.168.0.1|177|localhost|20|0.9.7|My own Daimonin server.|02|03|04");
+ Assert.assertEquals("ipaddress must be stored.", "192.168.0.1", testling.getIpaddress());
+ Assert.assertEquals("unknown1 must be stored.", "177", testling.getUnknown1());
+ Assert.assertEquals("hostname must be stored.", "localhost", testling.getHostname());
+ Assert.assertEquals("playercount must be stored.", 20, testling.getPlayerCount());
+ Assert.assertEquals("version must be stored.", "0.9.7", testling.getVersion());
+ Assert.assertEquals("description must be stored.", "My own Daimonin server.", testling.getDescription());
+ Assert.assertEquals("unknown2 must be stored.", "02", testling.getUnknown2());
+ Assert.assertEquals("unknown3 must be stored.", "03", testling.getUnknown3());
+ Assert.assertEquals("unknown4 must be stored.", "04", testling.getUnknown4());
+ }
+
+} // class MetaServerEntryTest
Property changes on: trunk/src/test/net/sf/cherbot/metaserver/MetaServerEntryTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
Added: trunk/src/test/net/sf/cherbot/metaserver/MetaServerInfoTest.java
===================================================================
--- trunk/src/test/net/sf/cherbot/metaserver/MetaServerInfoTest.java (rev 0)
+++ trunk/src/test/net/sf/cherbot/metaserver/MetaServerInfoTest.java 2007-06-09 17:14:35 UTC (rev 51)
@@ -0,0 +1,76 @@
+/*
+ * Copyright © 2007, Christian Hujer and the CherBot developers. All Rights Reserved.
+ * License: GNU General Public License v2.0 or newer.
+ * See file COPYING in the root directory of this project.
+ */
+
+package test.net.sf.cherbot.metaserver;
+
+import net.sf.cherbot.metaserver.MetaServerInfo;
+import org.junit.Test;
+import org.junit.Assert;
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.StringReader;
+
+/** Unit-Test for {@link MetaServerInfo}.
+ * @author <a href="mailto:ch...@ri...">Christian Hujer</a>
+ */
+public class MetaServerInfoTest {
+
+ /** Tests whether the constructor {@link net.sf.cherbot.metaserver.MetaServerInfo#MetaServerInfo(String, int)} and the corresponding getters work. */
+ @Test public void testMetaServerInfo() {
+ final MetaServerInfo testling = new MetaServerInfo("localhost", 1234);
+ Assert.assertEquals("host must be stored.", "localhost", testling.getHost());
+ Assert.assertEquals("port must be stored.", 1234, testling.getPort());
+ }
+
+ /** Tests whether parsing from a BufferedReader works.
+ * @throws IOException in case of I/O problems (unexpected).
+ */
+ @Test public void testParse() throws IOException {
+ final String metaServerString = "192.168.0.1|177|riedquat|20|0.9.7|My own Daimonin server.|02|03|04\n" +
+ "192.168.0.2|177|lave|20|0.9.7|My other Daimonin server.|02|03|04\n";
+ final MetaServerInfo testling = new MetaServerInfo();
+ testling.parse(new BufferedReader(new StringReader(metaServerString)));
+ Assert.assertEquals("MetaServerInfo now must contain 2 entries.", 2, testling.size());
+ Assert.assertEquals("ip address of first entry must be 192.168.0.1.", "192.168.0.1", testling.get(0).getIpaddress());
+ Assert.assertEquals("ip address of second entry must be 192.168.0.2.", "192.168.0.2", testling.get(1).getIpaddress());
+ }
+
+ /** Tests whether parsing from a BufferedReader deletes previous entries.
+ * @throws IOException in case of I/O problems (unexpected).
+ */
+ @Test public void testParseDeletes() throws IOException {
+ final String metaServerString = "192.168.0.1|177|riedquat|20|0.9.7|My own Daimonin server.|02|03|04\n" +
+ "192.168.0.2|177|lave|20|0.9.7|My other Daimonin server.|02|03|04\n";
+ final MetaServerInfo testling = new MetaServerInfo();
+ testling.parse(new BufferedReader(new StringReader(metaServerString)));
+ Assert.assertEquals("MetaServerInfo now must contain 2 entries.", 2, testling.size());
+ testling.parse(new BufferedReader(new StringReader(metaServerString)));
+ Assert.assertEquals("Parsing a second time must delete previous entries, so size again is 2.", 2, testling.size());
+ }
+
+ /** Tests that {@link net.sf.cherbot.metaserver.MetaServerInfo#update()} doesn't violate the contract of {@link net.sf.cherbot.Updatable#update()}.
+ * @throws IOException in case of I/O problems (unexpected).
+ */
+ @Test public void testUpdate() throws IOException {
+ final String metaServerString = "192.168.0.1|177|riedquat|20|0.9.7|My own Daimonin server.|02|03|04\n" +
+ "192.168.0.2|177|lave|20|0.9.7|My other Daimonin server.|02|03|04\n";
+ final MetaServerInfo testling = new MetaServerInfo();
+ testling.parse(new BufferedReader(new StringReader(metaServerString)));
+ Assert.assertEquals("MetaServerInfo now must contain 2 entries.", 2, testling.size());
+ Assert.assertEquals("ip address of first entry must be 192.168.0.1.", "192.168.0.1", testling.get(0).getIpaddress());
+ Assert.assertEquals("ip address of second entry must be 192.168.0.2.", "192.168.0.2", testling.get(1).getIpaddress());
+ try {
+ testling.update();
+ Assert.fail("Exception expected but not thrown.");
+ } catch (final Exception ignore) {
+ // expected
+ }
+ // Verify that the failed update() didn't destroy information.
+ Assert.assertEquals("MetaServerInfo now still must contain 2 entries.", 2, testling.size());
+ Assert.assertEquals("ip address of first entry still must be 192.168.0.1.", "192.168.0.1", testling.get(0).getIpaddress());
+ Assert.assertEquals("ip address of second entry still must be 192.168.0.2.", "192.168.0.2", testling.get(1).getIpaddress());
+ }
+} // class MetaServerInfoTest
Property changes on: trunk/src/test/net/sf/cherbot/metaserver/MetaServerInfoTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ LF
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2007-06-09 14:42:06
|
Revision: 50
http://svn.sourceforge.net/cherbot/?rev=50&view=rev
Author: christianhujer
Date: 2007-06-09 07:42:01 -0700 (Sat, 09 Jun 2007)
Log Message:
-----------
Added module libraries to IntelliJ IDEA module configuration.
Modified Paths:
--------------
trunk/cherbot.iml
Modified: trunk/cherbot.iml
===================================================================
--- trunk/cherbot.iml 2007-06-09 14:40:33 UTC (rev 49)
+++ trunk/cherbot.iml 2007-06-09 14:42:01 UTC (rev 50)
@@ -12,6 +12,33 @@
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="junit-4.1" level="project" />
<orderEntry type="library" name="annotations" level="project" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/lib/junit-4.1.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/lib/annotations.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="jar://$MODULE_DIR$/lib/japi-lib-argparser-0.1.jar!/" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
<component name="copyright">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|