0.2.2: protect create profile with check if one is set as sometimes we still get AppError 0 loaded
This commit is contained in:
parent
0be1b63047
commit
a7fa18b5ff
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "cwtch-imp"
|
name = "cwtch-imp"
|
||||||
version = "0.2.1"
|
version = "0.2.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
description = "small demon, a familiar of a witch. imp is a set of bot creating utilities built on top of libcwtch-rs"
|
description = "small demon, a familiar of a witch. imp is a set of bot creating utilities built on top of libcwtch-rs"
|
||||||
|
|
17
src/imp.rs
17
src/imp.rs
|
@ -63,15 +63,11 @@ impl Imp {
|
||||||
|
|
||||||
match &event {
|
match &event {
|
||||||
Event::CwtchStarted => {
|
Event::CwtchStarted => {
|
||||||
println!("event CwtchStarted!");
|
println!("Cwtch Started");
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
match self.profile {
|
if self.profile.is_none() {
|
||||||
None => {
|
self.cwtch.load_profiles(&self.password);
|
||||||
println!("Creating bot");
|
|
||||||
self.cwtch.load_profiles(&self.password);
|
|
||||||
}
|
|
||||||
Some(_) => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::UpdateGlobalSettings { settings } => {
|
Event::UpdateGlobalSettings { settings } => {
|
||||||
|
@ -108,7 +104,6 @@ impl Imp {
|
||||||
self.settings = Some(local_settings);
|
self.settings = Some(local_settings);
|
||||||
}
|
}
|
||||||
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} => {
|
||||||
|
|
||||||
if let Err(e) = profile_data {
|
if let Err(e) = profile_data {
|
||||||
panic!("error parsing profile: {}", e);
|
panic!("error parsing profile: {}", e);
|
||||||
}
|
}
|
||||||
|
@ -147,8 +142,10 @@ impl Imp {
|
||||||
}
|
}
|
||||||
Event::AppError { error, data } => {
|
Event::AppError { error, data } => {
|
||||||
if initialized && error == "Loaded 0 profiles" {
|
if initialized && error == "Loaded 0 profiles" {
|
||||||
self.cwtch
|
if self.profile.is_none() {
|
||||||
.create_profile(&self.behaviour.profile_name, &self.password, true);
|
self.cwtch
|
||||||
|
.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, .. } => {
|
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, .. } => {
|
||||||
|
|
Loading…
Reference in New Issue