mirror of
https://github.com/MeexReay/bRAC.git
synced 2025-06-24 10:52:58 +03:00
Compare commits
8 Commits
c3982a211c
...
5b23a3bd70
Author | SHA1 | Date | |
---|---|---|---|
5b23a3bd70 | |||
c8b2c7e541 | |||
![]() |
80e7b8c506 | ||
![]() |
aaee249f56 | ||
![]() |
9675dfe87f | ||
![]() |
32cf3839bf | ||
![]() |
5029b51cf6 | ||
![]() |
c9673807d9 |
@ -87,6 +87,7 @@ 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)
|
||||
|
60
docs/crate.md
Normal file
60
docs/crate.md
Normal file
@ -0,0 +1,60 @@
|
||||
# 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)
|
@ -11,6 +11,7 @@ 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
|
||||
|
23
examples/protocol.rs
Normal file
23
examples/protocol.rs
Normal file
@ -0,0 +1,23 @@
|
||||
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(())
|
||||
}
|
@ -66,44 +66,25 @@ pub struct Config {
|
||||
pub debug_logs: bool,
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn get_config_path() -> PathBuf {
|
||||
let mut config_dir = PathBuf::from_str(".").unwrap();
|
||||
use std::env;
|
||||
env::var("APPDATA")
|
||||
.ok()
|
||||
.and_then(|o| Some(PathBuf::from_str(&o).ok()?.join("bRAC")))
|
||||
.unwrap_or("bRAC/config.yml".into())
|
||||
}
|
||||
|
||||
#[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")
|
||||
#[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")
|
||||
}
|
||||
|
||||
pub fn load_config(path: PathBuf) -> Config {
|
||||
|
@ -41,6 +41,7 @@ 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
|
||||
];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user