From d62cffca6698e048a7cc461bfccb3eff51439ce5 Mon Sep 17 00:00:00 2001 From: Dan Ballard Date: Sat, 24 Feb 2024 19:32:40 -0800 Subject: [PATCH] cleanup echobot warnings; update to libcwtch-rs 0.8.0 --- Cargo.toml | 4 ++-- examples/echobot.rs | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 99efc8c..b408e32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cwtch-imp" -version = "0.2.3" +version = "0.3.0" edition = "2021" license = "MIT" description = "small demon, a familiar of a witch. imp is a set of bot creating utilities built on top of libcwtch-rs" @@ -12,5 +12,5 @@ documentation = "https://docs.rs/cwtch-imp/" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libcwtch = {path = "./../libcwtch-rs"} # "0.7.0" +libcwtch = "0.8.0" chrono = "0.4.19" diff --git a/examples/echobot.rs b/examples/echobot.rs index 3fe9e79..405594b 100644 --- a/examples/echobot.rs +++ b/examples/echobot.rs @@ -16,7 +16,7 @@ const BOT_NAME: &str = "echobot"; struct Echobot {} fn main() { - let behaviour: Behaviour = BehaviourBuilder::new().name(BOT_NAME.to_string()).new_contact_policy(NewContactPolicy::Accept).build(); + let behaviour: Behaviour = BehaviourBuilder::new().name(BOT_NAME.to_string()).new_contact_policy(NewContactPolicy::Accept).contact_interaction_policy(ContactInteractionPolicy::Accept).build(); let event_loop_handle = thread::spawn(move || { let mut echobot = Echobot {}; let mut bot = Imp::spawn(behaviour, PASSWORD.to_string(), BOT_HOME.to_string()); @@ -26,17 +26,19 @@ fn main() { } impl imp::EventHandler for Echobot { - fn on_new_message_from_contact(&self, cwtch: &dyn libcwtch::CwtchLib, profile: &Profile, conversation_id: ConversationID, handle: String, timestamp_received: DateTime, message: MessageWrapper) { + fn on_new_message_from_contact(&self, cwtch: &dyn libcwtch::CwtchLib, profile: &Profile, conversation_id: ConversationID, _handle: String, _timestamp_received: DateTime, message: MessageWrapper) { let response = MessageWrapper { o: MessageType::TextMessage, d: message.d, }; - cwtch.send_message(&profile.profile_id, conversation_id, &response); + if let Err(e) = cwtch.send_message(&profile.profile_id, conversation_id, &response) { + println!("Error sending message: {}", e.to_string()); + } } - fn handle(&mut self, cwtch: &dyn CwtchLib, profile_opt: Option<&Profile>, event: &Event) { + fn handle(&mut self, _cwtch: &dyn CwtchLib, _profile_opt: Option<&Profile>, event: &Event) { match event { - Event::NewPeer { profile_id, tag, created, name, default_picture, picture, online, profile_data } => { + Event::NewPeer { profile_id, tag: _, created: _, name, default_picture: _, picture: _, online: _, profile_data: _ } => { println!( "\n***** {} at {} *****\n", name, profile_id.as_str()