IRC Bot in Processing or integrated platform

edited February 2017 in Library Questions

I need to create an IRC bot that will listen on a channel for certain words and send actions to Processing. I have tried to adapt a Java IRC library to processing but I am fairly noobish at programming, and I found it to be really difficult. Right now I am using the Pircbot library. Here is my code adapted from the sample:

    import org.jibble.pircbot.*;

    class MyBot extends PircBot {

        MyBot() {
            this.setName("MyBot");
        }


    }




    void setup()
    {
        size(800,600);

         // Now start our bot up.
        MyBot bot = new MyBot();

        // Enable debugging output.
        bot.setVerbose(true);

        // Connect to the IRC server.
        bot.connect("irc.freenode.net");

        // Join the #pircbot channel.
        bot.joinChannel("#pircbot");
    }

    void draw()
    {

    }

when I try to run it I get an Unhandled Exception Type IOException. I really have no idea how to troubleshoot this. If I can get this working that would be ideal.

However, if it would be easier to use an external system and integrate into Processing then that would work too.

Can I get some pointers on how to make this code work, or something else?

Answers

  • Hey, I know it's been 2 years so you will maybe not answer. But I have exactly the same problem. Maybe now someone will know the answer.

    There is a Twitch channel, Marble Racing. Which is basically colorfull marble racing downhill. But each marble is created by a viewer, when he types !marble in the twitch chat it creates a new marble in the game. I have plan to create this kind of gameplay, but I'm completely stuck.

  • @Praetorian You get exactly this-

    Unhandled Exception Type IOException

    ?

  • Yes I get it on the bot.connect call. I have the exact same code as this man.

  • edited February 2017 Answer ✓

    The this should be enough.
    Replace line 26 (the bot.connect call) with this-

    try{
      bot.connect("irc.freenode.net");
    }catch(Exception e){
      e.printStackTrace();
      System.exit(-1);
    }  
    

    Read about Exception Handling in Java for more information.

  • edited February 2017

    It's not really an error here. It's just a way of the compiler telling you that you're not handling an exception that you should be. Runtime exceptions need not be explicitly stated or handled, unlike this Exception. That's probably why you've never noticed this type of error before. But chances are, you'll have seen some Runtime exception like ArrayIndexOutOfBoundsException or NullPointerException.

  • Oh ok I understand, and now it's working. I can see my bot sending a message. Thank you very much!

Sign In or Register to comment.