Compare commits

..

No commits in common. "5b23a3bd703954e655e1b465679698eca8ceefe6" and "c3982a211ccf48113433573ce90cadd3781ca469" have entirely different histories.

6 changed files with 37 additions and 104 deletions

View File

@ -87,7 +87,6 @@ messages starting with a slash are sent to chat only if the `--disable-commands`
- [Compiling](docs/compiling.md)
- [User agents](docs/user_agents.md)
- [Using as crate](docs/crate.md)
- [Authenticated mode](docs/auth_mode.md)
- [WRAC protocol (v2.0)](docs/wrac.md)
- [About RAC URL](docs/url.md)

View File

@ -1,60 +0,0 @@
# Using as crate
This article describes how to use the client as rust crate
## Installation
To use exact version:
```toml
[dependencies.bRAC]
git = "https://github.com/MeexReay/bRAC"
tag = "0.1.2+2.0"
default-features = false
```
To use with latest changes:
```toml
[dependencies.bRAC]
git = "https://github.com/MeexReay/bRAC"
default-features = false
```
`default-features = false` here removes GTK4 gui from installation.
## Usage
As the code structure was changed like about gazillion times,
you need to explore it yourself, if you are using an old version.
Here is example of usage on commit [80e7b8c](https://github.com/MeexReay/bRAC/commit/80e7b8c50642f9b76be06980305ed03253858d0c)
```rust
use bRAC::proto::*;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let mut conn = connect("rac://meex.lol", None)?; // read docs/url.md
send_message(&mut conn, "<dude> hi RAC-loving kikes!")?;
register_user(&mut conn, "dude", "password")?;
send_message_auth(&mut conn, "dude", "password", "my auth message")?;
send_message_spoof_auth(&mut conn, "<dude> this message totally fucks auth system")?;
let (mut all_messages, last_size) = read_messages(&mut conn, 10, 0, false)?.unwrap(); // limits with 10 messages
/* imagine that new messages were written here */
let (mut new_messages, last_size) = read_messages(&mut conn, 10, last_size, true)?.unwrap(); // chunked reading!
all_messages.append(&mut new_messages);
println!("all_messages: {all_messages:?}. last_size: {last_size}");
Ok(())
}
```
## See more
- [rac-rs - A Rust client library for RAC protocol. (with async support)](https://github.com/kostya-zero/rac-rs)

View File

@ -11,9 +11,8 @@ Here are listed the most common clients, and their name colors in the chat.
| [bRAC](https://github.com/MeexReay/bRAC) | 리㹰<{name}> {text} | `\uB9AC\u3E70<(.*?)> (.*)` | green
| [CRAB](https://gitea.bedohswe.eu.org/pixtaded/crab) | ═══<{name}> {text} | `\u2550\u2550\u2550<(.*?)> (.*)` | light red
| [Mefidroniy](https://github.com/OctoBanon-Main/mefedroniy-client) | °ʘ<{name}> {text} | `\u00B0\u0298<(.*?)> (.*)` | light magenta
| [cRACk](https://github.com/pansangg/cRACk) | ⁂<{name}> {text} | `\u2042<(.*?)> (.*)` | gold
| clRAC | <{name}> {text} | `<(.*?)> (.*)` | cyan
## developer notes
in auth-mode, there is must to be `> ` after name (`{name}> {text}`)
in auth-mode, there is must to be `> ` after name (`{name}> {text}`)

View File

@ -1,23 +0,0 @@
use bRAC::proto::*;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let mut conn = connect("rac://meex.lol", None)?;
send_message(&mut conn, "<dude> hi RAC-loving kikes!")?;
register_user(&mut conn, "dude", "password")?;
send_message_auth(&mut conn, "dude", "password", "my auth message")?;
send_message_spoof_auth(&mut conn, "<dude> this message totally fucks auth system")?;
let (mut all_messages, last_size) = read_messages(&mut conn, 10, 0, false)?.unwrap(); // limits with 10 messages
/* imagine that new messages were written here */
let (mut new_messages, last_size) = read_messages(&mut conn, 10, last_size, true)?.unwrap(); // chunked reading!
all_messages.append(&mut new_messages);
println!("all_messages: {all_messages:?}. last_size: {last_size}");
Ok(())
}

View File

@ -66,25 +66,44 @@ pub struct Config {
pub debug_logs: bool,
}
#[cfg(target_os = "windows")]
pub fn get_config_path() -> PathBuf {
use std::env;
env::var("APPDATA")
.ok()
.and_then(|o| Some(PathBuf::from_str(&o).ok()?.join("bRAC")))
.unwrap_or("bRAC/config.yml".into())
}
let mut config_dir = PathBuf::from_str(".").unwrap();
#[cfg(any(target_os = "macos", target_os = "linux"))]
pub fn get_config_path() -> PathBuf {
use homedir::my_home;
my_home()
.ok()
.flatten()
.map(|o| o.join(".config"))
.map(|o| o.join("bRAC"))
.unwrap_or("bRAC".into())
.join("config.yml")
#[cfg(not(target_os = "windows"))]
if let Some(dir) = {
let home_dir = {
use homedir::my_home;
my_home().ok().flatten()
};
#[cfg(target_os = "linux")]
let config_dir = {
let home_dir = home_dir.map(|o| o.join("bRAC"));
home_dir.map(|o| o.join(".config"))
};
#[cfg(target_os = "macos")]
let config_dir = {
let home_dir = home_dir.map(|o| o.join("bRAC"));
home_dir.map(|o| o.join(".config"))
};
config_dir
} {
config_dir = dir;
}
#[cfg(target_os = "windows")]
if let Some(dir) = {
use std::env;
env::var("APPDATA")
.ok()
.and_then(|o| Some(PathBuf::from_str(&o).ok()?.join("bRAC")))
} {
config_dir = dir;
}
config_dir.join("config.yml")
}
pub fn load_config(path: PathBuf) -> Config {

View File

@ -41,7 +41,6 @@ lazy_static! {
(Regex::new(r"\u{B9AC}\u{3E70}<(.*?)> (.*)").unwrap(), "#70fa7a".to_string()), // bRAC
(Regex::new(r"\u{2550}\u{2550}\u{2550}<(.*?)> (.*)").unwrap(), "#fa7070".to_string()), // CRAB
(Regex::new(r"\u{00B0}\u{0298}<(.*?)> (.*)").unwrap(), "#da70fa".to_string()), // Mefidroniy
(Regex::new(r"\u{2042}<(.*?)> (.*)").unwrap(), "#f5f543".to_string()), // cRACk
(Regex::new(r"<(.*?)> (.*)").unwrap(), "#70fadc".to_string()), // clRAC
];