diff --git a/Cargo.toml b/Cargo.toml index d90206c..e5860d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 = "0.4.2" +libcwtch = "0.6.1" chrono = "0.4.19" diff --git a/examples/echobot.rs b/examples/echobot.rs index 595c95c..3fe9e79 100644 --- a/examples/echobot.rs +++ b/examples/echobot.rs @@ -26,8 +26,8 @@ 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: Message) { - let response = Message { + 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, }; diff --git a/src/imp.rs b/src/imp.rs index 4fa6d04..908512a 100644 --- a/src/imp.rs +++ b/src/imp.rs @@ -17,7 +17,7 @@ pub trait EventHandler { #[allow(unused_variables)] fn on_new_contact(&self, cwtch: &dyn libcwtch::CwtchLib, profile: &Profile, convo_id: ConversationID) {} #[allow(unused_variables)] - fn on_new_message_from_contact(&self, cwtch: &dyn libcwtch::CwtchLib, profile: &Profile, conversation_id: ConversationID, handle: String, timestamp_received: DateTime, message: Message) {} + fn on_new_message_from_contact(&self, cwtch: &dyn libcwtch::CwtchLib, profile: &Profile, conversation_id: ConversationID, handle: String, timestamp_received: DateTime, message: MessageWrapper) {} } /// Cwtch bot @@ -145,10 +145,10 @@ impl Imp { self.profile = Some(ok_profile.clone()); } } - Event::AppError { error } => { + Event::AppError { error, data } => { if initialized && error == "Loaded 0 profiles" { self.cwtch - .create_profile(&self.behaviour.profile_name, &self.password); + .create_profile(&self.behaviour.profile_name, &self.password, true); } } Event::ContactCreated {profile_id, conversation_id, contact_id, nick, status, unread, picture, default_picture, num_messages, accepted, access_control_list, blocked, loading, last_msg_time, .. } => { @@ -214,7 +214,7 @@ impl Imp { self.cwtch .accept_conversation(&profile.profile_id, conversation_id); } - NewContactPolicy::Block => self.cwtch.block_contact(&profile_handle.clone(), conversation_id), + NewContactPolicy::Block => self.cwtch.block_conversation(&profile_handle.clone(), conversation_id), NewContactPolicy::AllowList(allow_list) => { match profile.conversations.get(&conversation_id) { Some(conversation) => { @@ -222,7 +222,7 @@ impl Imp { self.cwtch .accept_conversation(&profile_handle.clone(), conversation_id); } else { - self.cwtch.block_contact(&profile_handle.clone(), conversation_id); + self.cwtch.block_conversation(&profile_handle.clone(), conversation_id); } }, None => {},