marginally better error handling

parent 7f1a8601
......@@ -8,7 +8,7 @@ fn ping(channel: &str, cli: &RtmClient) {
let _ = cli.sender().send_message(channel, "Failsafe is here!");
}
fn failsafe(channel: &str, cli: &RtmClient) {
pub fn failsafe(channel: &str, cli: &RtmClient) {
zeta::send_script();
let (success, message) = zeta::try_start();
......
......@@ -61,22 +61,26 @@ fi
let mut session=Session::new().unwrap();
session.set_host(&HOST).unwrap();
session.parse_config(None).unwrap();
session.connect().unwrap();
session.set_username(&USER).unwrap();
//session.userauth_publickey_auto(None).unwrap();
match session.userauth_password(&PASS) {
Ok(_) => {},
Err(_) => return,
}
{
let mut scp = session.scp_new(
WRITE,
"/Users/jharasym/projects/external/errbot/")
.unwrap();
scp.init().unwrap();
let buf=script.as_bytes().to_vec();
scp.push_file("ensure_alive.sh",buf.len(),0o700).unwrap();
scp.write(&buf).unwrap();
match session.connect() {
Ok(_) => {
session.set_username(&USER).unwrap();
//session.userauth_publickey_auto(None).unwrap();
match session.userauth_password(&PASS) {
Ok(_) => {},
Err(_) => return,
}
{
let mut scp = session.scp_new(
WRITE,
"/Users/jharasym/projects/external/errbot/")
.unwrap();
scp.init().unwrap();
let buf=script.as_bytes().to_vec();
scp.push_file("ensure_alive.sh",buf.len(),0o700).unwrap();
scp.write(&buf).unwrap();
}
},
Err(error) => eprintln!("[✗] failed to transfer script: {:?}", error),
}
}
......
......@@ -50,6 +50,9 @@ impl Handler {
}
let text: String = message_standard.text.unwrap();
if text.contains(&"!failsafe") {
return action::failsafe(&channel, &cli);
}
if !text.contains(bot_id) {
println!("[ℹ] ignoring non-mentioned message");
return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment