Esempio n. 1
0
 @Override
 public void onJoin(JoinEvent event) {
   if (Config.LOGGED_CHANS.contains(event.getChannel().getName())) {
     log(
         event.getChannel().getName(),
         String.format(
             "%s %s (%s) has joined %s",
             Utils.getTime(),
             event.getUser().getNick(),
             event.getUser().getLogin() + "@" + event.getUser().getHostmask(),
             event.getChannel().getName()));
   }
   if (Bot.relay.containsKey(event.getChannel().getName().toLowerCase())) {
     event
         .getBot()
         .sendMessage(
             Bot.relay.get(event.getChannel().getName().toLowerCase()),
             String.format(
                 "[%s] %s (%s) has joined %s",
                 event.getChannel().getName(),
                 event.getUser().getNick(),
                 event.getUser().getLogin() + "@" + event.getUser().getHostmask(),
                 event.getChannel().getName()));
   }
 }
Esempio n. 2
0
 @Override
 public void onJoin(JoinEvent event) {
   String relay =
       String.format(
           "[IRMC] %s has joined %s", event.getUser().getNick(), event.getChannel().getName());
   plugin.relayToServer(relay);
 }
 /**
  * Returns if the nick is a new visitor to the channel
  *
  * @param event join event
  * @return true if new nick
  * @throws Exception
  */
 private boolean isExistingUser(JoinEvent event) {
   List<String> knownUsers;
   try {
     knownUsers = getUserList();
   } catch (Exception e) {
     logger.error("Unable to load userlist. " + e.getMessage());
     return false;
   }
   boolean existingUser = false;
   String username = event.getUser().getNick();
   for (String u : knownUsers) {
     if (event.getUser().getNick().equalsIgnoreCase(u)) {
       logger.info("Known nick: " + username);
       existingUser = true;
     }
   }
   // New nick
   if (existingUser == false) {
     logger.info("New nick: " + username);
     addKnownUser(username);
   }
   return existingUser;
 }
 // User Join event
 @Override
 public void onJoin(JoinEvent event) {
   logger.info(event.getUser().getNick() + " joined the channel.");
   // If not an existing nick, welcomes new nick.
   if (!isExistingUser(event)) {
     // TODO: get reply from configuration file
     event.respond(
         "Welcome to "
             + event.getChannel().getName().toString()
             + " This "
             + "is a new channel, and we're still trying to gain "
             + "users. If you have a question, feel free to ask, "
             + "and be sure to come back soon!");
   }
 }