new imp with broken out behaviour
This commit is contained in:
parent
9eba701ec6
commit
7d7dca67c9
|
@ -151,9 +151,9 @@ checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
|
|||
|
||||
[[package]]
|
||||
name = "libcwtch"
|
||||
version = "0.3.0"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25c487f128e73d0c8a18f421f67efa7cf0b3ee913dbd2b1ef49b0854e25abf85"
|
||||
checksum = "82cfe2b14be43f9f77596fa12beb3a12a3e2c12eaa82b25be933d537e6e3d4f9"
|
||||
dependencies = [
|
||||
"hex-literal",
|
||||
"libc",
|
||||
|
|
|
@ -6,7 +6,7 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
libcwtch = "0.3.0"
|
||||
libcwtch = "0.3.2"
|
||||
imp = {path = "../imp"}
|
||||
serde_json = "1.0"
|
||||
|
||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -1,22 +1,21 @@
|
|||
extern crate core;
|
||||
|
||||
use std::borrow::{Borrow, BorrowMut};
|
||||
use std::collections::HashMap;
|
||||
use std::borrow::{BorrowMut};
|
||||
use std::fs::read_dir;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::thread;
|
||||
|
||||
use ::imp::event::Event;
|
||||
use ::imp::imp;
|
||||
use ::imp::imp::EventHandler;
|
||||
use ::imp::imp::NewContactPolicy;
|
||||
use ::imp::behaviour;
|
||||
use ::imp::behaviour::BehaviourBuilder;
|
||||
use ::imp::behaviour::Behaviour;
|
||||
use ::imp::imp::Imp;
|
||||
use libcwtch;
|
||||
use libcwtch::CwtchLib;
|
||||
use libcwtch::structs::*;
|
||||
use serde_json;
|
||||
|
||||
use crate::imp::{Behaviour, BehaviourBuilder, Imp};
|
||||
|
||||
const DIST_DIR: &str = "cwtch_dist";
|
||||
const BOT_HOME: &str = "~/.cwtch/bots/update_bot";
|
||||
const PASSWORD: &str = "be gay do crime";
|
||||
|
@ -72,7 +71,7 @@ fn main() {
|
|||
}
|
||||
|
||||
let mut update_bot = UpdateBot::new();
|
||||
let behaviour: Behaviour = BehaviourBuilder::new().name(BOT_NAME.to_string()).profile_pic_path("build_bot.png".to_string()).new_contact_policy(imp::NewContactPolicy::Accept).build();
|
||||
let behaviour: Behaviour = BehaviourBuilder::new().name(BOT_NAME.to_string()).profile_pic_path("build_bot.png".to_string()).new_contact_policy(behaviour::NewContactPolicy::Accept).build();
|
||||
|
||||
let event_loop_handle = thread::spawn(move || {
|
||||
let mut bot = Imp::spawn(behaviour, PASSWORD.to_string(), BOT_HOME.to_string());
|
||||
|
@ -96,7 +95,7 @@ impl UpdateBot {
|
|||
Some(last_offered) => last_offered != self.version,
|
||||
None => true,
|
||||
},
|
||||
Err(e) => false
|
||||
Err(_) => false
|
||||
};
|
||||
if do_offer {
|
||||
self.offer(cwtch, profile_opt, convo_id);
|
||||
|
@ -148,7 +147,7 @@ impl imp::EventHandler for UpdateBot {
|
|||
};
|
||||
}
|
||||
}
|
||||
Event::NewMessageFromPeer { conversation_id, handle, timestamp_received, message } => {
|
||||
Event::NewMessageFromPeer { conversation_id, handle: _, timestamp_received: _, message } => {
|
||||
match profile_opt {
|
||||
Some(profile) => {
|
||||
let from = profile.handle.as_str();
|
||||
|
@ -186,7 +185,7 @@ impl imp::EventHandler for UpdateBot {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
Event::ErrUnhandled { name, data } => eprintln!("unhandled event: {}!", name),
|
||||
Event::ErrUnhandled { name, data: _ } => eprintln!("unhandled event: {}!", name),
|
||||
_ => ()
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue