Skip to content

Commit

Permalink
0.9.1 - Fix Clickable Links
Browse files Browse the repository at this point in the history
  • Loading branch information
ShayBox committed Oct 18, 2024
1 parent 416243d commit a51025e
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 85 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vrc-log"
version = "0.9.0"
version = "0.9.1"
authors = ["Shayne Hartford <[email protected]>"]
edition = "2021"
description = "VRChat Local Cache Avatar ID Logger"
Expand Down Expand Up @@ -36,17 +36,17 @@ tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter", "time"] }

[features]
default = ["cache", "title", "avtrdb", "doughnut", "neko", "vrcdb"]

discord = ["dep:discord-presence", "dep:cached"]
title = ["dep:crossterm"]
default = ["cache", "avtrdb", "vrcdb", "vrcga", "vrcwb", "title"]

# VRChat Avatar Database Providers
avtrdb = ["dep:reqwest", "discord"]
cache = ["dep:sqlite"]
doughnut = ["dep:reqwest", "discord"]
neko = ["dep:reqwest", "discord"]
avtrdb = ["dep:reqwest", "discord"]
vrcdb = ["dep:reqwest", "discord"]
vrcga = ["dep:reqwest", "discord"]
vrcwb = ["dep:reqwest", "discord"]

discord = ["dep:discord-presence", "dep:cached"]
title = ["dep:crossterm"]

# https://github.com/johnthagen/min-sized-rust
[profile.release]
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ Place the file in the VRChat directory or `PATH` and set your launch options
`vrc-log(.exe) %command%`

