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.

Parsing private messages and clan chat

Featured Replies

Hi guys. 

 

I need to listen to the clan chat and private messages that my account receives and act on them. I'm not sure how I can achieve this however. 

 

Basically I'd like my bot to join a clan chat, and when another character says a certain phrase it acts on it. Is this even possible?

 

Thanks

Hi guys. 

 

I need to listen to the clan chat and private messages that my account receives and act on them. I'm not sure how I can achieve this however. 

 

Basically I'd like my bot to join a clan chat, and when another character says a certain phrase it acts on it. Is this even possible?

 

Thanks

@Override
public void onMessage(Message message){

    if(message.getType() == Message.MessageType.PLAYER){
            
      String text = message.getMessage();
    }
}

That should get you started

Awesome. Thanks! Will that also work for clan chat messages if I change the type?

 

The only MessageTypes available are:

GAME 
PLAYER 
RECEIVE_TRADE

So GAME will include clan chat messages.

Edited by Explv

  • Author

Oh I see, is there anyway I can differentiate between clan chat and private chat messages? 

 

Thanks for your help.

Oh I see, is there anyway I can differentiate between clan chat and private chat messages? 

 

Thanks for your help.

 

I think it might be ID 9 for clan chat:

@Override
public void onMessage(Message message){

    if(message.getTypeId() == 9){

      // do something
    }
}

Edited by Explv

  • Author

Ok so I have another issue. 

 

@Override
public void onMessage(Message message){
log("Message received.");
String messageReceived = message.getMessage();

if(message.getTypeId() == 9){
log("Clan chat message.");

if(messageReceived == "/!Test"){
log("Test received..");
getKeyboard().typeString("/Success!", true);
}

log(messageReceived);
}

 

Although it appears in my logger as !Test, the if statement doesn't resolve as true so the code wont execute? Am I missing something.

Ok so I have another issue. 

@Override
public void onMessage(Message message){
log("Message received.");
String messageReceived = message.getMessage();

if(message.getTypeId() == 9){
log("Clan chat message.");

if(messageReceived == "/!Test"){
log("Test received..");
getKeyboard().typeString("/Success!", true);
}

log(messageReceived);
}

Although it appears in my logger as !Test, the if statement doesn't resolve as true so the code wont execute? Am I missing something.

 

String values are compared using .equals()  not ==

 

Also the message will not contain /

 

It should be:

if(messageReceived.equals("!Test")){
    log("Test received..");
    getKeyboard().typeString("/Success!", true);
}

  • Author

Oh yeah of course! I knew it would be something simple like that! Thanks again!


I don't suppose you know how I can grab the message senders character name and store it in a variable? 

I figured out. Thanks for your help though!

Edited by ninjamuffinz

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.