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.

Script interaction via dropbox

Featured Replies

So I  have been working on a little method that parses string from a .txt file from my dropbox.

I parse the string, split it and then use the fragments as variables (for quick id fixes, live updates, etc...).

 

Everything works fine but even though the getDropbox() method is only called during onStart I still feel that it slows down the script way to much. 

 

2lxhvr8.jpg

String dropboxLink = "https://dl.dropboxusercontent.com/u/xxx/xxx.txt";
URL url;
BufferedInputStream in;
HttpURLConnection con;
int responseCode = 0;
public String[] dropboxDataArray;
	private void getDropBox() throws IOException {
		try {
			url = new URL(dropboxLink);
		} catch (MalformedURLException e1) {
			e1.printStackTrace();
		}
		HttpURLConnection.setFollowRedirects(true);
		try {
			con = (HttpURLConnection) url.openConnection();
		} catch (IOException e4) {
			e4.printStackTrace();
		}
		con.setDoOutput(false);
		con.setReadTimeout(20000);
		con.setRequestProperty("Connection", "keep-alive");
		con.setRequestProperty("User-Agent",
				"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0");
		try {
			((HttpURLConnection) con).setRequestMethod("GET");
		} catch (ProtocolException e3) {
			e3.printStackTrace();
		}
		con.setConnectTimeout(5000);
		try {
			in = new BufferedInputStream(con.getInputStream());
		} catch (IOException e2) {
			e2.printStackTrace();
		}
		try {
			responseCode = con.getResponseCode();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
		if (responseCode == HttpURLConnection.HTTP_OK) {
		}
		   StringBuffer buffer = new StringBuffer();
           int chars_read;
           while ((chars_read = in.read()) != -1) 
           {
               char g = (char) chars_read;
               buffer.append(g);
           }
           final String dropboxContent = buffer.toString();
           dropboxDataArray = dropboxContent.split("\\s+");
	}

Edited by Botrepreneur

I don't know much about java but I know getting text from a website shouldn't be that complicated.

I'm pretty sure something like this works;

 

String response = "";
URL url = new URL(url);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter writer = new OutputStreamWriter(
conn.getOutputStream());
writer.flush();
 
BufferedReader reader = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
 
response = reader.readLine();
 
writer.close();
reader.close();
  • Author

 

I don't know much about java but I know getting text from a website shouldn't be that complicated.

I'm pretty sure something like this works;

String response = "";
URL url = new URL(url);
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter writer = new OutputStreamWriter(
conn.getOutputStream());
writer.flush();
 
BufferedReader reader = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
 
response = reader.readLine();
 
writer.close();
reader.close();

 

dropbox are assholes, those kind of short methods only returned characters from their site (the osbot client didn't like that at all) and not from the .txt file I specifically requested.

You should really look into threads.  I use threads for my script to contact my server while the script is starting.  The script can continue to run and not be hung up by the dropbox.

 

So the variables you set via dropbox all have to be initialized as null, or their default values.

 

Create a new thread with the dropbox method in it -> run it

 

Thread will continue to run and the dropbox method will update the variables over time.

Edited by dreamliner

I used to use pastebin when my MTA script was free to notify the user of an update. Maybe use that as an alternative to dropbox. As far as I can tell, you are having to pretend to be firefox which makes it complicated.

Edited by Diclonius

wrote this a while back to auto update local scripts.. hope it helps

	private void checkForUpdate() throws InterruptedException {
		try {
			URL url = new URL("url");
			Scanner s = new Scanner(url.openStream());
			String latestVersion = s.next();
			if (latestVersion.equals(/* version getting here*/"1.0")) {
			} else if (latestVersion.equals("Stop")) {
			} else {
				updateScript();
			}
			s.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
  • Author

 

wrote this a while back to auto update local scripts.. hope it helps

	private void checkForUpdate() throws InterruptedException {
		try {
			URL url = new URL("url");
			Scanner s = new Scanner(url.openStream());
			String latestVersion = s.next();
			if (latestVersion.equals(/* version getting here*/"1.0")) {
			} else if (latestVersion.equals("Stop")) {
			} else {
				updateScript();
			}
			s.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

 

this method (like the other short answers from above) doesn't seem to work for dropbox :/

The method from the OP seems to work fine now tho, might just have been experiencing internet issues tongue.png

Edited by Botrepreneur

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.