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 valuable drop notification

Featured Replies

Takes a little bit of regex but it's simple to do.

Instead of adding the item name to a list, in my loop() I do if valuableLootName !empty then force loot the one item, then resume normal function.

 

				String tmpLootName = "";
				if (msg.contains("aluable drop")) {
					tmpLootName = msg.replace("<col=ef1020>", "").replace("</col>", "")
							.replaceFirst("(.{0,15})", "").replaceFirst("(\\d x)", "")
							.replaceFirst("\\(([^\\)]+)\\)", "").trim();
					log("DROP MESSAGE: " + tmpLootName);
					valuableLootName = tmpLootName;
				}

 

  • Author
13 hours ago, Swizzbeat said:

Overcomplicated to hell. A simple between : and ( parsing with trim would suffice.

 

 

Meh, looks overcomplicated to hell. You'd still have to parse out the quantity by going with substring and trim. I found it easier on my eyes to do it this way, and the speed difference is so little it's laughable. Now if we were doing like 20k of these in one go this would be done a little different.

14 hours ago, Polymorphism said:

Takes a little bit of regex but it's simple to do.

Instead of adding the item name to a list, in my loop() I do if valuableLootName !empty then force loot the one item, then resume normal function.

 


				String tmpLootName = "";
				if (msg.contains("aluable drop")) {
					tmpLootName = msg.replace("<col=ef1020>", "").replace("</col>", "")
							.replaceFirst("(.{0,15})", "").replaceFirst("(\\d x)", "")
							.replaceFirst("\\(([^\\)]+)\\)", "").trim();
					log("DROP MESSAGE: " + tmpLootName);
					valuableLootName = tmpLootName;
				}

 

 

13 hours ago, Swizzbeat said:

Overcomplicated to hell. A simple between : and ( parsing with trim would suffice.

 

Agreed, this is over complicated. Either of these options would suffice:

Where the message is:

 String lootMessage = "<col=ef1020>Valuable drop: Onyx (3,038,047 coins)</col>";

 

Matcher m = Pattern.compile(": (.+) \\(").matcher(lootMessage);
if (m.find()) {
    String loot = m.group(1);
}

or

String loot = lootMessage.substring(lootMessage.indexOf(": ") + 2, lootMessage.lastIndexOf(" ("));

 

Edited by Explv

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.