Support Forums
[Java] IRC Bot :/ - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Java Programming (https://www.supportforums.net/forumdisplay.php?fid=22)
+---- Thread: [Java] IRC Bot :/ (/showthread.php?tid=11589)

Pages: 1 2


[Java] IRC Bot :/ - wchar_t - 08-28-2010

Code:
import java.io.*;
import java.net.*;
import java.lang.Throwable.*;




public class Main {

    public static void main(String[] args) {
        // The server to connect to and our details.
        String server = "irc.afterworkchat.net";
        String nick = "Pcqbot";
        String login = "pcquaddy";
        String channel = "#bblabla";

    // Connect directly to the IRC server.
        try {
        Socket socket = new Socket(server, 6667);
        BufferedWriter writer = new BufferedWriter(
                new OutputStreamWriter(socket.getOutputStream( )));
        BufferedReader reader = new BufferedReader(
                new InputStreamReader(socket.getInputStream( )));

        // Log on to the server.
        writer.write("NICK " + nick + "\r\n");
        writer.write("USER " + login + " 8 * : heyho\r\n");
        writer.flush( );

        String line = null;
        while ((line = reader.readLine( )) != null) {
            if (line.indexOf("004") >= 0) {
                // We are now logged in.
                break;
            }
            else if

(line.indexOf("433") >= 0) {
                System.out.println("Nickname is already in use.");
                return;
            }
        }



        // Log on to the server.
        writer.write("NICK " + nick + "\r\n");
        writer.write("USER " + login + " 8 * : yoo\r\n");
        writer.flush( );

        //Join the channel.
        writer.write("JOIN " + channel + "\r\n");
        writer.write("PRIVMSG " + channel + " :yo guys \r\n");

        writer.flush( );

        while ((line = reader.readLine( )) != null) {
            if (line.toLowerCase( ).startsWith("PING "))       {

                writer.write("PONG " + line.substring(5) + "\r\n");
                writer.flush( );
                                 }
       String[] tmp = line.split(" :");
       System.out.println(tmp[0] + "::" + tmp[1]);
       if (tmp[1].length() >= 5) {
       if (tmp[1].substring(0,6).equals(nick)) {
       if (tmp[1].length() >= 11 && tmp[1].substring(7, 11).equals("say ")) {
       String[] tmp2 = tmp[1].split("say ");
       System.out.println(tmp[1] + "::" + tmp2[1]);
       writer.write("PRIVMSG " + channel + " :" + tmp2[1] + "\r\n");
       writer.flush();
       }}}

       String[] tmp1 = line.split(" :");
       System.out.println(tmp1[0] + "::" + tmp1[1]);
       if (tmp1[1].length() >= 5) {
       if (tmp1[1].substring(0,6).equals(nick)) {
       if (tmp1[1].length() >= 12 && tmp1[1].substring(7, 12).equals("join ")) {
       String[] tmp12 = tmp1[1].split("join ");
       System.out.println(tmp1[1] + "::" + tmp12[1]);
       writer.write("JOIN " + " :" + tmp12[1] + "\r\n");
       writer.flush();
       }}}

       String[] tmp11 = line.split(" :");
       System.out.println(tmp11[0] + "::" + tmp11[1]);
       if (tmp11[1].length() >= 5) {
       if (tmp11[1].substring(0,6).equals(nick)) {
       if (tmp11[1].length() >= 12 && tmp1[1].substring(7, 12).equals("part ")) {
       String[] tmp112 = tmp11[1].split("part ");
       System.out.println(tmp11[1] + "::" + tmp112[1]);
       writer.write("PART " + " :" + tmp112[1] + "\r\n");
       writer.flush();
       }}}




            String[] tmp3 = line.split(" :");
       System.out.println(tmp3[0] + "::" + tmp3[1]);
       if (tmp3[1].length() >= 5) {
       if (tmp3[1].substring(0,6).equals(nick)) {
       if (tmp3[1].length() >= 11 && tmp3[1].substring(7, 11).equals("topic ")) {
       String[] tmp2 = tmp3[1].split("topic ");
       System.out.println(tmp3[1] + "::" + tmp2[1]);
       writer.write("TOPIC " + channel + " :" + tmp2[1] + "\r\n");
       writer.flush();
       }}}

  

                                }
    }
    catch (Throwable e) {
             System.out.println(e);
                          }


                     }
            }

Found on pcquad's website Big Grin


RE: [Java] IRC Bot :/ - Starky - 08-29-2010

Nice code, thanks!


RE: [Java] IRC Bot :/ - wchar_t - 09-06-2010

(08-29-2010, 01:18 AM)Starky Wrote: Nice code, thanks!

indeed its a nice code :2

easyily modified into a great project.


RE: [Java] IRC Bot :/ - iraqkey - 09-07-2010

You're flamingworm V2? The epic coppy and paste leechbot.


RE: [Java] IRC Bot :/ - wchar_t - 09-08-2010

(09-07-2010, 12:11 PM)iraqkey Wrote: You're flamingworm V2? The epic coppy and paste leechbot.

of course not.

i give credits, always.


RE: [Java] IRC Bot :/ - iraqkey - 09-08-2010

(09-08-2010, 07:58 AM)Scammer Wrote: of course not.

i give credits, always.
still leeching.


RE: [Java] IRC Bot :/ - x04a - 09-08-2010

He gave credits, and is sharing a great code. Don't flame him, it isn't necessary or helpful.


RE: [Java] IRC Bot :/ - wchar_t - 09-09-2010

Quote:In computing and specifically on the Internet, a leech or leecher is one who benefits, usually deliberately, from others' information or effort but does not offer anything in return, or makes only token offerings in an attempt to avoid being called a leech. In economics this type of behavior is called "free riding" and is associated with the free rider problem.

I gave original coder credits. gtfo.


RE: [Java] IRC Bot :/ - `P R O D I G Y™ - 09-15-2010

Is it outdated, and is it stable or?


RE: [Java] IRC Bot :/ - Solitary - 09-17-2010

wow great code man. thanks for the share.