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