Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java IRC Bot

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java IRC Bot

    Alright, so I am detecting if there are arguments or not. The detecting if there are none works, but if there are it does nothing at all.

    Here is my code.
    package me.mretech.peacebot.commands;
     
    import org.pircbotx.PircBotX;
    import org.pircbotx.hooks.ListenerAdapter;
    import org.pircbotx.hooks.events.MessageEvent;
     
    public class JoinCommand extends ListenerAdapter<PircBotX> {
    	public void onMessage(MessageEvent<PircBotX> event) throws Exception {
    		String CommandPrefix = "!";
    		String message = event.getMessage().trim();
    		String[] args = message.split(" ");
     
    		if(event.getChannel().getName().equalsIgnoreCase("#peacebot")) {
    			if(message.startsWith(CommandPrefix)) {
    				if(message.substring(1).equalsIgnoreCase("peacebot join")) {
    					if(event.getChannel().isOp(event.getUser())) {
    						if(!(args.length == 3)) {
    							event.getBot().sendMessage(event.getChannel(), event.getUser().getNick() + " -> Correct Arguments: !peacebot join [channel]");
    						} else if(args.length == 3) {
    							event.getBot().sendMessage(event.getChannel(), event.getUser().getNick() + " -> I am Joining Channel: " + args[3]);
    						}
    					} else {
    						event.getBot().sendMessage(event.getChannel(), event.getUser().getNick() + " -> I am joining your channel.");
    					}
    				}
    			}
    		}
    	}
    }

    I would appreciate it if anyone could help me out with this, thanks =)

    mIRC Client


    Eclipse Console


  2. #2
    Junior Member
    Join Date
    Nov 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java IRC Bot

    Bump

Similar Threads

  1. Java IRC Bot
    By Mretech in forum Java Networking
    Replies: 3
    Last Post: November 28th, 2013, 08:55 PM
  2. IRC client
    By Brt93yoda in forum The Cafe
    Replies: 14
    Last Post: November 26th, 2010, 04:31 PM
  3. Pinball bot
    By Johannes in forum Project Collaboration
    Replies: 16
    Last Post: August 13th, 2009, 07:59 AM