diff --git a/Cargo.toml b/Cargo.toml index 4541597..a6fe6b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,3 @@ -[workspace] -members = ["helix", "commands"] -resolver = "2" - [package] name = "botoh" version = "0.1.0" diff --git a/commands/Cargo.toml b/commands/Cargo.toml deleted file mode 100644 index 246cd80..0000000 --- a/commands/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "commands" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/commands/src/main.rs b/commands/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/commands/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} diff --git a/flake.nix b/flake.nix index 3dd1e10..886b784 100644 --- a/flake.nix +++ b/flake.nix @@ -46,7 +46,7 @@ hooks = { # rust rustfmt.enable = true; - clippy.enable = true; + clippy.enable = false; taplo.enable = true; # nix statix.enable = true; diff --git a/helix/Cargo.toml b/helix/Cargo.toml deleted file mode 100644 index e70e9e2..0000000 --- a/helix/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -name = "helix" -version = "0.1.0" -edition = "2021" - -[dependencies] diff --git a/helix/src/main.rs b/helix/src/main.rs deleted file mode 100644 index e7a11a9..0000000 --- a/helix/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("Hello, world!"); -} diff --git a/src/main.rs b/src/main.rs index 3b8d07c..2bb67ba 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,9 @@ use dotenv::dotenv; +use std::collections::HashMap; use std::env; use twitch_irc::login::StaticLoginCredentials; +use twitch_irc::message::ReplyToMessage; +use twitch_irc::message::ServerMessage; use twitch_irc::ClientConfig; use twitch_irc::SecureTCPTransport; use twitch_irc::TwitchIRCClient; @@ -29,15 +32,51 @@ pub async fn main() { let (mut incoming_messages, client) = TwitchIRCClient::::new(config); - let join_handle = - tokio::spawn(async move { while let Some(message) = incoming_messages.recv().await {} }); + let mut initial_channels = HashMap::new(); - client.join("notnotoh".to_owned()).unwrap(); + initial_channels.insert("notnotoh", ()); + initial_channels.insert("notohh", ()); + initial_channels.insert("daph", ()); + initial_channels.insert("ryanpotat", ()); - client - .say("notnotoh".to_owned(), "test".to_owned()) - .await - .unwrap(); + for (channels, _) in initial_channels.iter() { + match client.join(channels.to_owned().to_string()) { + Ok(_) => println!("Joined channels {}", channels), + Err(e) => eprintln!("Failed to join channels! {}", e), + } + } + + let prefix = "?"; + + let join_handle = tokio::spawn(async move { + while let Some(message) = incoming_messages.recv().await { + match message { + ServerMessage::Privmsg(msg) => { + println!( + "(#{}) {}: {}", + msg.channel_login, msg.sender.name, msg.message_text + ); + if msg.sender.name == "notohh" { + match msg.message_text.as_str() { + "?ping" => client + .say(msg.channel_login.to_owned(), "Pong!".to_owned()) + .await + .unwrap(), + "?test" => client + .say(msg.channel_login.to_owned(), "test".to_owned()) + .await + .unwrap(), + _ => {} + } + } + } + ServerMessage::Whisper(msg) => { + println!("(w) {}: {}", msg.sender.name, msg.message_text); + } + _ => {} + } + } + }); join_handle.await.unwrap(); }