Featurize self update
This commit is contained in:
parent
fb7ab4f6cc
commit
ae10b786fe
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2378,7 +2378,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shibe-bot"
|
name = "shibe-bot"
|
||||||
version = "1.0.2"
|
version = "1.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
|
18
Cargo.toml
18
Cargo.toml
@ -3,7 +3,7 @@ name = "shibe-bot"
|
|||||||
description = "A Discord bot written in Rust, using Poise."
|
description = "A Discord bot written in Rust, using Poise."
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
version = "1.0.2"
|
version = "1.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
@ -24,9 +24,13 @@ serde_json = "1.0.140"
|
|||||||
roux = "2.2.13"
|
roux = "2.2.13"
|
||||||
structstruck = "0.5.0"
|
structstruck = "0.5.0"
|
||||||
reqwest = { version = "0.12.15", features = ["json"] }
|
reqwest = { version = "0.12.15", features = ["json"] }
|
||||||
octocrab = "0.44.1"
|
octocrab = { version = "0.44.1", optional = true }
|
||||||
tempfile = "3.20.0"
|
tempfile = { version = "3.20.0", optional = true }
|
||||||
self-replace = "1.5.0"
|
self-replace = { version = "1.5.0", optional = true }
|
||||||
zip = "4.2.0"
|
zip = { version = "4.2.0", optional = true }
|
||||||
nix = { version = "0.30.1", features = ["process"] }
|
nix = { version = "0.30.1", features = ["process"], optional = true }
|
||||||
minreq = { version = "2.14.0", features = ["https"] }
|
minreq = { version = "2.14.0", features = ["https"], optional = true }
|
||||||
|
|
||||||
|
|
||||||
|
[features]
|
||||||
|
self-update=["octocrab", "tempfile", "self-replace", "zip", "nix", "minreq"]
|
@ -1,4 +1,4 @@
|
|||||||
# Shibe Bot 1.0.2
|
# Shibe Bot 1.1.0
|
||||||
|
|
||||||
[](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml)
|
[](https://github.com/shibedrill/shibe-bot/actions/workflows/rust.yml)
|
||||||
[](LICENSE.txt)
|
[](LICENSE.txt)
|
||||||
|
@ -1,17 +1,9 @@
|
|||||||
use std::convert::Infallible;
|
#[cfg(feature="self-update")]
|
||||||
use std::os::unix::process::CommandExt;
|
use {std::convert::Infallible, std::os::unix::process::CommandExt, octocrab, std::io::Write, self_replace, zip, minreq};
|
||||||
|
|
||||||
use crate::Context;
|
use crate::Context;
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
use octocrab;
|
|
||||||
use std::io::Write;
|
|
||||||
|
|
||||||
use self_replace;
|
|
||||||
use zip;
|
|
||||||
|
|
||||||
use minreq;
|
|
||||||
|
|
||||||
/// Print version and build information
|
/// Print version and build information
|
||||||
#[poise::command(slash_command)]
|
#[poise::command(slash_command)]
|
||||||
pub async fn version(ctx: Context<'_>) -> Result<(), Error> {
|
pub async fn version(ctx: Context<'_>) -> Result<(), Error> {
|
||||||
@ -42,6 +34,7 @@ pub async fn version(ctx: Context<'_>) -> Result<(), Error> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature="self-update")]
|
||||||
/// Update the bot remotely (requires Github CI)
|
/// Update the bot remotely (requires Github CI)
|
||||||
#[poise::command(slash_command, owners_only, hide_in_help)]
|
#[poise::command(slash_command, owners_only, hide_in_help)]
|
||||||
pub async fn update(
|
pub async fn update(
|
||||||
@ -121,6 +114,7 @@ pub async fn say(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature="self-update")]
|
||||||
fn self_update() -> Result<Infallible, Error> {
|
fn self_update() -> Result<Infallible, Error> {
|
||||||
let artifact_url = "https://nightly.link/shibedrill/shibe-bot/workflows/rust/main/artifact.zip";
|
let artifact_url = "https://nightly.link/shibedrill/shibe-bot/workflows/rust/main/artifact.zip";
|
||||||
let tempdir = tempfile::Builder::new().prefix("shibe-bot").tempdir()?;
|
let tempdir = tempfile::Builder::new().prefix("shibe-bot").tempdir()?;
|
||||||
@ -173,11 +167,11 @@ fn self_update() -> Result<Infallible, Error> {
|
|||||||
mod test {
|
mod test {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use crate::Error;
|
#[cfg(feature="self-update")]
|
||||||
#[cfg(test)]
|
use {crate::Error, std::convert::Infallible};
|
||||||
use std::convert::Infallible;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg(feature="self-update")]
|
||||||
fn test_self_update() -> Result<Infallible, Error> {
|
fn test_self_update() -> Result<Infallible, Error> {
|
||||||
use crate::command::devel::self_update;
|
use crate::command::devel::self_update;
|
||||||
use pretty_env_logger;
|
use pretty_env_logger;
|
||||||
|
@ -85,6 +85,7 @@ async fn main() {
|
|||||||
shutdown(),
|
shutdown(),
|
||||||
restart(),
|
restart(),
|
||||||
say(),
|
say(),
|
||||||
|
#[cfg(feature="self-update")]
|
||||||
update(),
|
update(),
|
||||||
version(),
|
version(),
|
||||||
// Fun
|
// Fun
|
||||||
|
Loading…
Reference in New Issue
Block a user