### Supported Avatar Database Providers
- [AVTRDB] - [Discord](https://discord.gg/ZxB6w2hGfU) / [Web](https://avtrdb.com) / [VRCX](https://api.avtrdb.com/v1/avatar/search/vrcx)
- [DOUGHNUT] - [Discord](https://discord.gg/tjfXPzzaxu) / [Web](https://avtr1.nekosunevr.co.uk/search.php) / [VRCX](https://avtr1.nekosunevr.co.uk/vrcx_search.php)
- [NEKO] - [Discord](https://discord.gg/tjfXPzzaxu) / [Web](https://avtr.nekosunevr.co.uk/search.php) / [VRCX](https://avtr.nekosunevr.co.uk/vrcx_search.php)
- [VRCDB] - [Discord](https://discord.gg/q427ecnUvj) / [Web](https://vrcdb.com) / [World](https://vrchat.com/home/world/wrld_1146f625-5d42-40f5-bfe7-06a7664e2796) / [VRCX](vrcx.vrcdb.com/avatars/Avatar/VRCX)
- [avtrDB - Avatar Search] - [Discord](https://discord.gg/ZxB6w2hGfU) / [Web](https://avtrdb.com) / [VRCX](https://api.avtrdb.com/v1/avatar/search/vrcx)
- [VRCDB - Avatar Search] - [Discord](https://discord.gg/q427ecnUvj) / [Web](https://vrcdb.com) / [World](https://vrchat.com/home/world/wrld_1146f625-5d42-40f5-bfe7-06a7664e2796) / [VRCX](vrcx.vrcdb.com/avatars/Avatar/VRCX)
- [VRCGA - Guardian Angel] - [Discord](https://discord.gg/tjfXPzzaxu) / [Web](https://avtr.nekosunevr.co.uk/search.php) / [VRCX](https://avtr.nekosunevr.co.uk/vrcx_search.php)
- [VRCWB - World Balancer] - [Discord](https://discord.gg/Uw7aAShdsp) / [Web](https://avtr1.nekosunevr.co.uk/search.php) / [VRCX](https://avtr1.nekosunevr.co.uk/vrcx_search.php)

#### Unsupported Avatar Database Providers
- ~~Ravenwood~~ - Used VRCDB (Shutdown)
- ~~VRCDB Ravenwood~~ - Shutdown
- ~~[Just H Party]~~ - Can't submit avatars
- ~~[Prismic's Avatar Search]~~ - Can't submit avatars

Additional providers are welcome, please open an issue, pull request, or join Discord

[AVTRDB]: https://avtrdb.com
[DOUGHNUT]: https://avtr1.nekosunevr.co.uk
[avtrDB - Avatar Search]: https://avtrdb.com
[Just H Party]: https://avtr.just-h.party
[NEKO]: https://avtr.nekosunevr.co.uk
[Prismic's Avatar Search]: https://vrchat.com/home/world/wrld_57514404-7f4e-4aee-a50a-57f55d3084bf
[VRCDB]: https://sites.smokes-hub.de
[VRCDB - Avatar Search]: https://sites.smokes-hub.de
[VRCGA - Guardian Angel]: https://avtr.nekosunevr.co.uk
[VRCWB - World Balancer]: https://avtr1.nekosunevr.co.uk
[VRCX]: https://github.com/vrcx-team/VRCX?tab=readme-ov-file#--vrcx
54 changes: 24 additions & 30 deletions src/discord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,44 +37,38 @@ impl Discord {
}
}

#[once(sync_writes = true)]
pub fn get_dev_id() -> String {
warn!("Error: Discord RPC Connection Failed\n");
warn!("This may be due to one of the following reasons:");
warn!("1. Discord is not running on your system.");
warn!("2. VRC-LOG was restarted too quickly.\n");
warn!("The User ID will default to the developer: ShayBox");

std::env::var("DISCORD").unwrap_or_else(|_| DEVELOPER_ID.to_owned())
}

#[once(option = true, sync_writes = true)]
pub fn get_user_id() -> Option<String> {
let discord = Discord::start();
if let Ok(user_id) = std::env::var("DISCORD") {
/* TODO: Validate User ID (Snowflake) - Regex? */
return Some(user_id);
}

// block_until_event will never time out
let discord = Discord::start();
std::thread::sleep(Duration::from_secs(5));
discord.client.shutdown().ok()?;

let user_id = match discord.user.lock().clone() {
None => get_dev_id(),
Some(user) => {
let userid = user.id.unwrap_or_else(get_dev_id);
if userid == "1045800378228281345" {
warn!("Vesktop & arRPC doesn't support fetching user info");
warn!("You can supply the 'DISCORD' env variable manually");
warn!("The User ID will default to the developer: ShayBox");

std::env::var("DISCORD").unwrap_or_else(|_| DEVELOPER_ID.to_owned())
} else {
if let Some(username) = user.username {

if let Some(user) = discord.user.lock().as_ref() {
if let Some(user_id) = &user.id {
if user_id != "1045800378228281345" {
if let Some(username) = &user.username {
info!("[Discord] Authenticated as {username}");
}

userid
return Some(user_id.clone());
}

warn!("Vesktop & arRPC doesn't support fetching user info");
warn!("You can supply the 'DISCORD' env variable manually");
warn!("The User ID will default to the developer: ShayBox");
}
};

Some(user_id)
} else {
warn!("Error: Discord RPC Connection Failed\n");
warn!("This may be due to one of the following reasons:");
warn!("1. Discord is not running on your system.");
warn!("2. VRC-LOG was restarted too quickly.\n");
warn!("The User ID will default to the developer: ShayBox");
}

Some(String::from(DEVELOPER_ID))
}
26 changes: 13 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crossbeam::channel::{Receiver, Sender};
use lazy_regex::{lazy_regex, regex_replace_all, Lazy, Regex};
use notify::{Config, Event, PollWatcher, RecursiveMode, Watcher};
use parking_lot::RwLock;
use terminal_link::Link;

use crate::provider::{prelude::*, Providers, Type};

Expand Down Expand Up @@ -45,15 +46,13 @@ pub fn get_local_time() -> String {
/// Will return `Err` if couldn't get the GitHub repository
pub fn check_for_updates() -> reqwest::Result<bool> {
let response = reqwest::blocking::get(CARGO_PKG_HOMEPAGE)?;
let Some(segments) = response.url().path_segments() else {
return Ok(false);
if let Some(segments) = response.url().path_segments() {
if let Some(remote_version) = segments.last() {
return Ok(remote_version > CARGO_PKG_VERSION);
};
};

let Some(remote_version) = segments.last() else {
return Ok(false);
};

Ok(remote_version > CARGO_PKG_VERSION)
Ok(false)
}

/// # Errors
Expand Down Expand Up @@ -116,10 +115,10 @@ pub fn process_avatars((_tx, rx, _): WatchResponse) -> anyhow::Result<()> {
(Type::CACHE, box_db!(Cache::new()?)),
#[cfg(feature = "avtrdb")]
(Type::AVTRDB, box_db!(AvtrDB::default())),
#[cfg(feature = "doughnut")]
(Type::DOUGHNUT, box_db!(Doughnut::default())),
#[cfg(feature = "neko")]
(Type::NEKO, box_db!(Neko::default())),
#[cfg(feature = "vrcwb")]
(Type::VRCWB, box_db!(VRCWB::default())),
#[cfg(feature = "vrcga")]
(Type::VRCGA, box_db!(VRCGA::default())),
#[cfg(feature = "vrcdb")]
(Type::VRCDB, box_db!(VRCDB::default())),
]);
Expand Down Expand Up @@ -224,6 +223,7 @@ pub fn print_colorized(avatar_id: &str) {
let color = COLORS[index];
*INDEX.write() = (index + 1) % COLORS.len();

let text = format!("vrcx://avatar/{avatar_id}").color(color);
info!("{text}");
let text = format!("vrcx://avatar/{avatar_id}");
let link = Link::new(&text, &text).to_string().color(color);
info!("{link}");
}
24 changes: 14 additions & 10 deletions src/provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,31 @@ use strum::Display;
pub mod avtrdb;
#[cfg(feature = "cache")]
pub mod cache;
#[cfg(feature = "doughnut")]
pub mod doughnut;
#[cfg(feature = "neko")]
pub mod neko;
#[cfg(feature = "vrcwb")]
pub mod vrcwb;
#[cfg(feature = "vrcga")]
pub mod vrcga;
#[cfg(feature = "vrcdb")]
pub mod vrcdb;

pub mod prelude;

#[derive(Display, Eq, Hash, PartialEq)]
pub enum Type {
#[cfg(feature = "avtrdb")]
AVTRDB,
#[cfg(feature = "cache")]
CACHE,
#[cfg(feature = "doughnut")]
DOUGHNUT,
#[cfg(feature = "neko")]
NEKO,
#[cfg(feature = "avtrdb")]
#[strum(to_string = "avtrDB - Avatar Search")]
AVTRDB,
#[cfg(feature = "vrcdb")]
#[strum(to_string = "VRCDB - Avatar Search")]
VRCDB,
#[cfg(feature = "vrcga")]
#[strum(to_string = "VRCGA - Guardian Angel")]
VRCGA,
#[cfg(feature = "vrcwb")]
#[strum(to_string = "VRCWB - World Balancer")]
VRCWB,
}

pub trait Provider {
Expand Down
8 changes: 4 additions & 4 deletions src/provider/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
pub use super::avtrdb::AvtrDB;
#[cfg(feature = "cache")]
pub use super::cache::Cache;
#[cfg(feature = "doughnut")]
pub use super::doughnut::Doughnut;
#[cfg(feature = "neko")]
pub use super::neko::Neko;
#[cfg(feature = "vrcwb")]
pub use super::vrcwb::VRCWB;
#[cfg(feature = "vrcga")]
pub use super::vrcga::VRCGA;
#[cfg(feature = "vrcdb")]
pub use super::vrcdb::VRCDB;
10 changes: 5 additions & 5 deletions src/provider/neko.rs → src/provider/vrcga.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ use crate::{

const URL: &str = "https://avtr.nekosunevr.co.uk/v1/vrchat/avatars/store/putavatarExternal";

pub struct Neko {
pub struct VRCGA {
client: Client,
userid: String,
}

impl Default for Neko {
impl Default for VRCGA {
fn default() -> Self {
Self {
client: Client::default(),
Expand All @@ -24,7 +24,7 @@ impl Default for Neko {
}
}

impl Provider for Neko {
impl Provider for VRCGA {
fn check_avatar_id(&self, _avatar_id: &str) -> Result<bool> {
bail!("Cache Only")
}
Expand All @@ -42,12 +42,12 @@ impl Provider for Neko {

let status = response.status();
let text = response.text()?;
debug!("[{}] {status} | {text}", Type::NEKO);
debug!("[{}] {status} | {text}", Type::VRCGA);

let unique = match status {
StatusCode::OK => false,
StatusCode::NOT_FOUND => true,
_ => bail!("[{}] {status} | {text}", Type::NEKO),
_ => bail!("[{}] {status} | {text}", Type::VRCGA),
};

Ok(unique)
Expand Down
10 changes: 5 additions & 5 deletions src/provider/doughnut.rs → src/provider/vrcwb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ use crate::{

const URL: &str = "https://avtr1.nekosunevr.co.uk/v1/vrchat/avatars/store/putavatarExternal";

pub struct Doughnut {
pub struct VRCWB {
client: Client,
userid: String,
}

impl Default for Doughnut {
impl Default for VRCWB {
fn default() -> Self {
Self {
client: Client::default(),
Expand All @@ -24,7 +24,7 @@ impl Default for Doughnut {
}
}

impl Provider for Doughnut {
impl Provider for VRCWB {
fn check_avatar_id(&self, _avatar_id: &str) -> Result<bool> {
bail!("Cache Only")
}
Expand All @@ -42,12 +42,12 @@ impl Provider for Doughnut {

let status = response.status();
let text = response.text()?;
debug!("[{}] {status} | {text}", Type::DOUGHNUT);
debug!("[{}] {status} | {text}", Type::VRCWB);

let unique = match status {
StatusCode::OK => false,
StatusCode::NOT_FOUND => true,
_ => bail!("[{}] {status} | {text}", Type::DOUGHNUT),
_ => bail!("[{}] {status} | {text}", Type::VRCWB),
};

Ok(unique)
Expand Down
1 change: 1 addition & 0 deletions src/vrchat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct VRChat {
/// This is actually the path to the cache parent directory
/// `VRChat` doesn't allow you to change the cache directory name
/// The `Cache-WindowsPlayer` path is appended during deserialization below
/// Because this is how `VRChat` does it, it must not be in the config file
#[serde(deserialize_with = "deserialize")]
pub cache_directory: PathBuf,
}
Expand Down

0 comments on commit a51025e

Please sign in to comment.