diff options
| author | Jokler <jokler@protonmail.com> | 2020-01-28 18:42:33 +0100 |
|---|---|---|
| committer | Jokler <jokler@protonmail.com> | 2020-01-29 20:39:27 +0100 |
| commit | 33f9989df92deebf589b1d0384a6fe485a5492d9 (patch) | |
| tree | da2814260b808809627aebf9029586767f44e129 /src/main.rs | |
| parent | 1e00d60298697e7443f66ad7a63bc0492bb8072f (diff) | |
| download | pokebot-33f9989df92deebf589b1d0384a6fe485a5492d9.tar.gz pokebot-33f9989df92deebf589b1d0384a6fe485a5492d9.zip | |
Make local mode spawn a music bot directly
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index 7f6fbf4..922162f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,6 @@ use std::io::{Read, Write}; use std::path::PathBuf; use futures::future::{FutureExt, TryFutureExt}; -use futures01::future::Future as Future01; use log::{debug, info}; use structopt::clap::AppSettings; use structopt::StructOpt; @@ -16,7 +15,7 @@ mod playlist; mod teamspeak; mod youtube_dl; -use bot::{MasterArgs, MasterBot}; +use bot::{MasterArgs, MasterBot, MusicBot, MusicBotArgs}; #[derive(StructOpt, Debug)] #[structopt(raw(global_settings = "&[AppSettings::ColoredHelp]"))] @@ -69,8 +68,6 @@ fn main() { fn run() -> Result<(), Box<dyn std::error::Error>> { log4rs::init_file("log4rs.yml", Default::default()).unwrap(); - info!("Starting PokeBot!"); - // Parse command line options let args = Args::from_args(); @@ -95,12 +92,32 @@ fn run() -> Result<(), Box<dyn std::error::Error>> { let bot_args = config.merge(args); + info!("Starting PokeBot!"); debug!("Received CLI arguments: {:?}", std::env::args()); tokio::run( async { - let (_, fut) = MasterBot::new(bot_args).await; - tokio::spawn(fut.unit_error().boxed().compat().map(|_| ())); + if bot_args.local { + let name = bot_args.names[0].clone(); + let id = bot_args.ids[0].clone(); + + let disconnect_cb = Box::new(move |_, _, _| {}); + + let bot_args = MusicBotArgs { + name: name, + name_index: 0, + id_index: 0, + local: true, + address: bot_args.address.clone(), + id, + channel: String::from("local"), + verbose: bot_args.verbose, + disconnect_cb, + }; + MusicBot::new(bot_args).await.1.await; + } else { + MasterBot::new(bot_args).await.1.await; + } } .unit_error() .boxed() |
