Merge pull request 'Stopped 64bit Linux MUSL target from segfaulting, rustfmt' (#4) from famfo/uberbot:master into master
Reviewed-on: lemonsh/uberbot#4
This commit is contained in:
commit
68c15be79a
2
.cargo/config.toml
Normal file
2
.cargo/config.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[target.x86_64-unknown-linux-musl]
|
||||||
|
rustflags=["-Ctarget-feature=-crt-static"]
|
39
src/main.rs
39
src/main.rs
|
@ -1,6 +1,6 @@
|
||||||
use async_circe::{commands::Command, Client, Config};
|
use async_circe::{commands::Command, Client, Config};
|
||||||
use bots::title::Titlebot;
|
use bots::title::Titlebot;
|
||||||
use bots::{weeb, leek};
|
use bots::{leek, weeb};
|
||||||
use rspotify::Credentials;
|
use rspotify::Credentials;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -61,7 +61,8 @@ async fn main() -> anyhow::Result<()> {
|
||||||
.with_env_filter(EnvFilter::from_env("UBERBOT_LOG"))
|
.with_env_filter(EnvFilter::from_env("UBERBOT_LOG"))
|
||||||
.init();
|
.init();
|
||||||
|
|
||||||
let mut file = File::open(env::var("UBERBOT_CONFIG").unwrap_or_else(|_| "uberbot.toml".to_string()))?;
|
let mut file =
|
||||||
|
File::open(env::var("UBERBOT_CONFIG").unwrap_or_else(|_| "uberbot.toml".to_string()))?;
|
||||||
let mut client_conf = String::new();
|
let mut client_conf = String::new();
|
||||||
file.read_to_string(&mut client_conf)?;
|
file.read_to_string(&mut client_conf)?;
|
||||||
|
|
||||||
|
@ -133,20 +134,30 @@ async fn handle_message(state: &mut AppState, command: Command) -> anyhow::Resul
|
||||||
}
|
}
|
||||||
|
|
||||||
enum LeekCommand {
|
enum LeekCommand {
|
||||||
Owo, Leet, Mock
|
Owo,
|
||||||
|
Leet,
|
||||||
|
Mock,
|
||||||
}
|
}
|
||||||
async fn execute_leek(state: &mut AppState, cmd: LeekCommand, channel: &str, nick: &str) -> anyhow::Result<()> {
|
async fn execute_leek(
|
||||||
|
state: &mut AppState,
|
||||||
|
cmd: LeekCommand,
|
||||||
|
channel: &str,
|
||||||
|
nick: &str,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
match state.last_msgs.get(nick) {
|
match state.last_msgs.get(nick) {
|
||||||
Some(msg) => {
|
Some(msg) => {
|
||||||
let output = match cmd {
|
let output = match cmd {
|
||||||
LeekCommand::Owo => leek::owoify(msg)?,
|
LeekCommand::Owo => leek::owoify(msg)?,
|
||||||
LeekCommand::Leet => leek::leetify(msg)?,
|
LeekCommand::Leet => leek::leetify(msg)?,
|
||||||
LeekCommand::Mock => leek::mock(msg)?
|
LeekCommand::Mock => leek::mock(msg)?,
|
||||||
};
|
};
|
||||||
state.client.privmsg(channel, &output).await?;
|
state.client.privmsg(channel, &output).await?;
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
state.client.privmsg(channel, "No last messages found.").await?;
|
state
|
||||||
|
.client
|
||||||
|
.privmsg(channel, "No last messages found.")
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -188,10 +199,22 @@ async fn handle_privmsg(
|
||||||
state.client.privmsg(&channel, response).await?;
|
state.client.privmsg(&channel, response).await?;
|
||||||
}
|
}
|
||||||
"mock" => {
|
"mock" => {
|
||||||
execute_leek(state, LeekCommand::Mock, channel, remainder.unwrap_or(&nick)).await?;
|
execute_leek(
|
||||||
|
state,
|
||||||
|
LeekCommand::Mock,
|
||||||
|
channel,
|
||||||
|
remainder.unwrap_or(&nick),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
"leet" => {
|
"leet" => {
|
||||||
execute_leek(state, LeekCommand::Leet, channel, remainder.unwrap_or(&nick)).await?;
|
execute_leek(
|
||||||
|
state,
|
||||||
|
LeekCommand::Leet,
|
||||||
|
channel,
|
||||||
|
remainder.unwrap_or(&nick),
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
"owo" => {
|
"owo" => {
|
||||||
execute_leek(state, LeekCommand::Owo, channel, remainder.unwrap_or(&nick)).await?;
|
execute_leek(state, LeekCommand::Owo, channel, remainder.unwrap_or(&nick)).await?;
|
||||||
|
|
Loading…
Reference in a new issue