remove console-subscriber
This commit is contained in:
parent
e83c9ac4e0
commit
5968c71d22
4 changed files with 147 additions and 541 deletions
651
Cargo.lock
generated
651
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -4,7 +4,6 @@ version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
console-subscriber = "0.3.0"
|
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
log = "0.4.21"
|
log = "0.4.21"
|
||||||
pretty_env_logger = "0.5.0"
|
pretty_env_logger = "0.5.0"
|
||||||
|
|
|
@ -38,7 +38,6 @@ in {
|
||||||
wantedBy = ["multi-user.target"];
|
wantedBy = ["multi-user.target"];
|
||||||
environment = {
|
environment = {
|
||||||
RUST_LOG = cfg.log_level;
|
RUST_LOG = cfg.log_level;
|
||||||
RUSTFLAGS = "--cfg tokio_unstable";
|
|
||||||
};
|
};
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
EnvironmentFile = cfg.environmentFiles;
|
EnvironmentFile = cfg.environmentFiles;
|
||||||
|
|
35
src/main.rs
35
src/main.rs
|
@ -20,7 +20,6 @@ extern crate pretty_env_logger;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
pub async fn main() {
|
pub async fn main() {
|
||||||
console_subscriber::init();
|
|
||||||
pretty_env_logger::try_init().expect("Failed to load logger");
|
pretty_env_logger::try_init().expect("Failed to load logger");
|
||||||
let mut client = client();
|
let mut client = client();
|
||||||
|
|
||||||
|
@ -36,11 +35,11 @@ pub async fn main() {
|
||||||
let message_handler = tokio::spawn(async move {
|
let message_handler = tokio::spawn(async move {
|
||||||
while let Some(message) = client.incoming_messages.recv().await {
|
while let Some(message) = client.incoming_messages.recv().await {
|
||||||
match message {
|
match message {
|
||||||
ServerMessage::Privmsg(msg) => {
|
ServerMessage::Privmsg(m) => {
|
||||||
let is_moderator = msg.badges.iter().any(|badge| badge.name == "moderator");
|
let is_moderator = m.badges.iter().any(|badge| badge.name == "moderator");
|
||||||
let channel = msg.channel_login.clone();
|
let channel = m.channel_login.clone();
|
||||||
let sender = msg.sender.name.clone();
|
let sender = m.sender.name.clone();
|
||||||
let contents = msg.message_text.clone();
|
let contents = m.message_text.clone();
|
||||||
let prefix = "*";
|
let prefix = "*";
|
||||||
|
|
||||||
println!("(#{}) {}: {}", &channel, &sender, &contents);
|
println!("(#{}) {}: {}", &channel, &sender, &contents);
|
||||||
|
@ -53,58 +52,58 @@ pub async fn main() {
|
||||||
match command {
|
match command {
|
||||||
"ping" => {
|
"ping" => {
|
||||||
if is_moderator {
|
if is_moderator {
|
||||||
ping_command(&msg, &client).await.unwrap_or_default();
|
ping_command(&m, &client).await.unwrap_or_default();
|
||||||
} else {
|
} else {
|
||||||
sleep(Duration::from_secs(1));
|
sleep(Duration::from_secs(1));
|
||||||
ping_command(&msg, &client).await.unwrap_or_default();
|
ping_command(&m, &client).await.unwrap_or_default();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"song" => {
|
"song" => {
|
||||||
if is_moderator {
|
if is_moderator {
|
||||||
lastfm_command(&msg, &client).await.unwrap_or_default();
|
lastfm_command(&m, &client).await.unwrap_or_default();
|
||||||
} else {
|
} else {
|
||||||
sleep(Duration::from_secs(1));
|
sleep(Duration::from_secs(1));
|
||||||
lastfm_command(&msg, &client).await.unwrap_or_default();
|
lastfm_command(&m, &client).await.unwrap_or_default();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"user" => {
|
"user" => {
|
||||||
if is_moderator {
|
if is_moderator {
|
||||||
get_user_command(&msg, &client, &arguments)
|
get_user_command(&m, &client, &arguments)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
} else {
|
} else {
|
||||||
sleep(Duration::from_secs(1));
|
sleep(Duration::from_secs(1));
|
||||||
get_user_command(&msg, &client, &arguments)
|
get_user_command(&m, &client, &arguments)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"logs" => {
|
"logs" => {
|
||||||
if is_moderator {
|
if is_moderator {
|
||||||
logs_command(&msg, &client, &arguments)
|
logs_command(&m, &client, &arguments)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
} else {
|
} else {
|
||||||
sleep(Duration::from_secs(1));
|
sleep(Duration::from_secs(1));
|
||||||
logs_command(&msg, &client, &arguments)
|
logs_command(&m, &client, &arguments)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"massping" => {
|
"massping" => {
|
||||||
if is_moderator {
|
if is_moderator {
|
||||||
massping_command(&msg, &client).await.unwrap_or_default();
|
massping_command(&m, &client).await.unwrap_or_default();
|
||||||
} else {
|
} else {
|
||||||
sleep(Duration::from_secs(1));
|
sleep(Duration::from_secs(1));
|
||||||
massping_command(&msg, &client).await.unwrap_or_default()
|
massping_command(&m, &client).await.unwrap_or_default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ServerMessage::Whisper(msg) => {
|
ServerMessage::Whisper(m) => {
|
||||||
println!("(w) {}: {}", msg.sender.name, msg.message_text);
|
println!("(w) {}: {}", m.sender.name, m.message_text);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue