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
  public void onTrigger(
      String channel,
      String sender,
      String login,
      String hostname,
      String message,
      String trigger) {
    String toNick = null;
    String msg = null;
    try {
      toNick = message.substring(0, message.indexOf(' '));
      msg = message.substring(message.indexOf(' '));
    } catch (IndexOutOfBoundsException ioobe) {
      bot.msg(channel, "Bogus message format: try !" + TRIGGER + " <nick> <message>.");
      return;
    }

    for (User user : bot.getUsers(channel)) {
      if (user.equals(toNick)) {
        bot.msg(channel, toNick + " is here right now, you dumbass!");
        return;
      }
    }
    saveTell(channel, sender, toNick, msg);
  }
Exemple #3
0
 public void onNickChange(String oldNick, String login, String hostname, String newNick) {
   for (String chan : bot.getChannels()) {
     for (User user : bot.getUsers(chan)) {
       if (user.equals(newNick)) {
         tell(chan, newNick);
       }
     }
   }
 }
Exemple #4
0
  public boolean userIsOnChannel(final String nick, final String channel) {

    for (final User user : getUsers(channel)) {
      if (user.getNick().toLowerCase().equals(nick.toLowerCase())) {
        return true;
      }
    }
    return false;
  }
 /**
  * Is the sender respected in the channel?
  *
  * IOW, does he have a voice of a channel operator?
  */
 private boolean isSenderAuthorized(String channel, String sender) {
     for (User u : getUsers(channel)) {
         System.out.println(u.getPrefix()+u.getNick());
         if (u.getNick().equals(sender)) {
             String p = u.getPrefix();
             if (p.contains("@") || p.contains("+"))
                 return true;
         }
     }
     return false;
 }
 @Override
 protected void onUserList(String channel, User[] users) {
   for (User u : getUsers(channel)) {
     if (u.isOp()) {
       String nick = u.getNick();
       if (!ops.contains(nick)) {
         ops.add(nick);
       }
     }
   }
 }
 public void handleLoss(String nick) {
   for (String s : channels) {
     for (User u : getUsers(s)) {
       if (u.getNick().equals(nick)) {
         return;
       }
     }
   }
   Group removedGroup = Group.getGroup(nick);
   if (removedGroup != null) {
     groups.remove(removedGroup);
   }
 }
Exemple #8
0
  public User playerMatchIRC(String name) {
    if (getServer().getOnlinePlayers().length < 1) {
      return null;
    }

    for (User user : getIrcBot().getUsers("#hardwork")) {
      if (user.getNick().equalsIgnoreCase(name)) {
        return user;
      }
    }

    return null;
  }
Exemple #9
0
 public boolean isVoice(String sender, String channel) {
   User users[] = getUsers(channel);
   User u = null;
   for (User usa : users) {
     if (sender.equals(usa.getNick())) {
       u = usa;
       break;
     }
   }
   if (u.hasVoice()) {
     return true;
   } else {
     return false;
   }
 }
  /**
   * Get all channels where the user with the given nickname is online
   *
   * @param nickname
   * @return Array of channel names
   */
  private Vector<String> getChannelsByNickname(String nickname) {
    Vector<String> channels = new Vector<String>();
    String[] channelArray = getChannels();

    for (String channel : channelArray) {
      User[] userArray = getUsers(channel);
      for (User user : userArray) {
        if (user.getNick().equals(nickname)) {
          channels.add(channel);
          break;
        }
      }
    }

    return channels;
  }
Exemple #11
0
  public boolean isOp(String sender, String channel) {
    User users[] = getUsers(channel);
    User u = null;
    for (User user : users) {
      String us = user.getNick().replace("~", "");
      System.out.println("user: "******"~")) {
      return true;
    } else {
      return false;
    }
  }