Skip to content

Commit

Permalink
cant press buttons twice
Browse files Browse the repository at this point in the history
  • Loading branch information
realTristan committed Jan 4, 2023
1 parent c717643 commit f847b07
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 18 additions & 5 deletions program/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod lib;
use lib::{
discord,
user::User,
thread::Thread
thread::Thread, global
};

fn main() -> iced::Result {
Expand Down Expand Up @@ -37,6 +37,7 @@ pub enum App {

// Page struct
pub struct Page {
running: bool,
current_token: String,
logs: Vec<String>,
current_page: u8,
Expand All @@ -58,6 +59,7 @@ impl Sandbox for Page {
fn new() -> Self {
let _user: User = User::new();
Self {
running: false,
current_page: 1, // _user.login()
user: _user,
current_token: String::new(),
Expand Down Expand Up @@ -103,33 +105,44 @@ impl Sandbox for Page {
}
},
App::StartPressed => {
println!("thread started");
if self.running {
return self.logs.push(String::from("Anti-cheat already started"));
}

// Clone the token for thread
thread.start(&self.user.bearer, &self.token);

// Update variables
self.running = true;
self.current_token = self.token.clone();
self.logs = Vec::new();
self.logs.push(format!("{}: Anti-cheat started", global::get_date_time()));

// Send a start notification
if !discord::send_start_message(&self.user.bearer, &self.token) {
self.logs.push(String::from("failed to send start message"));
self.logs.push(String::from("Failed to send start message"));
return
}
},
App::StopPressed => {
println!("thread stopped");
if !self.running {
return self.logs.push(String::from("anti-cheat already stopped"));
}

// Stop the thread
thread.stop();

// Reset variables
self.running = false;
self.current_token = String::new();
self.logs = Vec::new();
self.logs.push(format!("{}: Anti-cheat stopped", global::get_date_time()));

// Send a start notification
discord::send_stop_message(&self.user.bearer, &self.token);
if !discord::send_stop_message(&self.user.bearer, &self.token) {
self.logs.push(String::from("Failed to send stop message"));
return
}
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion program/target/.rustc_info.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"rustc_fingerprint":472984446891056861,"outputs":{"10376369925670944939":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/tristan/.rustup/toolchains/stable-x86_64-apple-darwin\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_feature=\"ssse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"apple\"\nunix\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.66.0 (69f9c33d7 2022-12-12)\nbinary: rustc\ncommit-hash: 69f9c33d71c871fc16ac445211281c6e7a340943\ncommit-date: 2022-12-12\nhost: x86_64-apple-darwin\nrelease: 1.66.0\nLLVM version: 15.0.2\n","stderr":""},"15697416045686424142":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n","stderr":""}},"successes":{}}
{"rustc_fingerprint":472984446891056861,"outputs":{"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.66.0 (69f9c33d7 2022-12-12)\nbinary: rustc\ncommit-hash: 69f9c33d71c871fc16ac445211281c6e7a340943\ncommit-date: 2022-12-12\nhost: x86_64-apple-darwin\nrelease: 1.66.0\nLLVM version: 15.0.2\n","stderr":""},"15697416045686424142":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n","stderr":""},"10376369925670944939":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/tristan/.rustup/toolchains/stable-x86_64-apple-darwin\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"sse3\"\ntarget_feature=\"ssse3\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"apple\"\nunix\n","stderr":""}},"successes":{}}

0 comments on commit f847b07

Please sign in to comment.