bhcli

A TUI for chatting on LE PHP Chats (onion)
git clone https://git.dasho.dev/n0tr1v/bhcli.git
Log | Files | Refs | README

commit ec22acbd5c878c50e60e191387f113273692c2ef
parent 4c483a308e132e806ef2b56bb8adb136728e02ad
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Fri,  7 Feb 2025 20:51:25 -0800

/inc to toggle incognito mode

Diffstat:
Msrc/main.rs | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -937,6 +937,8 @@ impl LeChatPHPClient { // Change nickname let new_nickname = captures[1].to_owned(); self.post_msg(PostType::NewNickname(new_nickname)).unwrap(); + } else if input == "/inc" { + self.post_msg(PostType::Incognito).unwrap(); } else if let Some(captures) = NEW_COLOR_RGX.captures(&input) { // Change color let new_color = captures[1].to_owned(); @@ -1179,6 +1181,7 @@ fn set_profile_base_info( let bold = doc.find(Attr("id", "bold")).next().unwrap(); let italic = doc.find(Attr("id", "italic")).next().unwrap(); let small = doc.find(Attr("id", "small")).next().unwrap(); + let incognito = doc.find(Attr("name", "incognito")).next().unwrap(); if bold.attr("checked").is_some() { params.push(("bold", "on".to_owned())); } @@ -1188,6 +1191,9 @@ fn set_profile_base_info( if small.attr("checked").is_some() { params.push(("small", "on".to_owned())); } + if incognito.attr("checked").is_some() { + params.push(("incognito", "on".to_owned())); + } let font_select = doc.find(Attr("name", "font")).next().unwrap(); let font = font_select.find(Name("option")).find_map(|el| { if el.attr("selected").is_some() { @@ -1263,6 +1269,18 @@ fn post_msg(client: &Client, post_type_recv: PostType, full_url: &str, session: ("newnickname", new_nickname), ]); } + PostType::Incognito => { + set_profile_base_info(&client, full_url, &mut params)?; + if params.iter().any(|(key, _)| *key == "incognito") { + params.retain(|(key, _)| *key != "incognito"); + } else { + params.push(("incognito", "on".to_owned())); + } + params.extend(vec![ + ("do", "save".to_owned()), + ("timestamps", "on".to_owned()), + ]); + } PostType::NewColor(new_color) => { set_profile_base_info(&client, full_url, &mut params)?; params.extend(vec![ @@ -1949,6 +1967,7 @@ enum PostType { Upload(String, String, String), // FilePath, SendTo, Message DeleteLast, // DeleteLast DeleteAll, // DeleteAll + Incognito, // Toggle incognito NewNickname(String), // NewUsername NewColor(String), // NewColor Profile(String, String), // NewColor, NewUsername