Commit 58fb249b by Tuomas Riihimäki

irc bot restarting

1 parent a83af5a4
......@@ -76,7 +76,7 @@
<dependency>
<groupId>fi.iudex</groupId>
<artifactId>utils-standalone</artifactId>
<version>1.0.10</version>
<version>1.0.11</version>
</dependency>
<dependency>
<groupId>net.sf.barcode4j</groupId>
......
......@@ -49,6 +49,8 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.jerklib.Profile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -94,13 +96,17 @@ public class IrcServlet extends HttpServlet {
*/
public void init(ServletConfig config) throws ServletException {
startBot();
}
private void startBot() {
String ircserver = SystemProperty.MOYA_IRC_SERVER.getValueOrDefault();
logger.info("Got irc server system property {}", ircserver);
if (ircserver != null)
{
logger.info("Starting IRC client with server {}", ircserver);
IrcBot bot = new IrcBot(ircserver, 6667, SystemProperty.MOYA_IRC_SERVERPASS.getValueOrNull() ,SystemProperty.MOYA_IRC_CHANNEL.getValueOrDefault(), "moya-bot");
IrcBot bot = new IrcBot(ircserver, 6667, SystemProperty.MOYA_IRC_SERVERPASS.getValueOrNull(), SystemProperty.MOYA_IRC_CHANNEL.getValueOrDefault(), new Profile("moyabot", "Moya bot", "moya-bot"));
botbean.add(bot);
bots.add(bot);
bot.start();
......@@ -125,17 +131,15 @@ public class IrcServlet extends HttpServlet {
for (IrcBot b : bots) {
try {
b.stop();
} catch (Throwable t) {
logger.info("Error stopping bot", t);
}
b.start();
}
bots.clear();
startBot();
// String msg = request.getParameter("msg");
// if (msg != null && !msg.isEmpty())
// for (IrcBot b : bots) {
// b.say(msg);
// }
}
/**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!