Jump to content

Connecting to irc using PircBotX


mylo

Recommended Posts

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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