diff --git a/README.md b/README.md index 061fefd..c3e0c4d 100644 --- a/README.md +++ b/README.md @@ -34,17 +34,20 @@ cargo build --release # build release (target/release/bRAC) cargo run # run (builds and runs bRAC itself) ``` -## config +## default config ```yml host: meex.lol:11234 # server host -name: null # user name +name: null # user name (null - ask every time) message_format: 리㹰<{name}> {text} # message format update_time: 50 # update chat interval -max_messages: 100 # chat messages limit +max_messages: 200 # chat messages limit +enable_ip_viewing: false # enable users' ip viewing +disable_ip_hiding: false # disable your ip hiding +enable_auth: false # enable auth-mode ``` -## command args +## command-line options ``` -p, --config-path Print config path @@ -58,23 +61,30 @@ max_messages: 100 # chat messages limit -i, --disable-ip-hiding Disable ip hiding -v, --enable-users-ip-viewing Enable users IP viewing -C, --configure Configure client --a, --disable-auth Disable authentication +-a, --enable-auth Enable authentication -h, --help Print help -V, --version Print version ``` -## commands +## cheat commands -`/help` - show help message \ -`/clear` - clear chat \ -`/spam *args` - spam with text \ -`/ping` - get server ping (send + read) +commands are any messages that start with a slash `/` \ +messages starting with a slash are sent to chat only if the `--disable-commands` option is specified + +- `/help` - show help message \ +- `/clear` - clear chat \ +- `/spam *args` - spam with text \ +- `/ping` - get server ping (send + read) + +## docs + +- [Message formats](https://github.com/MeexReay/bRAC/blob/main/docs/message_formats.md) +- [Authenticated mode](https://github.com/MeexReay/bRAC/blob/main/docs/auth_mode.md) ## see also - [RAC protocol (v2.0)](https://gitea.bedohswe.eu.org/pixtaded/crab#rac-protocol) - [CRAB - client & server for RAC](https://gitea.bedohswe.eu.org/pixtaded/crab) - [Mefidroniy - client for RAC](https://github.com/OctoBanon-Main/mefedroniy-client) -- [Colored usernames](https://github.com/MeexReay/bRAC/blob/main/docs/colored_usernames.md) - [AlmatyD - server for RACv1.0](https://gitea.bedohswe.eu.org/bedohswe/almatyd) - [RAC protocol (v1.0)](https://bedohswe.eu.org/text/rac/protocol.md.html) diff --git a/docs/auth_mode.md b/docs/auth_mode.md new file mode 100644 index 0000000..7cd6a52 --- /dev/null +++ b/docs/auth_mode.md @@ -0,0 +1,8 @@ +# auth mode + +## differences from the unauthorized mode + +### message format + +- there is must to be "> " after name ({name}> {text}) +- if there is magic key (like 리㹰) then you must add "<" sign after it (not always) diff --git a/docs/colored_usernames.md b/docs/colored_usernames.md deleted file mode 100644 index 28f4719..0000000 --- a/docs/colored_usernames.md +++ /dev/null @@ -1,25 +0,0 @@ -# colored usernames - -## bRAC - -regex - `\uB9AC\u3E70<(.*?)> (.*)` \ -color - green \ -example - `리㹰 text` - -## CRAB - -regex - `\u2550\u2550\u2550<(.*?)> (.*)` \ -color - light red \ -example - `═══ text` - -## Mefedroniy - -regex - `(.*?): (.*)` \ -color - light magenta \ -example - `nick: text` - -## clRAC - -regex - `<(.*?)> (.*)` \ -color - cyan \ -example - ` text` \ No newline at end of file diff --git a/docs/message_formats.md b/docs/message_formats.md new file mode 100644 index 0000000..0f04c8e --- /dev/null +++ b/docs/message_formats.md @@ -0,0 +1,47 @@ +# message formats + +## types + +### bRAC + +this client + +```yml +format: "리㹰<{name}> {text}" +regex: "\uB9AC\u3E70<(.*?)> (.*)" +color: "green" +``` + +### CRAB + +[CRAB - client & server for RAC written in java](https://gitea.bedohswe.eu.org/pixtaded/crab) + +```yml +format: "═══<{name}> {text}" +regex: "\u2550\u2550\u2550<(.*?)> (.*)" +color: "light red" +``` + +### Mefedroniy + +[Mefidroniy - client for RAC written in rust](https://github.com/OctoBanon-Main/mefedroniy-client) + +```yml +format: "°ʘ<{name}> {text}" +regex: "\u00B0\u0298<(.*?)> (.*)" +color: "light magenta" +``` + +### clRAC + +official client + +```yml +format: "<{name}> {text}" +regex: "<(.*?)> (.*)" +color: "cyan" +``` + +## developer notes + +in auth-mode, there is must to be `> ` after name (`{name}> {text}`) \ No newline at end of file diff --git a/src/config.rs b/src/config.rs index 1c14f24..f56f054 100644 --- a/src/config.rs +++ b/src/config.rs @@ -39,7 +39,7 @@ fn default_host() -> String { "meex.lol:11234".to_string() } fn default_message_format() -> String { MESSAGE_FORMAT.to_string() } fn ask_usize(name: impl ToString, default: usize) -> usize { - get_input(format!("{} (default: {}) > ", name.to_string(), default).bright_yellow()) + get_input(format!("{} (default: {}) {} ", name.to_string().bold(), default, ">".bold()).bright_yellow()) .and_then(|o| o.parse().ok()).unwrap_or(default) } @@ -49,11 +49,11 @@ fn ask_string(name: impl ToString, default: impl ToString + Clone) -> String { fn ask_string_option(name: impl ToString, default: impl ToString) -> Option { let default = default.to_string(); - get_input(format!("{} (default: {}) > ", name.to_string(), default).bright_yellow()) + get_input(format!("{} (default: {}) {} ", name.to_string().bold(), default, ">".bold()).bright_yellow()) } fn ask_bool(name: impl ToString, default: bool) -> bool { - get_input(format!("{} (Y/N, default: {}) > ", name.to_string(), if default { "Y" } else { "N" }).bright_yellow()) + get_input(format!("{} (Y/N, default: {}) {} ", name.to_string().bold(), if default { "Y" } else { "N" }, ">".bold()).bright_yellow()) .map(|o| o.to_lowercase() != "n") .unwrap_or(default) } diff --git a/src/proto.rs b/src/proto.rs index 9faff6e..3461824 100644 --- a/src/proto.rs +++ b/src/proto.rs @@ -1,4 +1,4 @@ -use std::{error::Error, io::{Read, Write}, net::{Shutdown, TcpStream}}; +use std::{error::Error, io::{Read, Write}, net::TcpStream};