mirror of
https://github.com/MeexReay/bRAC.git
synced 2025-06-24 10:52:58 +03:00
server list connection now changes mode
This commit is contained in:
parent
ada4d1d181
commit
cdfd16f8c4
@ -26,8 +26,10 @@ use gtk::{
|
||||
Justification, Label, ListBox, Orientation, Overlay, Picture, ScrolledWindow, Settings, Window
|
||||
};
|
||||
|
||||
use crate::proto::parse_rac_url;
|
||||
|
||||
use super::{config::{default_max_messages, default_update_time, get_config_path, save_config, Config},
|
||||
ctx::Context, on_send_message, parse_message, print_message, recv_tick, sanitize_message};
|
||||
ctx::Context, on_send_message, parse_message, print_message, recv_tick, sanitize_message, SERVER_LIST};
|
||||
|
||||
struct UiModel {
|
||||
chat_box: GtkBox,
|
||||
@ -408,7 +410,7 @@ fn build_ui(ctx: Arc<Context>, app: &Application) -> UiModel {
|
||||
|
||||
let server_list = ListBox::new();
|
||||
|
||||
for url in ["rac://meex.lol", "rac://meex.lol:11234", "rac://91.192.22.20"] {
|
||||
for url in SERVER_LIST.iter() {
|
||||
let url = url.to_string();
|
||||
|
||||
let label = Label::builder()
|
||||
@ -422,7 +424,11 @@ fn build_ui(ctx: Arc<Context>, app: &Application) -> UiModel {
|
||||
#[weak] ctx,
|
||||
move |_, _, _, _| {
|
||||
let mut config = ctx.config.read().unwrap().clone();
|
||||
config.host = url.clone();
|
||||
if let Some((_, ssl, wrac)) = parse_rac_url(&url) {
|
||||
config.host = url.clone();
|
||||
config.wrac_enabled = wrac;
|
||||
config.ssl_enabled = ssl;
|
||||
}
|
||||
ctx.set_config(&config);
|
||||
save_config(get_config_path(), &config);
|
||||
}
|
||||
|
@ -15,6 +15,14 @@ use ctx::Context;
|
||||
pub use gui::run_main_loop;
|
||||
|
||||
|
||||
const HELP_MESSAGE: &str = "Help message:
|
||||
/help - show help message
|
||||
/register password - register user
|
||||
/login password - login user
|
||||
/clear n - send empty message n times
|
||||
/spam n text - send message with text n times
|
||||
/ping - check server ping";
|
||||
|
||||
lazy_static! {
|
||||
static ref ANSI_REGEX: Regex = Regex::new(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])").unwrap();
|
||||
static ref CONTROL_CHARS_REGEX: Regex = Regex::new(r"[\x00-\x1F\x7F]").unwrap();
|
||||
@ -28,6 +36,12 @@ lazy_static! {
|
||||
(Regex::new(r"\u{00B0}\u{0298}<(.*?)> (.*)").unwrap(), "magenta".to_string()), // Mefidroniy
|
||||
(Regex::new(r"<(.*?)> (.*)").unwrap(), "cyan".to_string()), // clRAC
|
||||
];
|
||||
|
||||
pub static ref SERVER_LIST: Vec<String> = vec![
|
||||
"rac://meex.lol".to_string(),
|
||||
"rac://meex.lol:11234".to_string(),
|
||||
"rac://91.192.22.20".to_string()
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -35,15 +49,6 @@ pub mod gui;
|
||||
pub mod config;
|
||||
pub mod ctx;
|
||||
|
||||
|
||||
const HELP_MESSAGE: &str = "Help message:
|
||||
/help - show help message
|
||||
/register password - register user
|
||||
/login password - login user
|
||||
/clear n - send empty message n times
|
||||
/spam n text - send message with text n times
|
||||
/ping - check server ping";
|
||||
|
||||
pub fn sanitize_text(input: &str) -> String {
|
||||
let without_ansi = ANSI_REGEX.replace_all(input, "");
|
||||
let cleaned_text = CONTROL_CHARS_REGEX.replace_all(&without_ansi, "");
|
||||
|
Loading…
x
Reference in New Issue
Block a user