diff --git a/bot/src/api/base.rs b/bot/src/api/base.rs index 21c9f2b8..e562dbe3 100644 --- a/bot/src/api/base.rs +++ b/bot/src/api/base.rs @@ -3,6 +3,8 @@ use anyhow::{bail, Error}; use bytes::Bytes; use reqwest::{header, Client, Method, StatusCode, Url}; +pub const USER_AGENT: &str = concat!("OxidizeBot/", version_str!()); + /// Trait to deal with optional bodies. /// /// Fix and replace once we get HRTB's or HRT's :cry: @@ -160,10 +162,7 @@ impl RequestBuilder { } } - req = req.header( - header::USER_AGENT, - concat!("OxidizeBot/", env!("CARGO_PKG_VERSION")), - ); + req = req.header(header::USER_AGENT, USER_AGENT); req }; diff --git a/bot/src/lib.rs b/bot/src/lib.rs index 21a591be..2d6ba818 100644 --- a/bot/src/lib.rs +++ b/bot/src/lib.rs @@ -10,7 +10,14 @@ extern crate smallvec; pub use async_injector as injector; -pub const VERSION: &str = include_str!(concat!(env!("OUT_DIR"), "/version.txt")); +/// Get the version number of the project. +macro_rules! version_str { + () => { + include_str!(concat!(env!("OUT_DIR"), "/version.txt")) + }; +} + +pub const VERSION: &str = version_str!(); #[macro_use] mod macros;