update to libcwtch rs 0.6.1

This commit is contained in:
Dan Ballard 2023-09-23 00:10:24 -07:00
parent f704ffc574
commit eaabc81f44
3 changed files with 8 additions and 8 deletions

View File

@ -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"

View File

@ -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<FixedOffset>, 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<FixedOffset>, message: MessageWrapper) {
let response = MessageWrapper {
o: MessageType::TextMessage,
d: message.d,
};

View File

@ -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<FixedOffset>, message: Message) {}
fn on_new_message_from_contact(&self, cwtch: &dyn libcwtch::CwtchLib, profile: &Profile, conversation_id: ConversationID, handle: String, timestamp_received: DateTime<FixedOffset>, 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 => {},