Skip to content

Commit

Permalink
add dynamic description
Browse files Browse the repository at this point in the history
  • Loading branch information
avoonix committed Jul 6, 2024
1 parent 162660a commit dc22fb9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions fuzzle/src/background_tasks/periodic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,5 +221,11 @@ async fn refetch_stickers(
let stats = database.get_stats().await?;
let percentage_tagged = stats.tagged_stickers as f32 / stats.stickers as f32 * 100.0;
simple_bot_api::set_my_short_description(&config.telegram_bot_token, &format!("I organize {} furry sticker sets 💚 {} taggings 💚 {} stickers ({:.1}% tagged) 💚 uwu", stats.sets, stats.taggings, stats.stickers, percentage_tagged)).await?;
simple_bot_api::set_my_description(&config.telegram_bot_token, &format!("Hi, I am {} and I organize furry sticker sets!
To use me, type @{} followed some tags in any chat to find one of the {} already tagged stickers.
If you know some stickers I might not be aware of, want to help tag the remaining {} stickers, or want to find stickers related to ones you already have, chat with me 💚", &config.bot_display_name, &config.telegram_bot_username.to_lowercase(), stats.tagged_stickers, stats.stickers - stats.tagged_stickers)).await?;
tokio::time::sleep(std::time::Duration::from_secs(10)).await;
Ok(())
}
15 changes: 15 additions & 0 deletions fuzzle/src/simple_bot_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ pub async fn set_my_short_description(
).await
}

/// 0-512 characters, plain text
#[tracing::instrument(skip(token))]
pub async fn set_my_description(
token: &str,
description: &str,
) -> Result<(), InternalError> {
perform_request(
"setMyDescription",
token,
json!({
"description": description,
}),
).await
}

#[tracing::instrument(skip(token))]
pub async fn create_new_sticker_set(
token: &str,
Expand Down
2 changes: 1 addition & 1 deletion fuzzle/src/text/texts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ If you search stickers by emojis instead of tags, the blacklist is not in effect
#[must_use]
pub fn get_start_text() -> Markdown {
Markdown::new(
"I'm a bot that can help you find stickers\\. It's basically e621, but with telegram stickers\\. To use me, press the \"Use me in a chat\" button below\\.
"I'm a bot that can help you find stickers\\. I am using many of the e621 tags, but with telegram stickers\\. To use me, press the \"Use me in a chat\" button below\\.
If you send me some stickers in this chat, I will add them to the database\\. Help with tagging is appreciated :3".to_string()
)
Expand Down

0 comments on commit dc22fb9

Please sign in to comment.