Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7949667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:03:18+00:00 2026-06-04T02:03:18+00:00

I am trying to create an IRC Bot, below is the code, however, when

  • 0

I am trying to create an IRC Bot, below is the code, however, when it runs, it will not detect “001” whatever I try, I’m running it on JRE6 and using JDK6. I’m developing it with Eclipse and using the debug feature to run it. I’ve tried with both “java.exe” and “javaw.exe”. When running, debugex shows 001 is clearly there.

Here is my code:

package bot;
import java.io.*;
import java.net.*;
public class Main {
    static PrintWriter out = null;
    @SuppressWarnings("unused")
    public static void main(String[] args) {
        Socket sock = null;
        BufferedReader in = null;
        try {
            sock = new Socket("irc.jermc.co.cc",6667);
            in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
            out = new PrintWriter(sock.getOutputStream(), true);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        boolean sentconnect = false;
        while(sock.isConnected() == true){
            if(sentconnect == false){
                writeout("NICK GBot");
                writeout("USER GBot GBot GBot :GBot");
                sentconnect = true;
            }
            String data = "";
            try {
                data = in.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            data = data.trim();
            if(data != ""){
                System.out.println("[IN] " + data);
            }
            String[] ex;
            ex = data.split(" ");
            for(String debugex : ex){
                //System.out.println("DEBUGEX: " + debugex);
            }
            if(ex[1] == "001"){
                writeout("JOIN #minecraft");
            }
            try {
                Thread.sleep((long) 0.5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if(ex[0] == "PING"){
                writeout("PONG " + ex[1]);
            }
        }
    }

    private static void writeout(String msg) {
        out.println(msg);
        System.out.println("[OUT] " + msg);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T02:03:19+00:00Added an answer on June 4, 2026 at 2:03 am

    String equality must be tested using String.equals(), not ==.

    It should be:

            if(! data.isEmpty()){                     // rather than: data != ""
                System.out.println("[IN] " + data);
            }
            ...
            if(ex[1].equals("001")){                  // rather than: ex[1] == "001"
                writeout("JOIN #minecraft");
            }
            ...
            if(ex[0].equals("PING")){                 // rather than: ex[0] == "PING"
                writeout("PONG " + ex[1]);
            }
    

    See How do I compare strings in Java.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
Trying to create COM -object on server. code is: var myGuid = new Guid(530A1815-820C-11D3-BBB7-008048DE406A);
I'm having a bit of a problem. I am trying to create an IRC
I am trying create a search box which will search datatables. The search box
I'm trying create a query that will output a total number, as well as
I am trying create an application which will clone the GIT repository to the
I'm trying create a small http proxy service. This is not working so well.
I'm currently trying create a service that will return results of a OLAP cube
I am trying create alert dailog using glade,but its not working .am i doing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.