summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bot/music.rs3
-rw-r--r--src/main.rs29
2 files changed, 25 insertions, 7 deletions
diff --git a/src/bot/music.rs b/src/bot/music.rs
index 821087c..dee1514 100644
--- a/src/bot/music.rs
+++ b/src/bot/music.rs
@@ -368,6 +368,7 @@ impl MusicBot {
}
fn spawn_stdin_reader(tx: Arc<Mutex<UnboundedSender<MusicBotMessage>>>) {
+ debug!("Spawning stdin reader thread");
thread::spawn(move || {
let stdin = ::std::io::stdin();
let lock = stdin.lock();
@@ -375,7 +376,7 @@ fn spawn_stdin_reader(tx: Arc<Mutex<UnboundedSender<MusicBotMessage>>>) {
let line = line.unwrap();
let message = MusicBotMessage::TextMessage(Message {
- target: MessageTarget::Server,
+ target: MessageTarget::Channel,
invoker: Invoker {
name: String::from("stdin"),
id: ClientId(0),
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()