first commit
This commit is contained in:
15
.gitignore
vendored
Normal file
15
.gitignore
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# ---> Rust
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
.idea/
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||
Cargo.lock
|
||||
src/variables.rs
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
10
Cargo.toml
Normal file
10
Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "twitchBot"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
tokio = { version = "1.27.0", features = ["full"] }
|
||||
rand = "0.8.5"
|
||||
2
README.md
Normal file
2
README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# Just super dank twitch bot
|
||||
But it's not another js bot... IT's RUST BOT! and it still doesn't change anything :)
|
||||
0
src/commands/aha.rs
Normal file
0
src/commands/aha.rs
Normal file
75
src/main.rs
Normal file
75
src/main.rs
Normal file
@@ -0,0 +1,75 @@
|
||||
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
|
||||
use tokio::net::TcpStream;
|
||||
|
||||
mod variables;
|
||||
use variables::{CHANNEL, CHANNEL2, PASSWORD, USERNAME};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let stream = TcpStream::connect("irc.chat.twitch.tv:6667").await.unwrap();
|
||||
let (reader, mut writer) = tokio::io::split(stream);
|
||||
let mut reader = BufReader::new(reader);
|
||||
writer
|
||||
.write_all(format!("PASS {}\r\n", PASSWORD).as_bytes())
|
||||
.await
|
||||
.unwrap();
|
||||
writer
|
||||
.write_all(format!("NICK {}\r\n", USERNAME).as_bytes())
|
||||
.await
|
||||
.unwrap();
|
||||
writer
|
||||
.write_all(format!("JOIN #{}\r\n", CHANNEL).as_bytes())
|
||||
.await
|
||||
.unwrap();
|
||||
writer
|
||||
.write_all(format!("JOIN #{}\r\n", CHANNEL2).as_bytes())
|
||||
.await
|
||||
.unwrap();
|
||||
writer
|
||||
.write_all(format!("PRIVMSG #{} :RalpherZ\r\n", CHANNEL).as_bytes())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
loop {
|
||||
let mut message = String::new();
|
||||
reader.read_line(&mut message).await;
|
||||
println!("{}", message);
|
||||
|
||||
// Respond to PING messages to avoid being disconnected
|
||||
if message.contains("PING") {
|
||||
writer.write_all(b"PONG\r\n").await.unwrap();
|
||||
}
|
||||
|
||||
if message.starts_with("Welcome ") {
|
||||
writer
|
||||
.write_all(format!("PRIVMSG #{} :huj!\r\n", CHANNEL).as_bytes())
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
if message.contains("!e") {
|
||||
writer
|
||||
.write_all(format!("PRIVMSG #{} :hujj!\r\n", CHANNEL).as_bytes())
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
if message.contains("!jo") {
|
||||
writer
|
||||
.write_all(format!("PRIVMSG #{} :jkhghjkghjkgjl!\r\n", CHANNEL).as_bytes())
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
if message.contains("!ping") {
|
||||
writer
|
||||
.write_all(format!("PRIVMSG #{} :pong!\r\n", CHANNEL).as_bytes())
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let response = "This is a response with multiple words.";
|
||||
if message.contains("!ayo") {
|
||||
writer.write_all(format!("PRIVMSG #{} :{}\r\n", CHANNEL, response).as_bytes()).await.unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user