From c2fe4dc663aa000efd39f19c315fbd5dac821f84 Mon Sep 17 00:00:00 2001 From: notohh Date: Fri, 7 Jun 2024 23:02:41 -0400 Subject: [PATCH] add commands folder --- src/commands/mod.rs | 2 ++ src/{commands.rs => commands/ping.rs} | 13 +------------ src/commands/test.rs | 16 ++++++++++++++++ src/main.rs | 8 ++++---- 4 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 src/commands/mod.rs rename src/{commands.rs => commands/ping.rs} (74%) create mode 100644 src/commands/test.rs diff --git a/src/commands/mod.rs b/src/commands/mod.rs new file mode 100644 index 0000000..f458a8d --- /dev/null +++ b/src/commands/mod.rs @@ -0,0 +1,2 @@ +pub mod ping; +pub mod test; diff --git a/src/commands.rs b/src/commands/ping.rs similarity index 74% rename from src/commands.rs rename to src/commands/ping.rs index abe288e..7ccb96c 100644 --- a/src/commands.rs +++ b/src/commands/ping.rs @@ -5,7 +5,7 @@ use twitch_irc::{ login::StaticLoginCredentials, message::PrivmsgMessage, SecureTCPTransport, TwitchIRCClient, }; -pub async fn ping(m: &PrivmsgMessage) { +pub async fn ping_command(m: &PrivmsgMessage) { let client = create_client(); let (mut _incoming_messages, client) = @@ -30,14 +30,3 @@ pub async fn ping(m: &PrivmsgMessage) { let _message = client.say(m.channel_login.to_owned(), s.to_owned()).await; } } - -pub async fn test(m: &PrivmsgMessage) { - let client = create_client(); - - let (mut _incoming_messages, client) = - TwitchIRCClient::::new(client); - - let _message = client - .say(m.channel_login.to_owned(), "test".to_owned()) - .await; -} diff --git a/src/commands/test.rs b/src/commands/test.rs new file mode 100644 index 0000000..3470604 --- /dev/null +++ b/src/commands/test.rs @@ -0,0 +1,16 @@ +use crate::client::create_client; +use sysinfo::System; + +use twitch_irc::{ + login::StaticLoginCredentials, message::PrivmsgMessage, SecureTCPTransport, TwitchIRCClient, +}; + +pub async fn test_command(m: &PrivmsgMessage) { + let client = create_client(); + + let (mut _incoming_messages, client) = + TwitchIRCClient::::new(client); + let _message = client + .say(m.channel_login.to_owned(), "test".to_owned()) + .await; +} diff --git a/src/main.rs b/src/main.rs index b3d2d33..d3647f6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use client::create_client; -use commands::*; +use commands::ping::ping_command; +use commands::test::test_command; use std::collections::HashMap; use twitch_irc::{ @@ -21,7 +22,6 @@ pub async fn main() { initial_channels.insert("notnotoh", ()); initial_channels.insert("notohh", ()); initial_channels.insert("daph", ()); - initial_channels.insert("ryanpotat", ()); for (channels, _) in initial_channels.iter() { match client.join(channels.to_owned().to_string()) { @@ -40,8 +40,8 @@ pub async fn main() { ); if msg.sender.name == "notohh" { match msg.message_text.as_str() { - "*ping" => ping(&msg).await, - "*test" => test(&msg).await, + "*ping" => ping_command(&msg).await, + "*test" => test_command(&msg).await, _ => {} } }