Commit 2fbbded3 by Tuomas Riihimäki

IRC server password

1 parent 2b1d625b
...@@ -13,8 +13,9 @@ import org.slf4j.LoggerFactory; ...@@ -13,8 +13,9 @@ import org.slf4j.LoggerFactory;
public enum SystemProperty { public enum SystemProperty {
MOYA_IRC_SERVER, MOYA_IRC_SERVER,
MOYA_IRC_CHANNEL("#moya-debug") MOYA_IRC_CHANNEL("#moya-debug"),
MOYA_IRC_SERVERPASS(),
; ;
private final String defaultValue; private final String defaultValue;
...@@ -62,4 +63,10 @@ public enum SystemProperty { ...@@ -62,4 +63,10 @@ public enum SystemProperty {
} }
return intval; return intval;
} }
public String getValueOrNull() {
String val = System.getProperty(this.name());
return val;
}
} }
...@@ -100,7 +100,7 @@ public class IrcServlet extends HttpServlet { ...@@ -100,7 +100,7 @@ public class IrcServlet extends HttpServlet {
{ {
logger.info("Starting IRC client with server {}", ircserver); logger.info("Starting IRC client with server {}", ircserver);
IrcBot bot = new IrcBot(ircserver, SystemProperty.MOYA_IRC_CHANNEL.getValueOrDefault(), "moya-bot"); IrcBot bot = new IrcBot(ircserver, 6667, SystemProperty.MOYA_IRC_SERVERPASS.getValueOrNull() ,SystemProperty.MOYA_IRC_CHANNEL.getValueOrDefault(), "moya-bot");
botbean.add(bot); botbean.add(bot);
bots.add(bot); bots.add(bot);
bot.start(); bot.start();
...@@ -123,6 +123,11 @@ public class IrcServlet extends HttpServlet { ...@@ -123,6 +123,11 @@ public class IrcServlet extends HttpServlet {
*/ */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
for (IrcBot b : bots) { for (IrcBot b : bots) {
try {
b.stop();
} catch (Throwable t) {
logger.info("Error stopping bot", t);
}
b.start(); b.start();
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!