mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-08-12 10:03:13 +00:00
Update ChatCLI
This commit is contained in:
parent
06b43748da
commit
7265ab1109
@ -19,6 +19,7 @@ arboard = "3"
|
||||
base64 = "0.22"
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
crossterm = "0.29"
|
||||
hex = "0.4.3"
|
||||
ratatui = "0.29"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
||||
@ -256,7 +256,8 @@ where
|
||||
Ok(Some("Help displayed".to_string()))
|
||||
}
|
||||
"/intro" => {
|
||||
let address = self.client.addr().to_string();
|
||||
// The address is bytes; hex is the shareable form users paste.
|
||||
let address = hex::encode(self.client.addr());
|
||||
self.add_system_message("── Your Address ──");
|
||||
self.add_system_message(&address);
|
||||
let clipboard_msg = match Clipboard::new().and_then(|mut cb| cb.set_text(&address))
|
||||
@ -271,10 +272,13 @@ where
|
||||
if args.is_empty() {
|
||||
return Ok(Some("Usage: /connect <address>".to_string()));
|
||||
}
|
||||
let Ok(address) = hex::decode(args) else {
|
||||
return Ok(Some("Address must be hex".to_string()));
|
||||
};
|
||||
let initial = format!("Hello from {}!", self.user_name);
|
||||
let chat_id = self
|
||||
.client
|
||||
.create_direct_conversation(args)
|
||||
.create_direct_conversation(&address)
|
||||
.map_err(|e| anyhow::anyhow!("{e:?}"))?;
|
||||
self.client
|
||||
.send_message(&chat_id, initial.as_bytes())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user