-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
212 additions
and
225 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "vrc-log" | ||
version = "0.4.5" | ||
version = "0.5.0" | ||
authors = ["Shayne Hartford <[email protected]>"] | ||
edition = "2021" | ||
description = "VRChat Local Cache Avatar ID Logger" | ||
|
@@ -27,16 +27,16 @@ regex = "1" | |
reqwest = { version = "0.11", features = ["blocking", "json"], optional = true } | ||
serde = { version = "1", features = ["derive"] } | ||
serde_json = "1" | ||
sqlite = { version = "0.32", features = ["bundled"], optional = true } | ||
strum = { version = "0.25", features = ["derive"] } | ||
sqlite = { version = "0.34", features = ["bundled"], optional = true } | ||
strum = { version = "0.26", features = ["derive"] } | ||
|
||
[features] | ||
default = ["cache", "ravenwood", "sqlite", "title"] | ||
default = ["cache", "sqlite", "title", "vrcdb"] | ||
cache = [] | ||
discord = ["dep:discord-presence"] | ||
ravenwood = ["dep:reqwest", "discord"] | ||
sqlite = ["dep:sqlite"] | ||
title = ["dep:crossterm"] | ||
vrcdb = ["dep:reqwest", "discord"] | ||
|
||
# https://github.com/johnthagen/min-sized-rust | ||
[profile.release] | ||
|
@@ -47,6 +47,7 @@ codegen-units = 1 | |
panic = "abort" | ||
|
||
[lints.clippy] | ||
pedantic = "warn" | ||
nursery = "warn" | ||
cargo = "warn" | ||
pedantic = { level = "warn", priority = -1 } | ||
nursery = { level = "warn", priority = -1 } | ||
cargo = { level = "warn", priority = -1 } | ||
multiple_crate_versions = "allow" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#[cfg(feature = "ravenwood")] | ||
pub use super::ravenwood::Ravenwood; | ||
#[cfg(feature = "sqlite")] | ||
pub use super::sqlite::Sqlite; | ||
#[cfg(feature = "vrcdb")] | ||
pub use super::vrcdb::VRCDB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,10 @@ use std::collections::HashMap; | |
|
||
use anyhow::{bail, Result}; | ||
use reqwest::blocking::Client; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::{ | ||
discord::{User, DEVELOPER_ID, USER}, | ||
provider::Provider, | ||
provider::{Provider, Type}, | ||
}; | ||
|
||
const USER_AGENT: &str = concat!( | ||
|
@@ -15,33 +14,22 @@ const USER_AGENT: &str = concat!( | |
" [email protected]" | ||
); | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct Response { | ||
status: Status, | ||
pub struct VRCDB { | ||
client: Client, | ||
userid: String, | ||
} | ||
|
||
#[derive(Deserialize, Serialize)] | ||
pub struct Status { | ||
message: String, | ||
status: i64, | ||
} | ||
|
||
pub struct Ravenwood { | ||
client: Client, | ||
user_id: String, | ||
} | ||
|
||
impl Ravenwood { | ||
impl VRCDB { | ||
#[must_use] | ||
pub const fn new(client: Client, user_id: String) -> Self { | ||
Self { client, user_id } | ||
pub const fn new(client: Client, userid: String) -> Self { | ||
Self { client, userid } | ||
} | ||
} | ||
|
||
impl Default for Ravenwood { | ||
impl Default for VRCDB { | ||
fn default() -> Self { | ||
let client = Client::default(); | ||
let user_id = USER.clone().map_or_else( | ||
let userid = USER.clone().map_or_else( | ||
|| { | ||
eprintln!("Error: Discord RPC Connection Failed\n"); | ||
eprintln!("This may be due to one of the following reasons:"); | ||
|
@@ -53,33 +41,32 @@ impl Default for Ravenwood { | |
}, | ||
|user| { | ||
let User { id, name, nick } = user; | ||
println!("[Ravenwood] Authenticated as {nick} ({name})"); | ||
println!("{} Authenticated as {nick} ({name})", Type::VRCDB); | ||
|
||
id | ||
}, | ||
); | ||
|
||
Self::new(client, user_id) | ||
Self::new(client, userid) | ||
} | ||
} | ||
|
||
impl Provider for Ravenwood { | ||
impl Provider for VRCDB { | ||
fn check_avatar_id(&self, _avatar_id: &str) -> Result<bool> { | ||
bail!("Unsupported") | ||
} | ||
|
||
fn send_avatar_id(&self, avatar_id: &str) -> Result<bool> { | ||
let response = self | ||
.client | ||
.put("https://api.ravenwood.dev/avatars/putavatar") | ||
.put("https://search.bs002.de/api/Avatar/putavatar") | ||
.header("User-Agent", USER_AGENT) | ||
.json(&HashMap::from([ | ||
("id", avatar_id), | ||
("userid", &self.user_id), | ||
("userid", &self.userid), | ||
])) | ||
.send()? | ||
.json::<Response>()?; | ||
.send()?; | ||
|
||
Ok(response.status.status == 201) | ||
Ok(response.status() == 201) | ||
} | ||
} |