2

I'm trying to make a bot for my twitch chat but i'm having some problems to connect to the chat with it. I read a bit about the library at: http://www.jibble.org/pircbot.php And tried to connect to my own chat but i'm getting an error.

1462989951913 *** Connected to server.
1462989951915 >>>PASS oauth:cencoring oath.
1462989951915 >>>NICK FredsBot
1462989951915 >>>USER FredsBot 8 * :PircBot 1.5.0 Java IRC Bot - www.jibble.org
1462989952324 :tmi.twitch.tv NOTICE * :Error logging in
1462989962324 *** Logged onto server.
Connected!
1462989962324 >>>JOIN #mychannel
1462989962324 *** Disconnected.

As you can see i'm getting an error while trying to login, but it does print out the connected message and after it disconnects. So far i've tried different oath keys without any luck. Have anyone stumble across this problem? Heres my code:

import org.jibble.pircbot.*;

public class MyBot extends PircBot {

    private static final String channelName = "#mychannel";
    private final String botName = "FredsBot";

    public MyBot() {
        this.setName(botName);
        this.setLogin(botName);

    }

    public String getchannelName() {
        return channelName;
    }

    @Override
    public void onMessage(String channel, String sender,
            String login, String hostname, String message) {
        if (message.equalsIgnoreCase("time")) {
            String time = new java.util.Date().toString();
            sendMessage(channel, sender + ": The time is now " + time);
        }
    }

    @Override
    protected void onConnect() {
        System.out.println("Connected!");
        joinChannel(channelName);


        super.onConnect();
        sendMessage(getchannelName(), "Hello, i am a bot");



       }

My main looks like this

    private static final String OAUTH = "myoath";
    private static final String ADRESS = "irc.chat.twitch.tv.";
    private static final int PORT = 6667;

    public static void main(String[] args) {

        MyBot bot = new MyBot();

        bot.setVerbose(true);

        try {

            bot.connect(ADRESS, PORT, OAUTH);
            //  bot.onMessage(channelName, "Bot", channelName, channelName, channelName);
        } catch (IOException ex) {
            Logger.getLogger(MainFile.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IrcException ex) {
            Logger.getLogger(MainFile.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

i've just cencored my oath and channel name so dont mind that. I did read up on similar post but most of them were solved just but getting a new oath key and it did not help me.

user3611818
  • 247
  • 2
  • 3
  • 13

1 Answers1

1

So i found out what the problem was. I had no idea that i needed to create an account for the bot with the exact name which i had declared in my code. Silly mistake.

user3611818
  • 247
  • 2
  • 3
  • 13