Skip to content

Commit

Permalink
fix: report user agent in /version correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
getchoo committed Dec 1, 2023
1 parent 85402f9 commit f997cbd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ use once_cell::sync::Lazy;
pub mod guzzle;
pub mod shiggy;

pub const USER_AGENT: &str = "teawieBot/";

pub static REQWEST_CLIENT: Lazy<reqwest::Client> = Lazy::new(|| {
pub static USER_AGENT: Lazy<String> = Lazy::new(|| {
let version = option_env!("CARGO_PKG_VERSION").unwrap_or("development");

format!("teawieBot/{version}")
});

pub static REQWEST_CLIENT: Lazy<reqwest::Client> = Lazy::new(|| {
reqwest::Client::builder()
.user_agent(format!("{USER_AGENT}/{version}"))
.user_agent(format!("{:#?}", USER_AGENT))
.build()
.unwrap_or_default()
});
2 changes: 1 addition & 1 deletion src/commands/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub async fn version(ctx: Context<'_>) -> Result<()> {
false,
),
("Revision:", &revision_url, false),
("User Agent:", crate::api::USER_AGENT, false),
("User Agent:", &crate::api::USER_AGENT, false),
];

ctx.send(|c| {
Expand Down

0 comments on commit f997cbd

Please sign in to comment.