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.

Basic chat tab API

Featured Replies

Better Alternative - liverare's API

 

Old API

 

Couldn't really find anything in the OSBot API that covers this, so I've made a simple API.
 

import org.osbot.script.Script;

public class ChatTabManager {
	
	private Script context;
	
	public ChatTabManager(Script context) {
		this.context = context;
	}
	
	public int getTabState(int tab) {
		return context.client.getInterface(548).getChild(tab).getSpriteIndex1();
	}
	
	public String getTabFilter(int tab) {
		String processedString = "{ERROR}";
		
		if(tab != ChatTab.GAME || tab != ChatTab.ALL) {
			String rawMessage = context.client.getInterface(548).getChild(tab + 2).getMessage();
			if(rawMessage.contains(">")) {
				processedString = rawMessage.substring(rawMessage.indexOf('>') + 1);
			} else {
				processedString = rawMessage;
			}
		}
		return processedString;
	}
	
	public boolean isTabOpen(int tab) {
		int tabState = this.getTabState(tab);
		if(tabState == TabState.OPEN || tabState == TabState.OPEN_HOVERED)
			return true;
		return false;
	}
	
	public int getCurrentTab() {
		int[] tabIDs = { 3, 6, 9, 13, 17, 21 };
		for(int id : tabIDs) {
			if(isTabOpen(id)) {
				return id;
			}
		}
		return 0;
	}
	
	public String getTabName(int tab) {
		return context.client.getInterface(548).getChild(tab + 1).getMessage();
	}
	
	public interface ChatTab {
		public final int ALL = 3;
		public final int GAME = 6;
		public final int PUBLIC = 9;
		public final int PRIVATE = 13;
		public final int CLAN = 17;
		public final int TRADE = 21;
	}
	
	public interface TabState {
		public final int STANDARD = 1019;
		public final int HOVERED = 1020;
		public final int UNREAD = 1021;
		public final int OPEN = 1022;
		public final int OPEN_HOVERED = 1023;
	}
}

For reference:
gueEr1m.png
Usage:

		ChatTabManager tabManager = new ChatTabManager(this);
		
		/* getTabFilter (<Integer ChatTab ID>) -- Returns 'On', 'Friends', 'Hide' etc. */
		String filterText = tabManager.getTabFilter(ChatTabManager.ChatTab.PUBLIC);
		
		/* getTabState (<Integer ChatTab ID>) -- Returns integer of the chat state */
		boolean isOpen = tabManager.getTabState(ChatTabManager.ChatTab.PUBLIC) == ChatTabManager.TabState.OPEN;
		
		/* isTabOpen (<Integer ChatTab ID>) -- Returns whether or not the specified tab is open */
		boolean isGameTabOpen = tabManager.isTabOpen(ChatTabManager.ChatTab.GAME);
		
		/* getCurrentTab () -- Returns the ID of the tab that is currently open */
		int currentTab = tabManager.getCurrentTab();
		
		/* getTabName (<Integer ChatTab ID>) -- Returns String value of that tab (eg. 'Private') */
		tabManager.getTabName(ChatTabManager.ChatTab.PRIVATE);

A thank you to Cyro for assisting me while creating this.

Edited by Parenthesis

if(tab != ChatTab.GAME || tab != ChatTab.ALL)

I believe you were supposed to use "&&". smile.png

 

I got to work on making a fully working API you can use.

 

Edited the API to make it not require Client to be a constant parameter for methods. However, an enum couldn't be used to achieve this.

Edited by liverare

  • Author
if(tab != ChatTab.GAME || tab != ChatTab.ALL)

I believe you were supposed to use "&&". smile.png

 

I got to work on making a fully working API you can use.

 

Example of use:

        if (!ChatTab.TRADE.isFilterSetToFriends(client))
            ChatTab.interact(client, ChatTab.TRADE, ChatTab.ACTION_FRIENDS);
        else if (!ChatTab.PUBLIC.isSelected(client))
            ChatTab.interact(client, ChatTab.PUBLIC, ChatTab.ACTION_VIEW);

-Check to see if trade tab's filter is not set to friends.

--Set the trade tab's filter to friends.

-Else check to see if the public tab's filter is not set to selected.

--Select the public tab.

 

Enjoy. smile.png

 

 

You're right on those conditional operators, don't know how I missed that.

 

That's an amazing API! way more useful than my current one. I'll put it up in the main post.

Guest
This topic is now closed to further replies.

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.