bhcli

"Strange's fork of n0tr1v's bhcli (onion)"
git clone https://git.dasho.dev/Strange/bhcli.git
Log | Files | Refs | README

commit b71d8efacae301778adb8e7dbc590c905bed6175
parent 9380ca9e23317359377fd2f9723976d4656a4fba
Author: Strange <StrangeGuy6228@protonmail.com>
Date:   Mon, 25 Dec 2023 18:52:02 +0530

added functionality \(local upload msg edit, not on server side\)

Diffstat:
MCargo.toml | 5+++--
Msrc/main.rs | 29++++++++++++++++++++++++++++-
2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml @@ -3,6 +3,8 @@ name = "bhcli" version = "0.1.0" edition = "2018" +[profile.dev] +debug = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -36,4 +38,4 @@ termage = "1.1.1" textwrap = "0.16.0" toml = "0.7.3" tui = { version = "0.19.0", features = ["crossterm"], default-features = false } -unicode-width = "0.1.8" -\ No newline at end of file +unicode-width = "0.1.8" diff --git a/src/main.rs b/src/main.rs @@ -641,6 +641,7 @@ impl LeChatPHPClient { KeyEvent { code: KeyCode::Char('t'), modifiers: KeyModifiers::NONE, .. } => self.handle_normal_mode_key_event_tag(app), KeyEvent { code: KeyCode::Char('p'), modifiers: KeyModifiers::NONE, .. } => self.handle_normal_mode_key_event_pm(app), KeyEvent { code: KeyCode::Char('k'), modifiers: KeyModifiers::CONTROL, .. } => self.handle_normal_mode_key_event_kick(app), + KeyEvent { code: KeyCode::Char('w'), modifiers: KeyModifiers::CONTROL, .. } => self.handle_normal_mode_key_event_warn(app), KeyEvent { code: KeyCode::Char('u'), modifiers: KeyModifiers::CONTROL, .. } | KeyEvent { code: KeyCode::PageUp, modifiers: KeyModifiers::NONE, .. } => self.handle_normal_mode_key_event_page_up(app), KeyEvent { code: KeyCode::Char('d'), modifiers: KeyModifiers::CONTROL, .. } | @@ -895,6 +896,20 @@ impl LeChatPHPClient { } } + fn handle_normal_mode_key_event_warn(&mut self, app: &mut App) { + if let Some(idx) = app.items.state.selected() { + if let Some(username) = get_username( + &self.base_client.username, + &app.items.items.get(idx).unwrap().text, + &self.config.members_tag, + ) { + app.input = format!("!warn {} ", username); + app.input_idx = app.input.width(); + app.input_mode = InputMode::Editing; + app.items.unselect(); + } + } + } fn handle_normal_mode_key_event_page_up(&mut self, app: &mut App) { if let Some(idx) = app.items.state.selected() { app.items.state.select(idx.checked_sub(10).or(Some(0))); @@ -1021,7 +1036,19 @@ impl LeChatPHPClient { }; self.post_msg(PostType::Upload(file_path, send_to, msg)) .unwrap(); - } else { + } + else if input.starts_with("!warn") { + // StrangeEdit + let msg: String = input + .find('@') + .map(|index| input[index..].to_string()) + .unwrap_or_else(String::new); + + let end_msg = format!("This is your warning - {}, will be kicked next !rules",msg); + log::error!("The Strange end_msg is :{}",end_msg); + self.post_msg(PostType::Post(end_msg,None)).unwrap(); + } + else { if input.starts_with("/") && !input.starts_with("/me ") { app.input_idx = input.len(); app.input = input;