First commit - OpenBullet 1.0.0

This commit is contained in:
ruri
2019-03-31 12:18:26 +02:00
parent 1a0775b648
commit 422079782d
296 changed files with 31668 additions and 0 deletions
@@ -0,0 +1,62 @@
using System.ComponentModel;
using System.Threading;
namespace RuriLib.Runner
{
/// <summary>
/// Whether the AbortableBackgroundWorker is idle, stopping or working.
/// </summary>
public enum WorkerStatus
{
/// <summary>The Worker is not working.</summary>
Idle,
/// <summary>The Worker is working.</summary>
Running,
/// <summary>The Worker is cancelling its work.</summary>
Stopping
}
/// <summary>
/// A Worker that can be aborted like normal threads.
/// </summary>
public class AbortableBackgroundWorker : BackgroundWorker
{
private Thread workerThread;
/// <summary>The Status of the Worker.</summary>
public WorkerStatus Status { get; set; }
/// <summary>The Id of the Worker.</summary>
public int Id { get; set; }
/// <summary>
/// OnDoWork that supports aborting.
/// </summary>
/// <param name="e">The DoWorkEventArgs</param>
protected override void OnDoWork(DoWorkEventArgs e)
{
workerThread = Thread.CurrentThread;
try
{
base.OnDoWork(e);
}
catch (ThreadAbortException)
{
e.Cancel = true; //We must set Cancel property to true!
Thread.ResetAbort(); //Prevents ThreadAbortException propagation
}
}
/// <summary>Calls the Abort() method on the inner Thread.</summary>
public void Abort()
{
if (workerThread != null)
{
workerThread.Abort();
workerThread = null;
}
}
}
}
+36
View File
@@ -0,0 +1,36 @@
using RuriLib.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RuriLib.Runner
{
/// <summary>
/// Interface used to communicate between the RunnerViewModel and the corresponding View.
/// </summary>
public interface IRunnerMessaging
{
/// <summary>A message has arrived.</summary>
event Action<IRunnerMessaging, LogLevel, string, bool> MessageArrived;
/// <summary>The status of the Master Worker changed.</summary>
event Action<IRunnerMessaging> WorkerStatusChanged;
/// <summary>A Hit was found.</summary>
event Action<IRunnerMessaging, Hit> FoundHit;
/// <summary>The proxies need to be reloaded.</summary>
event Action<IRunnerMessaging> ReloadProxies;
/// <summary>An Action needs to be executed on the main thread.</summary>
event Action<IRunnerMessaging, Action> DispatchAction;
/// <summary>The progress needs to be saved.</summary>
event Action<IRunnerMessaging> SaveProgress;
/// <summary>The user needs to type the custom inputs.</summary>
event Action<IRunnerMessaging> AskCustomInputs;
}
}
+53
View File
@@ -0,0 +1,53 @@
using OpenQA.Selenium.Remote;
using RuriLib.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RuriLib.Runner
{
/// <summary>
/// Bot class. Includes a Worker that is used to perform checks on input data in the Runner.
/// </summary>
public class RunnerBotViewModel : ViewModelBase
{
private int id;
/// <summary>The unique id of the bot (usually between 1 and the total amount of Bots).</summary>
public int Id { get { return id; } set { id = value; OnPropertyChanged(); } }
private string data = "";
/// <summary>The data that needs to be checked.</summary>
public string Data { get { return data; } set { data = value; OnPropertyChanged(); } }
private string proxy = "";
/// <summary>The proxy that the Worker is using to perform requests.</summary>
public string Proxy { get { return proxy; } set { proxy = value; OnPropertyChanged(); } }
private string status = "Initializing...";
/// <summary>The status of the bot.</summary>
public string Status { get { return status; } set { status = value; OnPropertyChanged(); } }
/// <summary>The Worker that performs the checks.</summary>
public AbortableBackgroundWorker Worker { get; set; }
/// <summary>The Selenium WebDriver.</summary>
public RemoteWebDriver Driver { get; set; } = null;
/// <summary>Whether the Selenium WebDriver is open or not.</summary>
public bool IsDriverOpen { get; set; } = false;
/// <summary>
/// Creates an instance of a bot given an id.
/// </summary>
/// <param name="id">The unique id that will be assigned to the bot.</param>
public RunnerBotViewModel(int id)
{
Id = id;
Worker = new AbortableBackgroundWorker();
Worker.WorkerSupportsCancellation = true;
Worker.Id = id;
}
}
}
File diff suppressed because it is too large Load Diff