Ejemplo n.º 1
0
 private void processMessage(
     final String channel,
     final String message,
     final String sender,
     final String login,
     final String hostname) {
   try {
     logsDao.logMessage(Logs.Type.MESSAGE, sender, channel, message);
     if (isValidSender(sender)) {
       List<Message> responses = new ArrayList<Message>();
       for (final String startString : startStrings) {
         if (responses != null && message.startsWith(startString)) {
           String content = message.substring(startString.length()).trim();
           while (content.charAt(0) == ':' || content.charAt(0) == ',') {
             content = content.substring(1).trim();
           }
           responses.addAll(getResponses(channel, sender, login, hostname, content));
         }
       }
       if (responses.isEmpty()) {
         responses.addAll(getChannelResponses(channel, sender, login, hostname, message));
       }
       for (Message response : responses) {
         response.send(this);
       }
     } else {
       if (log.isInfoEnabled()) {
         log.info("ignoring " + sender);
       }
     }
   } catch (Exception e) {
     log.error(e.getMessage(), e);
     throw new RuntimeException(e.getMessage());
   }
 }
Ejemplo n.º 2
0
 @Override
 public void onJoin(
     final String channel, final String sender, final String login, final String hostname) {
   if (channelDao.get(channel).getLogged()) {
     logsDao.logMessage(Logs.Type.JOIN, sender, channel, ":" + hostname + " joined the channel");
   }
 }
Ejemplo n.º 3
0
 @Override
 public void onPart(
     final String channel, final String sender, final String login, final String hostname) {
   final Channel chan = channelDao.get(channel);
   if (chan != null && chan.getLogged()) {
     logsDao.logMessage(Logs.Type.PART, sender, channel, "parted the channel");
   }
 }
Ejemplo n.º 4
0
 @Override
 public void onQuit(
     final String channel, final String sender, final String login, final String hostname) {
   final Channel chan = channelDao.get(channel);
   if (chan != null && chan.getLogged()) {
     logsDao.logMessage(Logs.Type.QUIT, sender, channel, "quit");
   } else if (chan == null) {
     log.debug("not logging " + channel);
   }
 }
Ejemplo n.º 5
0
 protected final void logMessage(final Message message) {
   final BotEvent event = message.getEvent();
   final String sender = getNick();
   final String channel = event.getChannel();
   if (!channel.equals(sender)) {
     if (channelDao.isLogged(channel)) {
       logsDao.logMessage(
           Logs.Type.MESSAGE, sender, message.getDestination(), message.getMessage());
     }
   }
 }
Ejemplo n.º 6
0
 @Override
 public void onKick(
     final String channel,
     final String kickerNick,
     final String kickerLogin,
     final String kickerHostname,
     final String recipientNick,
     final String reason) {
   if (channelDao.get(channel).getLogged()) {
     logsDao.logMessage(
         Logs.Type.KICK, kickerNick, channel, " kicked " + recipientNick + " (" + reason + ")");
   }
 }
Ejemplo n.º 7
0
 @Override
 public void onAction(
     final String sender,
     final String login,
     final String hostname,
     final String target,
     final String action) {
   if (log.isDebugEnabled()) {
     log.debug("Sender " + sender + " Message " + action);
   }
   if (channelDao.get(target).getLogged()) {
     logsDao.logMessage(Logs.Type.ACTION, sender, target, action);
   }
 }