mirror of
https://github.com/ethanrusz/echbot.git
synced 2024-11-24 12:57:46 -05:00
Add framework for Hi-Rez API
This commit is contained in:
parent
4089abc815
commit
eb39ece900
7 changed files with 61 additions and 7 deletions
34
Cargo.lock
generated
34
Cargo.lock
generated
|
@ -108,9 +108,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f"
|
checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iana-time-zone",
|
"iana-time-zone",
|
||||||
|
"js-sys",
|
||||||
"num-integer",
|
"num-integer",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"serde",
|
"serde",
|
||||||
|
"time 0.1.45",
|
||||||
|
"wasm-bindgen",
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -276,6 +279,8 @@ dependencies = [
|
||||||
name = "echbot"
|
name = "echbot"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"md5",
|
||||||
"poise",
|
"poise",
|
||||||
"rand",
|
"rand",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
@ -398,7 +403,7 @@ checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"wasi",
|
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -611,6 +616,12 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "md5"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.5.0"
|
version = "2.5.0"
|
||||||
|
@ -650,7 +661,7 @@ checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"log",
|
"log",
|
||||||
"wasi",
|
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1037,7 +1048,7 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde-value",
|
"serde-value",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"time",
|
"time 0.3.17",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"typemap_rev",
|
"typemap_rev",
|
||||||
|
@ -1132,6 +1143,17 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "time"
|
||||||
|
version = "0.1.45"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"wasi 0.10.0+wasi-snapshot-preview1",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.3.17"
|
version = "0.3.17"
|
||||||
|
@ -1382,6 +1404,12 @@ dependencies = [
|
||||||
"try-lock",
|
"try-lock",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.10.0+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
version = "0.11.0+wasi-snapshot-preview1"
|
version = "0.11.0+wasi-snapshot-preview1"
|
||||||
|
|
|
@ -9,3 +9,5 @@ edition = "2021"
|
||||||
poise = "0.5.2"
|
poise = "0.5.2"
|
||||||
tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
chrono = "0.4.23"
|
||||||
|
md5 = "0.7.0"
|
||||||
|
|
|
@ -10,6 +10,8 @@ You must set the following for the bot to run.
|
||||||
environment:
|
environment:
|
||||||
- DISCORD_TOKEN=your_token_here
|
- DISCORD_TOKEN=your_token_here
|
||||||
- GUILD_ID=your_guild_id_here
|
- GUILD_ID=your_guild_id_here
|
||||||
|
- DEV_ID=your_hi-rez_dev_id
|
||||||
|
- AUTH_KEY=your_hi-rez_auth_key
|
||||||
```
|
```
|
||||||
|
|
||||||
## Quotes
|
## Quotes
|
||||||
|
|
23
src/api.rs
Normal file
23
src/api.rs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
use chrono;
|
||||||
|
use crate::Error;
|
||||||
|
|
||||||
|
fn get_utc_timestamp() -> String {
|
||||||
|
return chrono::Utc::now().format("%Y%m%d%H%M%S").to_string();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn generate_signature(timestamp: String) -> String {
|
||||||
|
let dev_id = std::env::var("DEV_ID")
|
||||||
|
.expect("Missing DEV_ID");
|
||||||
|
let auth_key = std::env::var("AUTH_KEY")
|
||||||
|
.expect("Missing AUTH_KEY");
|
||||||
|
let signature = md5::compute(format!("{}createsession{}{}", dev_id, auth_key, timestamp));
|
||||||
|
|
||||||
|
return format!("{:?}", signature);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn create_session() -> Result<(), Error> {
|
||||||
|
let timestamp = get_utc_timestamp();
|
||||||
|
let signature: String = generate_signature(timestamp);
|
||||||
|
println!("{}", signature);
|
||||||
|
Ok(())
|
||||||
|
}
|
|
@ -12,17 +12,15 @@ pub(crate) async fn team(
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let mut v = ctx.guild().unwrap().voice_states; // Get hashmap of users' voice states within the guild
|
let mut v = ctx.guild().unwrap().voice_states; // Get hashmap of users' voice states within the guild
|
||||||
v.retain(|_, s| s.channel_id == Some(channel.id())); // Drop users not active in requested voice channel from hashmap
|
v.retain(|_, s| s.channel_id == Some(channel.id())); // Drop users not active in requested voice channel from hashmap
|
||||||
let res = format!("Channel {} has {} active users.", channel.id(), v.keys().len());
|
|
||||||
|
|
||||||
ctx.send(|f| f
|
ctx.send(|f| f
|
||||||
.content(res)
|
|
||||||
.embed(|f| f
|
.embed(|f| f
|
||||||
.title(format!("Custom {}v{} Teams", size, size))
|
.title(format!("Custom {}v{} Teams", size, size))
|
||||||
.description("I'm not done with this yet.")
|
.description("I'm not done with this yet.")
|
||||||
.field("Order", "Some names", true)
|
.field("Order", "Some names", true)
|
||||||
.field("Chaos", "Other names", true)
|
.field("Chaos", "Other names", true)
|
||||||
.field("Spectators", "You guessed it, names.", false)
|
.field("Spectators", "You guessed it, names.", false)
|
||||||
.color(serenity::Colour(16711680)) // Red
|
.color(serenity::Colour::DARK_GREEN)
|
||||||
)).await?;
|
)).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
mod commands;
|
mod commands;
|
||||||
|
mod api;
|
||||||
|
|
||||||
use poise::serenity_prelude as serenity;
|
use poise::serenity_prelude as serenity;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue