Jump to content

Connecting to irc using PircBotX


Recommended Posts

Posted (edited)
package com.bot.worldscouter;

import org.osbot.rs07.api.def.ItemDefinition;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;
import org.pircbotx.Configuration;
import org.pircbotx.Configuration.Builder;
import org.pircbotx.PircBotX;
import org.pircbotx.exception.IrcException;

import java.awt.*;
import java.io.IOException;
import java.util.*;
import java.util.List;

@ScriptManifest(
        name = "WorldScouter",
        author = "ShootMyFruit",
        version = 1.00,
        info = "",
        logo = ""
)

public class WorldScouter extends Script {

    Configuration config = (new Builder())
            .setName("MyExampleBot")
            .setAutoNickChange(true)
            .addAutoJoinChannel("#workworkwork")
            .buildForServer("irc.swiftirc.net");

    PircBotX swiftBot =  new PircBotX(config);;


    public void onStart() {
       log("hello");

        try {
            swiftBot.startBot();
        } catch (IOException var2) {
            log("a");
            var2.printStackTrace();
        } catch (IrcException var3) {
            log("b");
            var3.printStackTrace();
        }
        log("hello");

    }

    public void onExit() {
        log("thank you for using the scouter");
        swiftBot.close();
    }

    public int onLoop() {
        java.util.List<Player> playersList = players.getAll();
        java.util.List<String> capeList = new ArrayList();
        List<String> capeCount = new ArrayList();

        for(Player player : playersList){
            int[] equipment = player.getDefinition().getAppearance();
            if (equipment[1] - 512 > 0) {
                capeList.add(ItemDefinition.forId(equipment[1] - 512).getName());
            }
        }

        Set<String> printed = new HashSet();

        for(String s : capeList) {
            if (printed.add(s)) {
                capeCount.add(s + ": " + Collections.frequency(capeList, s));
            }
        }

        this.log(worlds.getCurrentWorld() + " " + capeCount);
        return 1000;
    }

    public void onPaint(Graphics2D g) {
    }

}

This is my current code it runs all the os bot logic but never connects to the irc channel. And from reading the PircBotx docs it looks like it should connect with what I've written. Any ideas?

Edited by mylo

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...