mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 16:49:10 +00:00
Improved bot
This commit is contained in:
@@ -48,7 +48,6 @@ public class AddGetterAdapter implements Opcodes, Injectable {
|
|||||||
final ClassNode fieldLocation, final FieldNode fieldNode,
|
final ClassNode fieldLocation, final FieldNode fieldNode,
|
||||||
final String methodName, final String returnDesc,
|
final String methodName, final String returnDesc,
|
||||||
final boolean staticMethod, final long multiplier) {
|
final boolean staticMethod, final long multiplier) {
|
||||||
Core.verbose("Injecting getter method: " + methodName);
|
|
||||||
this.into = into;
|
this.into = into;
|
||||||
this.fieldLocation = fieldLocation;
|
this.fieldLocation = fieldLocation;
|
||||||
this.fieldNode = fieldNode;
|
this.fieldNode = fieldNode;
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public class ServerProviderInfo {
|
|||||||
Core.verbose("Reading info: " + providerInfo);
|
Core.verbose("Reading info: " + providerInfo);
|
||||||
BufferedReader br = WebUtil.getReader(new URL(providerInfo.toString() + "&method=json"), username, password);
|
BufferedReader br = WebUtil.getReader(new URL(providerInfo.toString() + "&method=json"), username, password);
|
||||||
|
|
||||||
|
|
||||||
JSONParser parser = new JSONParser();
|
JSONParser parser = new JSONParser();
|
||||||
if ((line = br.readLine()) != null) {
|
if ((line = br.readLine()) != null) {
|
||||||
JSONObject jsonObject = (JSONObject) parser.parse(line);
|
JSONObject jsonObject = (JSONObject) parser.parse(line);
|
||||||
@@ -59,6 +58,15 @@ public class ServerProviderInfo {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public URL getExtendenHookFile() {
|
||||||
|
try {
|
||||||
|
return new URL(properties.get("hooks") + "&extended=true");
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return getHookFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public URL getHookFile() {
|
public URL getHookFile() {
|
||||||
try {
|
try {
|
||||||
return new URL(properties.get("hooks"));
|
return new URL(properties.get("hooks"));
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package org.parabot.core.forum;
|
package org.parabot.core.forum;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Class which holds parabot forum account user and pass, only specific classes
|
* Class which holds parabot forum account user and pass, only specific classes
|
||||||
@@ -15,8 +18,8 @@ public class Account {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param username - UTF-8 encoded forum account username
|
* @param username - Forum account username
|
||||||
* @param password - UTF-8 encoded forum account password
|
* @param password - Forum account password
|
||||||
*/
|
*/
|
||||||
public Account(final String username, final String password) {
|
public Account(final String username, final String password) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
@@ -25,7 +28,7 @@ public class Account {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets user's parabot account name
|
* Gets user's parabot account name
|
||||||
* @return username, already URL UTF-8 encoded.
|
* @return username.
|
||||||
*/
|
*/
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return this.username;
|
return this.username;
|
||||||
@@ -33,10 +36,36 @@ public class Account {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets user's parabot password
|
* Gets user's parabot password
|
||||||
* @return password, already URL UTF-8 encoded.
|
* @return password.
|
||||||
*/
|
*/
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return this.password;
|
return this.password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets user's parabot account name
|
||||||
|
* @return username, already URL UTF-8 encoded.
|
||||||
|
*/
|
||||||
|
public String getURLUsername(){
|
||||||
|
try {
|
||||||
|
return URLEncoder.encode(this.username, "UTF-8");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets user's password
|
||||||
|
* @return password, already URL UTF-8 encoded.
|
||||||
|
*/
|
||||||
|
public String getURLPassword(){
|
||||||
|
try {
|
||||||
|
return URLEncoder.encode(this.password, "UTF-8");
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import org.parabot.environment.api.utils.WebUtil;
|
|||||||
import org.parabot.environment.scripts.executers.SDNScriptExecuter;
|
import org.parabot.environment.scripts.executers.SDNScriptExecuter;
|
||||||
import org.parabot.environment.servers.executers.PublicServerExecuter;
|
import org.parabot.environment.servers.executers.PublicServerExecuter;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@@ -74,11 +73,7 @@ public final class AccountManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (contents.equals("correct")) {
|
if (contents.equals("correct")) {
|
||||||
try {
|
account = new Account(user, pass);
|
||||||
account = new Account(URLEncoder.encode(user, "UTF-8"), URLEncoder.encode(pass, "UTF-8"));
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class SDNScripts extends ScriptParser {
|
|||||||
JSONParser parser = new JSONParser();
|
JSONParser parser = new JSONParser();
|
||||||
try {
|
try {
|
||||||
BufferedReader br = WebUtil.getReader(new URL(String.format(Configuration.SDN_SCRIPTS_JSON, manager.getAccount()
|
BufferedReader br = WebUtil.getReader(new URL(String.format(Configuration.SDN_SCRIPTS_JSON, manager.getAccount()
|
||||||
.getUsername())));
|
.getURLUsername())));
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class PublicServers extends ServerParser {
|
|||||||
public void execute() {
|
public void execute() {
|
||||||
try {
|
try {
|
||||||
BufferedReader br = WebUtil.getReader(new URL(
|
BufferedReader br = WebUtil.getReader(new URL(
|
||||||
Configuration.GET_SERVER_PROVIDERS_JSON), manager.getAccount().getUsername(), manager.getAccount().getPassword());
|
Configuration.GET_SERVER_PROVIDERS_JSON), manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword());
|
||||||
String line;
|
String line;
|
||||||
|
|
||||||
JSONParser parser = new JSONParser();
|
JSONParser parser = new JSONParser();
|
||||||
|
|||||||
@@ -155,6 +155,4 @@ public class Script implements Runnable {
|
|||||||
Time.sleep(ms);
|
Time.sleep(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,5 @@
|
|||||||
package org.parabot.environment.scripts.executers;
|
package org.parabot.environment.scripts.executers;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLConnection;
|
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
|
|
||||||
import org.parabot.core.Configuration;
|
import org.parabot.core.Configuration;
|
||||||
import org.parabot.core.classpath.ClassPath;
|
import org.parabot.core.classpath.ClassPath;
|
||||||
import org.parabot.core.forum.AccountManager;
|
import org.parabot.core.forum.AccountManager;
|
||||||
@@ -15,6 +9,11 @@ import org.parabot.environment.api.utils.WebUtil;
|
|||||||
import org.parabot.environment.scripts.Script;
|
import org.parabot.environment.scripts.Script;
|
||||||
import org.parabot.environment.scripts.loader.JavaScriptLoader;
|
import org.parabot.environment.scripts.loader.JavaScriptLoader;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Loads a script from the SDN
|
* Loads a script from the SDN
|
||||||
@@ -44,7 +43,7 @@ public class SDNScriptExecuter extends ScriptExecuter {
|
|||||||
@Override
|
@Override
|
||||||
public void run(ThreadGroup tg) {
|
public void run(ThreadGroup tg) {
|
||||||
try {
|
try {
|
||||||
final URLConnection urlConnection = WebUtil.getConnection(new URL(String.format(Configuration.GET_SDN_SCRIPT, manager.getAccount().getUsername(), manager.getAccount().getPassword(), this.id)));
|
final URLConnection urlConnection = WebUtil.getConnection(new URL(String.format(Configuration.GET_SDN_SCRIPT, manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword(), this.id)));
|
||||||
final String contentType = urlConnection.getHeaderField("Content-type");
|
final String contentType = urlConnection.getHeaderField("Content-type");
|
||||||
if(contentType.equals("text/html")) {
|
if(contentType.equals("text/html")) {
|
||||||
// failed to fetch script
|
// failed to fetch script
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class PublicServerExecuter extends ServerExecuter {
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
ServerProviderInfo serverProviderInfo = new ServerProviderInfo(new URL(Configuration.GET_SERVER_PROVIDER_INFO
|
ServerProviderInfo serverProviderInfo = new ServerProviderInfo(new URL(Configuration.GET_SERVER_PROVIDER_INFO
|
||||||
+ this.serverID), manager.getAccount().getUsername(), manager.getAccount().getPassword());
|
+ this.serverID), manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword());
|
||||||
|
|
||||||
final File destination = new File(Directories.getCachePath(),
|
final File destination = new File(Directories.getCachePath(),
|
||||||
serverProviderInfo.getCRC32() + ".jar");
|
serverProviderInfo.getCRC32() + ".jar");
|
||||||
@@ -66,7 +66,7 @@ public class PublicServerExecuter extends ServerExecuter {
|
|||||||
Core.verbose("Found cached server provider [CRC32: " + serverProviderInfo.getCRC32() + "]");
|
Core.verbose("Found cached server provider [CRC32: " + serverProviderInfo.getCRC32() + "]");
|
||||||
} else {
|
} else {
|
||||||
WebUtil.downloadFile(new URL(jarUrl), destination,
|
WebUtil.downloadFile(new URL(jarUrl), destination,
|
||||||
VerboseLoader.get(), manager.getAccount().getUsername(), manager.getAccount().getPassword());
|
VerboseLoader.get(), manager.getAccount().getURLUsername(), manager.getAccount().getURLPassword());
|
||||||
Core.verbose("Server provider downloaded...");
|
Core.verbose("Server provider downloaded...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user