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.

Need help with reading message from chatbox and doing stuff if it contains something. debug my code please

Featured Replies

package doubling;
 
import java.awt.Graphics2D;
import java.lang.Thread.State;
import java.util.List;
 
import org.osbot.rs07.api.Chatbox;
import org.osbot.rs07.api.Chatbox.MessageType;
import org.osbot.rs07.script.API;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 
 
@ScriptManifest(name = "respond", author = "", version = 1.0, info = "", logo = "") 
public class doubling extends Script {
 
 
 
 
    @Override
    public void onStart() {
        log("started");
       
 
 
    }
    
    @Override
    public void onExit() {
        log("ended!");
 
 
    }
    
 
   
    public void onMessage(String m) throws InterruptedException{
 
   
    }
 
    @Override
    public int onLoop() throws InterruptedException {
    List<String> m =  chatbox.getMessages(MessageType.PLAYER);
if (m.contains("hey")){
       
    log("someone said it");
   
    String a = new String("somethinga");
    String b = new String("somethingb");
    String c = new String("somethingc");
    int r = random(1, 3);
    if(r%2 == 0){
    keyboard.typeString(a);
    log("said" + a);
    sleep(500);
   
   
    if(r == 1){
    keyboard.typeString(b);
    log("said" + b);
    sleep(400);
    }
   
 
    if(r == 3){
    keyboard.typeString©;
    log("said" + c);
    sleep(500);
    }
    }
   
   
        return 215; //The amount of time in milliseconds before the loop starts over
    }
 
 
    @Override
    public void onPaint(Graphics2D g) {
        //This is where you will put your code for paint(s)
 
 
 
 
    }
 
 
}

 

 

The message to be read from player in chatbox.

Edited by sarthycool

package doubling;
 
import java.awt.Graphics2D;
import java.lang.Thread.State;
import java.util.List;
 
import org.osbot.rs07.api.Chatbox;
import org.osbot.rs07.api.Chatbox.MessageType;
import org.osbot.rs07.script.API;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 
 
@ScriptManifest(name = "respond", author = "", version = 1.0, info = "", logo = "") 
public class doubling extends Script {
 
 
 
 
    @Override
    public void onStart() {
        log("started");
       
 
 
    }
    
    @Override
    public void onExit() {
        log("ended!");
 
 
    }
    
 
   
    public void onMessage(String m) throws InterruptedException{
 
   
    }
 
    @Override
    public int onLoop() throws InterruptedException {
    List<String> m =  chatbox.getMessages(MessageType.PLAYER);
if (m.contains("hey")){
       
    log("someone said it");
   
    String a = new String("somethinga");
    String b = new String("somethingb");
    String c = new String("somethingc");
    int r = random(1, 3);
    if(r%2 == 0){
    keyboard.typeString(a);
    log("said" + a);
    sleep(500);
   
   
    if(r == 1){
    keyboard.typeString(b);
    log("said" + b);
    sleep(400);
    }
   
 
    if(r == 3){
    keyboard.typeString©;
    log("said" + c);
    sleep(500);
    }
    }
   
   
        return 215; //The amount of time in milliseconds before the loop starts over
    }
 
 
    @Override
    public void onPaint(Graphics2D g) {
        //This is where you will put your code for paint(s)
 
 
 
 
    }
 
 
}

 

 

The message to be read from player in chatbox.

try using onMessage?

since chatboxGetMessages will get all the messages including old ones i think

and onMessage gets the new ones or somethng lol

You could work with onMessage 

public void onMessage(Message message) throws java.lang.InterruptedException{
		String Txt = message.getMessage().toLowerCase();
       if(Txt.contains("hey")) {
               log("HE said it");
        } 
	}
  • Author

 

You could work with onMessage 

public void onMessage(Message message) throws java.lang.InterruptedException{
		String Txt = message.getMessage().toLowerCase();
       if(Txt.contains("hey")) {
               log("HE said it");
        } 
	}

 

The whole code which is in onLoop() was in onMessage().

 

It did not work even then.

  • Author

onMessage should work, i use it with many scripts.

 

package doubling;

import java.awt.Graphics2D;

import java.lang.Thread.State;

import java.util.List;

import org.osbot.rs07.api.Chatbox;

import org.osbot.rs07.api.Chatbox.MessageType;

import org.osbot.rs07.script.API;

import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(name = "respond", author = "", version = 1.0, info = "", logo = "")

public class doubling extends Script {

@Override

public void onStart() {

log("started");

}

@Override

public void onExit() {

log("ended!");

}

public void onMessage(String m) throws InterruptedException{

String m = message.getMessages(MessageType.PLAYER);

if (m.contains("Repaid")){

log("someone said repaid");

String a = new String("wow!");

String b = new String("Thank you! <3");

String c = new String("<3 <3");

int r = random(1, 3);

if(r%2 == 0){

keyboard.typeString(a);

log("said" + a);

sleep(500);

}

if(r == 1){

keyboard.typeString(b);

log("said" + b);

sleep(400);

}

if(r == 3){

keyboard.typeString©;

log("said" + c);

sleep(500);

}

}

}

@Override

public int onLoop() throws InterruptedException {

return 215; //The amount of time in milliseconds before the loop starts over

}

@Override

public void onPaint(Graphics2D g) {

//This is where you will put your code for paint(s)

}

}

 

 

This is the code now. The line marked in red is giving error.  

Edited by sarthycool

package doubling;

import java.awt.Graphics2D;

import java.lang.Thread.State;

import java.util.List;

import org.osbot.rs07.api.Chatbox;

import org.osbot.rs07.api.Chatbox.MessageType;

import org.osbot.rs07.script.API;

import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(name = "respond", author = "", version = 1.0, info = "", logo = "")

public class doubling extends Script {

@Override

public void onStart() {

log("started");

}

@Override

public void onExit() {

log("ended!");

}

public void onMessage(String m) throws InterruptedException{

String m = message.getMessages(MessageType.PLAYER);

if (m.contains("Repaid")){

log("someone said repaid");

String a = new String("wow!");

String b = new String("Thank you! <3");

String c = new String("<3 <3");

int r = random(1, 3);

if(r%2 == 0){

keyboard.typeString(a);

log("said" + a);

sleep(500);

}

if(r == 1){

keyboard.typeString(b);

log("said" + b);

sleep(400);

}

if(r == 3){

keyboard.typeString©;

log("said" + c);

sleep(500);

}

}

}

@Override

public int onLoop() throws InterruptedException {

return 215; //The amount of time in milliseconds before the loop starts over

}

@Override

public void onPaint(Graphics2D g) {

//This is where you will put your code for paint(s)

}

}

 

 

This is the code now. The line marked in red is giving error.  

String Txt = message.getMessage().toLowerCase(); try this

  • Author

String Txt = message.getMessage().toLowerCase(); try this

 

Doesnt work. 'message' is being underlined. The error is "message cannot be resolved".

Doesnt work. 'message' is being underlined. The error is "message cannot be resolved".

 

:???:

 

Your function definition is this:

public void onMessage(String m) throws InterruptedException {

}

It should be:

@Override
public void onMessage(Message message) throws InterruptedException {

}

And now the Message variable is called message so:

@Override
public void onMessage(Message message) throws InterruptedException {
    String text = message.getMessage().toLowerCase();
}

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.