mirror of
https://github.com/kristoferssolo/tg-relay-rs.git
synced 2025-12-20 11:04:41 +00:00
chore: fix clippy warnings
This commit is contained in:
parent
a35b255d67
commit
bae194b2bf
1
src/lib.rs
Normal file
1
src/lib.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod telemetry;
|
||||
12
src/main.rs
12
src/main.rs
@ -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> {
|
||||
|
||||
@ -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(())
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user