add commands folder

This commit is contained in:
notohh 2024-06-07 23:02:41 -04:00
parent 3aa541c3e2
commit c2fe4dc663
Signed by: notohh
GPG key ID: BD47506D475EE86D
4 changed files with 23 additions and 16 deletions

2
src/commands/mod.rs Normal file
View file

@ -0,0 +1,2 @@
pub mod ping;
pub mod test;

View file

@ -5,7 +5,7 @@ use twitch_irc::{
login::StaticLoginCredentials, message::PrivmsgMessage, SecureTCPTransport, TwitchIRCClient, login::StaticLoginCredentials, message::PrivmsgMessage, SecureTCPTransport, TwitchIRCClient,
}; };
pub async fn ping(m: &PrivmsgMessage) { pub async fn ping_command(m: &PrivmsgMessage) {
let client = create_client(); let client = create_client();
let (mut _incoming_messages, 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; 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::<SecureTCPTransport, StaticLoginCredentials>::new(client);
let _message = client
.say(m.channel_login.to_owned(), "test".to_owned())
.await;
}

16
src/commands/test.rs Normal file
View file

@ -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::<SecureTCPTransport, StaticLoginCredentials>::new(client);
let _message = client
.say(m.channel_login.to_owned(), "test".to_owned())
.await;
}

View file

@ -1,5 +1,6 @@
use client::create_client; use client::create_client;
use commands::*; use commands::ping::ping_command;
use commands::test::test_command;
use std::collections::HashMap; use std::collections::HashMap;
use twitch_irc::{ use twitch_irc::{
@ -21,7 +22,6 @@ pub async fn main() {
initial_channels.insert("notnotoh", ()); initial_channels.insert("notnotoh", ());
initial_channels.insert("notohh", ()); initial_channels.insert("notohh", ());
initial_channels.insert("daph", ()); initial_channels.insert("daph", ());
initial_channels.insert("ryanpotat", ());
for (channels, _) in initial_channels.iter() { for (channels, _) in initial_channels.iter() {
match client.join(channels.to_owned().to_string()) { match client.join(channels.to_owned().to_string()) {
@ -40,8 +40,8 @@ pub async fn main() {
); );
if msg.sender.name == "notohh" { if msg.sender.name == "notohh" {
match msg.message_text.as_str() { match msg.message_text.as_str() {
"*ping" => ping(&msg).await, "*ping" => ping_command(&msg).await,
"*test" => test(&msg).await, "*test" => test_command(&msg).await,
_ => {} _ => {}
} }
} }