mirror of
https://github.com/MeexReay/bRAC.git
synced 2025-05-07 14:08:02 +03:00
commands in readme
This commit is contained in:
parent
b2f11ca60a
commit
2812e51a9b
@ -8,6 +8,7 @@ better RAC client
|
|||||||
- using tor proxy by default
|
- using tor proxy by default
|
||||||
- coloring usernames by their clients (CRAB, clRAC, Mefidroniy, etc)
|
- coloring usernames by their clients (CRAB, clRAC, Mefidroniy, etc)
|
||||||
- RACv1.99.x compatible
|
- RACv1.99.x compatible
|
||||||
|
- cheat commands
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@ -48,6 +49,11 @@ regex - `<(.*?)> (.*)` \
|
|||||||
color - cyan \
|
color - cyan \
|
||||||
example - `<nick> text`
|
example - `<nick> text`
|
||||||
|
|
||||||
|
### commands
|
||||||
|
|
||||||
|
/clear - clear chat
|
||||||
|
/spam *args - spam in chat with text
|
||||||
|
|
||||||
## see also
|
## see also
|
||||||
|
|
||||||
- [CRAB - client & server for RAC](https://gitea.bedohswe.eu.org/pixtaded/crab)
|
- [CRAB - client & server for RAC](https://gitea.bedohswe.eu.org/pixtaded/crab)
|
||||||
|
29
src/main.rs
29
src/main.rs
@ -179,15 +179,17 @@ fn format_message(message: String) -> Option<String> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_command(host: &str, command: &str) -> Result<(), Box<dyn Error>> {
|
fn on_command(host: &str, command: &str, input: Arc<RwLock<String>>) -> Result<(), Box<dyn Error>> {
|
||||||
let command = command.trim_start_matches("/");
|
let command = command.trim_start_matches("/");
|
||||||
let (command, args) = command.split_once(" ").unwrap_or((&command, ""));
|
let (command, args) = command.split_once(" ").unwrap_or((&command, ""));
|
||||||
let args = args.split(" ").collect::<Vec<&str>>();
|
let args = args.split(" ").collect::<Vec<&str>>();
|
||||||
|
|
||||||
if command == "clear" {
|
if command == "clear" {
|
||||||
send_message(host, &format!("\r\x1B[1A{}", " ".repeat(64)).repeat(MAX_MESSAGES))?;
|
send_message(host, &format!("\r\x1B[1A{}", " ".repeat(64)).repeat(MAX_MESSAGES))?;
|
||||||
|
// *input.write().unwrap() = "/ заспамлено)))".to_string();
|
||||||
} else if command == "spam" {
|
} else if command == "spam" {
|
||||||
send_message(host, &format!("\r\x1B[1A{}{}", args.join(" "), " ".repeat(10)).repeat(MAX_MESSAGES))?;
|
send_message(host, &format!("\r\x1B[1A{}{}", args.join(" "), " ".repeat(10)).repeat(MAX_MESSAGES))?;
|
||||||
|
// *input.write().unwrap() = "/ заспамлено)))".to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -260,23 +262,26 @@ fn main() {
|
|||||||
match key.unwrap() {
|
match key.unwrap() {
|
||||||
Key::Char('\n') => {
|
Key::Char('\n') => {
|
||||||
let message = input.read().unwrap().clone();
|
let message = input.read().unwrap().clone();
|
||||||
|
|
||||||
|
{
|
||||||
|
let input_len = input.read().unwrap().len();
|
||||||
|
write!(terminal.lock().unwrap(),
|
||||||
|
"{}{}{}",
|
||||||
|
cursor::Left(1).to_string().repeat(input_len),
|
||||||
|
" ".repeat(input_len),
|
||||||
|
cursor::Left(1).to_string().repeat(input_len)
|
||||||
|
).unwrap();
|
||||||
|
terminal.lock().unwrap().flush().unwrap();
|
||||||
|
input.write().unwrap().clear();
|
||||||
|
}
|
||||||
|
|
||||||
if !message.is_empty() {
|
if !message.is_empty() {
|
||||||
if message.starts_with("/") {
|
if message.starts_with("/") {
|
||||||
on_command(&host, &message).expect("Error on command");
|
on_command(&host, &message, input.clone()).expect("Error on command");
|
||||||
} else {
|
} else {
|
||||||
send_message(&host, &format!("{}<{}> {}", MAGIC_KEY, name, message)).expect("Error sending message");
|
send_message(&host, &format!("{}<{}> {}", MAGIC_KEY, name, message)).expect("Error sending message");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let input_len = input.read().unwrap().len();
|
|
||||||
write!(terminal.lock().unwrap(),
|
|
||||||
"{}{}{}",
|
|
||||||
cursor::Left(1).to_string().repeat(input_len),
|
|
||||||
" ".repeat(input_len),
|
|
||||||
cursor::Left(1).to_string().repeat(input_len)
|
|
||||||
).unwrap();
|
|
||||||
terminal.lock().unwrap().flush().unwrap();
|
|
||||||
input.write().unwrap().clear();
|
|
||||||
}
|
}
|
||||||
Key::Backspace => {
|
Key::Backspace => {
|
||||||
if input.write().unwrap().pop().is_some() {
|
if input.write().unwrap().pop().is_some() {
|
||||||
|
Loading…
Reference in New Issue
Block a user