Jump 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.

Reacting to messages in chatbox

Featured Replies

Hi, I want to basically stop my script if chatbox says: You don't have the runes to cast this spell.

 

Having some problems: trying to use chatbox.getMessages(), but keep getting errors in intellij, also just tried the normal message one but think something went wrong there:

 

Would someone be able to show me the correct snippet for detecting this?

 

Thanks

In your onStart() method:

this.getBot().addMessageListener(this);

Then you can use the messageListener:

public void onMessage(Message message) {
	String text = message.getMessage().toLowerCase();
	if (text.contains("you don't have the runes")) {
		//They don't have the runes so do something
	}
}

 

Edited by DrizzyBot

just implement onMessage inside your script and it will check messages

make sure the message type == Game

2 hours ago, DrizzyBot said:

In your onStart() method:


this.getBot().addMessageListener(this);

 

You don't need to do that for messageListener.  It's already implemented from 'Script' :troll:

7 hours ago, DrizzyBot said:

In your onStart() method:


this.getBot().addMessageListener(this);

Then you can use the messageListener:


public void onMessage(Message message) {
	String text = message.getMessage().toLowerCase();
	if (text.contains("you don't have the runes")) {
		//They don't have the runes so do something
	}
}

 

Make sure to check if the message is from the game so people won't be able to log your accounts of by typing it in chatbox. 

He asked for a Chatbox API answer and literally every answer in here is not what he was asking for. Your IDE will tell you exactly what's wrong, please show a screenshot of the code you have.

15 minutes ago, Alek said:

He asked for a Chatbox API answer and literally every answer in here is not what he was asking for. Your IDE will tell you exactly what's wrong, please show a screenshot of the code you have.

That's probably because he doesn't know how to do it based on his other threads. His question is not based on having problems with Chatbox API but having problems with reading messages in general. 

  • Author
4 hours ago, The Undefeated said:

That's probably because he doesn't know how to do it based on his other threads. His question is not based on having problems with Chatbox API but having problems with reading messages in general. 

Yeah, i don't know how to do it :').

This is my current setup had deleted previous attempts but pretty sure they were worse :'). Current problems are the m is unable to be resolved and the = Message.MessageType(GAME) is incorrect

 public void onMessage(Message m){
    if (m.getType() == Message.MessageType(GAME)) {

        String text = m.getMessage().toLowerCase();
        if (text.contains("rune")) {
            stop();
        }
        if(text.contains("arrow")){
            stop();
        }
    }
}
5 minutes ago, scriptersteve said:

Yeah, i don't know how to do it :').

This is my current setup had deleted previous attempts but pretty sure they were worse :'). Current problems are the m is unable to be resolved and the = Message.MessageType(GAME) is incorrect. Now it's just the Message.MessageType(GAME) that's wrong, fixed the other issue as i had a bracket messed up elsewhere


 public void onMessage(Message m){
    if (m.getType() == Message.MessageType(GAME)) {

        String text = m.getMessage().toLowerCase();
        if (text.contains("rune")) {
            stop();
        }
        if(text.contains("arrow")){
            stop();
        }
    }
}

 

  • Author

Hold up got this now and no errors so going to test it:  

public void onMessage(Message m){
    if (m.getType() == GAME) {

        String text = m.getMessage().toLowerCase();
        if (text.contains("rune")) {
            stop();
        }
        if(text.contains("arrow")){
            stop();
        }

    }


}

It's possible you're getting a null string. 

Also, text.contains() may fail you later in the future for more general words.

text.equals("zz") is better for more exact phrases. You might run into messages that contain other elements other then just the phrase. I believe there is something in the API that could help you out. If you can't find it, there are easy work arounds that you should figure out.

 

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

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.