Exemple #1
0
  public void onMessage(
      String channel, String sender, String login, String hostname, String message) {
    if (message.matches("^(\\w+):.+") && !message.matches("(\\w+)://.+")) {
      String toNick = message.substring(0, message.indexOf(':'));
      String msg = message.substring(message.indexOf(':') + 1, message.length());

      List<SeenUser> seens = JWorm.get(SeenUser.class);
      boolean save = false;
      for (SeenUser s : seens) {
        if (s.getNicks().contains(toNick)) {
          save = true;
          break;
        }
      }

      for (User user : bot.getUsers(channel)) {
        if (user.equals(toNick)) {
          return;
        }
      }

      if (save) {
        saveTell(channel, sender, toNick, msg);
      }
    }
  }
Exemple #2
0
 private void tell(String channel, String toNick) {
   List<TellItem> items =
       JWorm.getWith(
           TellItem.class, "where `to`='" + toNick + "' and `channel`='" + channel + "'");
   for (TellItem item : items) {
     StringBuilder message = new StringBuilder();
     message
         .append(item.getTo())
         .append(": ")
         .append(item.getFrom())
         .append(" told me to tell you this: ")
         .append(item.getMessage());
     bot.msg(channel, message.toString());
     item.delete();
   }
 }