better stuff
This commit is contained in:
+10
-5
@@ -15,12 +15,11 @@ use tokio::{
|
||||
|
||||
use crate::bot::Bot;
|
||||
|
||||
async fn shutdown_listener(bot: Arc<Bot>, tx: watch::Sender<bool>) -> anyhow::Result<()> {
|
||||
async fn try_shutdown_listener(bot: Arc<Bot>, tx: watch::Sender<bool>) -> anyhow::Result<()> {
|
||||
let mut stdin = BufReader::new(io::stdin());
|
||||
let mut line = String::new();
|
||||
|
||||
loop {
|
||||
let mut stdin = BufReader::new(io::stdin());
|
||||
|
||||
let mut line = String::new();
|
||||
|
||||
stdin.read_line(&mut line).await?;
|
||||
|
||||
match line.to_lowercase().trim() {
|
||||
@@ -56,6 +55,12 @@ async fn shutdown_listener(bot: Arc<Bot>, tx: watch::Sender<bool>) -> anyhow::Re
|
||||
}
|
||||
}
|
||||
|
||||
async fn shutdown_listener(bot: Arc<Bot>, tx: watch::Sender<bool>) {
|
||||
if let Err(e) = try_shutdown_listener(bot, tx).await {
|
||||
log::error!("{e}");
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
let mut builder = env_logger::Builder::from_default_env();
|
||||
|
||||
Reference in New Issue
Block a user