minor improvments
This commit is contained in:
4
build.rs
4
build.rs
@ -14,7 +14,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
println!("cargo:rerun-if-env-changed=GIT_REVISION");
|
println!("cargo:rerun-if-env-changed=GIT_REVISION");
|
||||||
|
|
||||||
if let Ok(data) = std::fs::read_to_string(".env") {
|
if let Ok(data) = std::fs::read_to_string(".env") {
|
||||||
data.split('\n').into_iter().for_each(|v| {
|
data.split('\n').for_each(|v| {
|
||||||
let kv: Vec<&str> = v.split('=').collect();
|
let kv: Vec<&str> = v.split('=').collect();
|
||||||
if kv.len() != 2 {
|
if kv.len() != 2 {
|
||||||
return;
|
return;
|
||||||
@ -34,7 +34,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_value_from_env(key: &str) -> Option<String> {
|
fn get_value_from_env(key: &str) -> Option<String> {
|
||||||
env::var(key).map_or_else(|_| None, Some)
|
env::var(key).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_value_from_command<I: IntoIterator<Item = S>, S: AsRef<std::ffi::OsStr>>(
|
fn get_value_from_command<I: IntoIterator<Item = S>, S: AsRef<std::ffi::OsStr>>(
|
||||||
|
|||||||
12
src/main.rs
12
src/main.rs
@ -70,7 +70,7 @@ async fn run() -> anyhow::Result<()> {
|
|||||||
let climate_client = climate::Client::new(&settings.climate_dsn);
|
let climate_client = climate::Client::new(&settings.climate_dsn);
|
||||||
|
|
||||||
let self_temp_client = {
|
let self_temp_client = {
|
||||||
let splitted: Vec<&str> = settings.hosttemp_cmd.split(' ').into_iter().collect();
|
let splitted: Vec<&str> = settings.hosttemp_cmd.split(' ').collect();
|
||||||
let (cmd, arg) = (splitted[0], splitted[1]);
|
let (cmd, arg) = (splitted[0], splitted[1]);
|
||||||
|
|
||||||
climate::SelfTemperature::new(cmd, arg)
|
climate::SelfTemperature::new(cmd, arg)
|
||||||
@ -263,14 +263,14 @@ struct Climate {
|
|||||||
#[derive(BotCommands, Debug, Clone, PartialEq, Eq)]
|
#[derive(BotCommands, Debug, Clone, PartialEq, Eq)]
|
||||||
#[command(description = "These commands are supported:")]
|
#[command(description = "These commands are supported:")]
|
||||||
enum Command {
|
enum Command {
|
||||||
#[command(rename="help", description = "display this text.")]
|
#[command(rename = "help", description = "display this text.")]
|
||||||
Help,
|
Help,
|
||||||
#[command(rename="roomtemp", description = "temperature of your room.")]
|
#[command(rename = "roomtemp", description = "temperature of your room.")]
|
||||||
RoomTemperature,
|
RoomTemperature,
|
||||||
#[command(rename="hosttemp", description = "temperature of raspberry.")]
|
#[command(rename = "hosttemp", description = "temperature of raspberry.")]
|
||||||
HostTemperature,
|
HostTemperature,
|
||||||
#[command(rename="version", description = "prints current version.")]
|
#[command(rename = "version", description = "prints current version.")]
|
||||||
VersionRequest,
|
VersionRequest,
|
||||||
#[command(rename="chatid", description = "prints current chat id.")]
|
#[command(rename = "chatid", description = "prints current chat id.")]
|
||||||
ChatID,
|
ChatID,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user