mirror of
https://github.com/MedzikUser/imgurs
synced 2024-08-15 00:03:19 +00:00
chore(webhook): delete discord webhook
This commit is contained in:
parent
c75cad024f
commit
71d124f435
8 changed files with 9 additions and 69 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
@ -485,17 +485,6 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "discord-webhook"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db4453db59b7305e07e41cb100c0dd81c2950d1f8e7d8fb03efcee7504f54b99"
|
||||
dependencies = [
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "easy-parallel"
|
||||
version = "3.2.0"
|
||||
|
@ -850,7 +839,6 @@ dependencies = [
|
|||
"clap_mangen",
|
||||
"colored",
|
||||
"dirs",
|
||||
"discord-webhook",
|
||||
"log",
|
||||
"notify-rust",
|
||||
"reqwest",
|
||||
|
|
|
@ -31,7 +31,6 @@ better-panic = "0.3.0"
|
|||
validator = "0.15.0"
|
||||
colored = "2.0.0"
|
||||
clap_mangen = "0.1.10"
|
||||
discord-webhook = "0.1.0"
|
||||
thiserror = "1.0.31"
|
||||
serde = { version = "1.0.138", features = ["derive"] }
|
||||
clap = { version = "3.2.8", features = ["derive"] }
|
||||
|
|
|
@ -7,7 +7,3 @@ enabled = true
|
|||
|
||||
[clipboard]
|
||||
enabled = true
|
||||
|
||||
[discord_webhook]
|
||||
enabled = false
|
||||
uri = ''
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:base"
|
||||
"config:base",
|
||||
"schedule:weekly",
|
||||
"group:allNonMajor",
|
||||
":semanticCommits"
|
||||
],
|
||||
"labels": [
|
||||
"dependencies"
|
||||
],
|
||||
"prHourlyLimit": 0,
|
||||
"automergeType": "pr",
|
||||
"prCreation": "immediate",
|
||||
"packageRules": [
|
||||
|
|
|
@ -5,7 +5,6 @@ pub mod credits;
|
|||
pub mod delete_image;
|
||||
pub mod info_image;
|
||||
pub mod upload_image;
|
||||
pub mod webhook;
|
||||
|
||||
pub use parse::*;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use imgurs::ImgurClient;
|
|||
use notify_rust::Notification;
|
||||
|
||||
use crate::{
|
||||
cli::{clipboard::set_clipboard, print_image_info, webhook::send_discord_webhook},
|
||||
cli::{clipboard::set_clipboard, print_image_info},
|
||||
config::toml,
|
||||
};
|
||||
|
||||
|
@ -46,11 +46,4 @@ pub async fn upload_image(client: ImgurClient, path: String) {
|
|||
if config.clipboard.enabled {
|
||||
set_clipboard(&i.data.link)
|
||||
}
|
||||
|
||||
// if enabled send embed with link and deletehash to discord (something like logger)
|
||||
if config.discord_webhook.enabled {
|
||||
send_discord_webhook(&i.data.link, &i.data.deletehash.unwrap())
|
||||
.await
|
||||
.expect("send discord webhook");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
use discord_webhook::client::WebhookClient;
|
||||
use std::error::Error;
|
||||
|
||||
use crate::config::toml;
|
||||
|
||||
// send embed with link and deletehash to discord (something like logger)
|
||||
pub async fn send_discord_webhook(
|
||||
link: &str,
|
||||
deletehash: &str,
|
||||
) -> Result<(), Box<dyn Error + Send + Sync>> {
|
||||
// get discord webhook uri from config
|
||||
let url = toml::parse().discord_webhook.uri;
|
||||
|
||||
// create WebhookClient
|
||||
let client: WebhookClient = WebhookClient::new(&url);
|
||||
|
||||
// get program version
|
||||
let version = option_env!("CARGO_PKG_VERSION").unwrap_or("unknown");
|
||||
|
||||
// send discord webhook
|
||||
client
|
||||
.send(|message| {
|
||||
message.username("Imgurs").embed(|embed| {
|
||||
embed
|
||||
.title(link)
|
||||
.description(&format!("Delete Hash ||{deletehash}||"))
|
||||
.image(link)
|
||||
.footer(&format!("Imgurs v{version}"), None)
|
||||
})
|
||||
})
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -7,7 +7,6 @@ pub struct Config {
|
|||
pub imgur: ConfigImgur,
|
||||
pub notification: ConfigNotification,
|
||||
pub clipboard: ConfigClipboard,
|
||||
pub discord_webhook: ConfigDiscordWebhook,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
@ -25,9 +24,3 @@ pub struct ConfigNotification {
|
|||
pub struct ConfigClipboard {
|
||||
pub enabled: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct ConfigDiscordWebhook {
|
||||
pub enabled: bool,
|
||||
pub uri: String,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue