Skip to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

More noob questions (this time, about message listeners!)

Featured Replies

Hey everyone! Thanks for being patient with me on my learning adventure.

I'm making a begger script that is basically an excuse to practice playing with the osbot API and get more comfortable. I have two scripts below, one which handles the main operation (BeggingScript.java) and one that handles trade (Trader.java). 

Everything is working wonderfully EXCEPT trade requests. I can't seem to get the API surrounding identifying trade requests to work. I have no problem accepting them once I identify the trade request in the chat, but I only got that working once accidently.

Any ideas on how to recognize trade requests or use the API in this way? 

Love you all,

 

Trader.java

import org.osbot.rs07.api.Trade;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.utility.ConditionalSleep;

public class Trader {
    private MethodProvider api;

    public Trader(MethodProvider api) {
        this.api = api;
    }

    // Detects if a trade has been initiated
    public boolean isInTrade() {
        boolean tradingStatus = api.getTrade().isCurrentlyTrading();
        api.log("Trade status detected: " + tradingStatus);
        return tradingStatus;
    }

    public void handleTrade() {
        Trade trade = api.getTrade();

        // Attempt to accept on first trade interface
        if (trade.isFirstInterfaceOpen()) {
            api.log("First trade interface detected; attempting to accept.");
            new ConditionalSleep(2000) {
                @Override
                public boolean condition() {
                    return trade.acceptTrade();
                }
            }.sleep();
            api.log("Accepted trade on first interface.");

            // Attempt to accept on second trade interface
        } else if (trade.isSecondInterfaceOpen()) {
            api.log("Second trade interface detected; attempting to accept.");
            new ConditionalSleep(2000) {
                @Override
                public boolean condition() {
                    return trade.acceptTrade();
                }
            }.sleep();
            api.log("Accepted trade on second interface.");

        } else {
            api.log("No trade interface detected; awaiting trade.");
        }
    }
}


BeggingScript.java

import org.osbot.rs07.api.Keyboard;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(name = "BeggingScript", author = "Assistant", version = 1.1, info = "Begging and trade handling script", logo = "")
public class BeggingScript extends Script {
    private Trader trader;
    private long lastMessageTime = 0;
    private static final int MESSAGE_INTERVAL = 6000; // 6 seconds between messages
    private String[] messages = {"Can anyone spare 5k?", "Can anyone spare some gp?"};

    @Override
    public void onStart() {
        trader = new Trader(this);
        log("BeggingScript started.");
    }

    @Override
    public int onLoop() throws InterruptedException {
        if (trader.isInTrade()) {
            log("In trade; pausing messages.");
            trader.handleTrade();
        } else {
            log("Not in trade; sending messages.");
            sendMessage();
        }
        return 1000;
    }

    private void sendMessage() {
        if (System.currentTimeMillis() - lastMessageTime > MESSAGE_INTERVAL) {
            int index = random(0, messages.length);
            String message = messages[index];
            getKeyboard().typeString(message);
            log("Sent message: " + message);
            lastMessageTime = System.currentTimeMillis();
        }
    }
}

 

  • 1 month later...

Never really checked out trading stuff, but u can get information from the chat and act upon it:
So if someone said 'hi' in chat, the bot will log 'sup', hook some methods to it and yey?

 @Override
   public final void onMessage(final Message message) {
   if (message == null) {
     return;
   }

   if (message.getMessage().toLowerCase().contains("hi")) {
     log("sup");
   }
 }

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.