chore: fix clippy warnings

This commit is contained in:
Kristofers Solo 2025-09-19 17:14:56 +03:00
parent a35b255d67
commit bae194b2bf
Signed by: kristoferssolo
GPG Key ID: 8687F2D3EEE6F0ED
3 changed files with 19 additions and 21 deletions

1
src/lib.rs Normal file
View File

@ -0,0 +1 @@
pub mod telemetry;

View File

@ -36,13 +36,14 @@ enum MediaKind {
async fn main() -> color_eyre::Result<()> {
dotenv().ok();
color_eyre::install()?;
setup_logger()?;
setup_logger();
let bot = Bot::from_env();
teloxide::repl(bot, |bot: Bot, msg: Message| async move {
if let Some(text) = msg.text() {
if let Some(shortcode) = extract_instagram_shortcode(text) {
if let Some(text) = msg.text()
&& let Some(shortcode) = extract_instagram_shortcode(text)
{
let bot_cloned = bot.clone();
let chat = msg.chat.id;
@ -55,7 +56,6 @@ async fn main() -> color_eyre::Result<()> {
}
});
}
}
respond(())
})
.await;
@ -77,7 +77,7 @@ async fn fetch_and_send(bot: &Bot, chat_id: ChatId, shortcode: &str) -> Result<(
let dir_path = dir.path().to_path_buf();
dbg!(&dir_path);
let target = format!("-{}", shortcode);
let target = format!("-{shortcode}");
dbg!(&target);
let status = Command::new("instaloader")
.arg("--dirname-pattern")
@ -134,7 +134,7 @@ async fn fetch_and_send(bot: &Bot, chat_id: ChatId, shortcode: &str) -> Result<(
fn ext_lower(path: &Path) -> Option<String> {
path.extension()
.and_then(|s| s.to_str())
.map(|s| s.to_ascii_lowercase())
.map(str::to_ascii_lowercase)
}
fn kind_by_magic(path: &Path) -> Option<MediaKind> {

View File

@ -1,9 +1,8 @@
use color_eyre::Result;
use tracing_bunyan_formatter::{BunyanFormattingLayer, JsonStorageLayer};
use tracing_subscriber::{EnvFilter, layer::SubscriberExt, util::SubscriberInitExt};
/// # Errors
pub fn setup_logger() -> Result<()> {
/// Initialise tracing with bunyan-style JSON output.
pub fn setup_logger() {
let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| "info".into());
let formatter = BunyanFormattingLayer::new("tg-relay-rs".into(), std::io::stdout);
@ -12,6 +11,4 @@ pub fn setup_logger() -> Result<()> {
.with(JsonStorageLayer)
.with(formatter)
.init();
Ok(())
}