bhcli

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

commit 84dc243837ec5f1d5381f461b04033b7b127bf95
parent cb141a849ed6414526e4b22faf87b20a1630c878
Author: Dasho <git@dasho.dev>
Date:   Sat, 19 Jul 2025 16:17:50 +0100

feat(chat logging): Add feature to save the chat log to /home/<user>/.config/bhcli/chat-log.txt

This update now saves the entire chat history (for which you're online for) to a file in the bhcli config directory. This allows for review after the fact and stronger moderation understanding.

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

diff --git a/src/main.rs b/src/main.rs @@ -37,6 +37,7 @@ use serde_derive::{Deserialize, Serialize}; use std::collections::HashMap; use std::io::Cursor; use std::io::{self, Write}; +use std::fs::OpenOptions; use std::process::Command; use std::sync::Mutex; use std::sync::{Arc, MutexGuard}; @@ -2222,6 +2223,7 @@ fn process_new_messages( && !(new_msg.date == last_known_msg.date && last_known_msg.text == new_msg.text) }); for new_msg in filtered { + log_chat_message(new_msg); if let Some((from, to_opt, msg)) = get_message(&new_msg.text, members_tag) { // Notify when tagged if msg.contains(format!("@{}", &username).as_str()) { @@ -2334,6 +2336,17 @@ fn update_messages( messages.truncate(1000); } +fn log_chat_message(msg: &Message) { + if let Ok(path) = confy::get_configuration_file_path("bhcli", None) { + if let Some(dir) = path.parent() { + let log_path = dir.join("chat-log.txt"); + if let Ok(mut f) = OpenOptions::new().create(true).append(true).open(log_path) { + let _ = writeln!(f, "{} - {}", msg.date, msg.text.text()); + } + } + } +} + fn delete_message( client: &Client, full_url: &str,