mirror of
https://github.com/MeexReay/bRAC.git
synced 2025-05-06 13:38:04 +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
|
||||
- coloring usernames by their clients (CRAB, clRAC, Mefidroniy, etc)
|
||||
- RACv1.99.x compatible
|
||||
- cheat commands
|
||||
|
||||

|
||||
|
||||
@ -48,6 +49,11 @@ regex - `<(.*?)> (.*)` \
|
||||
color - cyan \
|
||||
example - `<nick> text`
|
||||
|
||||
### commands
|
||||
|
||||
/clear - clear chat
|
||||
/spam *args - spam in chat with text
|
||||
|
||||
## see also
|
||||
|
||||
- [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, args) = command.split_once(" ").unwrap_or((&command, ""));
|
||||
let args = args.split(" ").collect::<Vec<&str>>();
|
||||
|
||||
if command == "clear" {
|
||||
send_message(host, &format!("\r\x1B[1A{}", " ".repeat(64)).repeat(MAX_MESSAGES))?;
|
||||
// *input.write().unwrap() = "/ заспамлено)))".to_string();
|
||||
} else if command == "spam" {
|
||||
send_message(host, &format!("\r\x1B[1A{}{}", args.join(" "), " ".repeat(10)).repeat(MAX_MESSAGES))?;
|
||||
// *input.write().unwrap() = "/ заспамлено)))".to_string();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -260,23 +262,26 @@ fn main() {
|
||||
match key.unwrap() {
|
||||
Key::Char('\n') => {
|
||||
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.starts_with("/") {
|
||||
on_command(&host, &message).expect("Error on command");
|
||||
on_command(&host, &message, input.clone()).expect("Error on command");
|
||||
} else {
|
||||
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 => {
|
||||
if input.write().unwrap().pop().is_some() {
|
||||
|
Loading…
Reference in New Issue
Block a user