aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml4
-rw-r--r--Cross-Compilation_Enviorment_Variables.md5
-rw-r--r--README.md3
-rw-r--r--Rocket.toml9
-rw-r--r--rust-toolchain1
-rw-r--r--src/core/handler.rs16
-rw-r--r--src/core/mod.rs1
-rw-r--r--src/core/model.rs11
-rw-r--r--src/core/webserver.rs22
-rw-r--r--src/lib.rs3
-rw-r--r--src/modules/commands/general/mod.rs4
-rw-r--r--src/modules/commands/general/voice.rs108
-rw-r--r--src/wisp.rs3
-rw-r--r--static/icon-256x256.icobin0 -> 8863 bytes
14 files changed, 185 insertions, 5 deletions
diff --git a/Cargo.toml b/Cargo.toml
index becb85d..b65c4df 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -35,6 +35,8 @@ sysinfo = "0.5"
threadpool = "1.7"
typemap = "0.3"
urbandictionary = "0.3"
+# rocket = "0.4.5"
+# rocket_contrib = "0.4.5"
[dependencies.parking_lot]
version = "0.6"
@@ -52,7 +54,7 @@ features = ["colored"]
git = "https://github.com/Mishio595/serenity.git"
# path = "/home/adelyn/dev/serenity"
default-features = false
-features = ["builder", "client", "cache", "framework", "standard_framework", "gateway", "http", "model", "utils"]
+features = ["builder", "client", "cache", "framework", "standard_framework", "gateway", "http", "model", "utils"] # voice
[patch.crates-io]
openssl = { git = "https://github.com/ishitatsuyuki/rust-openssl", branch = "0.9.x" }
diff --git a/Cross-Compilation_Enviorment_Variables.md b/Cross-Compilation_Enviorment_Variables.md
new file mode 100644
index 0000000..2ae277e
--- /dev/null
+++ b/Cross-Compilation_Enviorment_Variables.md
@@ -0,0 +1,5 @@
+CC=E:/cygwin64/usr/local/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-gcc.exe
+CFLAGS=E:\msys64\usr\include;
+OPENSSL_DIR=E:\msys64\mingw64
+OPENSSL_LIB_DIR=E:\msys64\mingw64\lib
+PQ_LIB_DIR=E:\Program Files\PostgreSQL\13\lib \ No newline at end of file
diff --git a/README.md b/README.md
index a62ed03..869de6c 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,5 @@
# Wisp
Wisp, your all-in-one Discord companion.
+
+### TODO
+[Wisp Core GitHub Project Board](https://github.com/orgs/wispgg/projects/3).
diff --git a/Rocket.toml b/Rocket.toml
new file mode 100644
index 0000000..2f99dde
--- /dev/null
+++ b/Rocket.toml
@@ -0,0 +1,9 @@
+[development]
+address = "localhost"
+port = 1337
+log = "normal"
+
+[production]
+address = "0.0.0.0"
+port = 8020
+log = "critical"
diff --git a/rust-toolchain b/rust-toolchain
new file mode 100644
index 0000000..bf867e0
--- /dev/null
+++ b/rust-toolchain
@@ -0,0 +1 @@
+nightly
diff --git a/src/core/handler.rs b/src/core/handler.rs
index 782cc6c..7fbb005 100644
--- a/src/core/handler.rs
+++ b/src/core/handler.rs
@@ -27,7 +27,6 @@ use std::time::Duration;
static LOAD_TIMERS: Once = Once::new();
pub struct Handler;
-
impl EventHandler for Handler {
fn ready(&self, ctx: Context, ready: Ready) {
CACHE.write().settings_mut().max_messages(MESSAGE_CACHE);
@@ -68,6 +67,14 @@ impl EventHandler for Handler {
} else { failed!(API_FAIL); }
});
info!("Logged in as {}#{}.", ready.user.name, ready.user.discriminator);
+
+ // thread::spawn(move || {
+ // rocket::ignite()
+ // .mount("/", routes![
+ // crate::core::webserver::icon,
+ // crate::core::webserver::index
+ // ]).launch();
+ // });
}
fn cached(&self, ctx: Context, guilds: Vec<GuildId>) {
@@ -100,9 +107,12 @@ impl EventHandler for Handler {
info!("Caching complete.");
}
- fn message(&self, _: Context, message: Message) {
+ fn message(&self, _ctx: Context, message: Message) {
+ // check_error!(message.guild().unwrap().read()
+ // .edit_member(712088369206919269, |member| member.nickname("Wisp")));
+
if message.content.contains("uwu!") {
- check_error!(message.channel_id.say("Uwufier has been re-branded! However, due to Discord verified bot limitations, we are still awaiting for our username change to go through, until then, meet Wisp, your all-in-one Discord companion. For future reference, please use the new prefix; `w.` !"));
+ check_error!(message.channel_id.say("Uwufier has been re-branded! However, due to the current limitations in place for verified Discord bots, we are still awaiting for our username change to go through, until then, meet Wisp, your all-in-one Discord companion. For future reference, please use the new prefix; `w.`!"));
}
if message.mention_everyone {
diff --git a/src/core/mod.rs b/src/core/mod.rs
index 2ddcba0..3abe541 100644
--- a/src/core/mod.rs
+++ b/src/core/mod.rs
@@ -6,3 +6,4 @@ pub mod handler;
pub mod model;
pub mod timers;
pub mod utils;
+// pub mod webserver;
diff --git a/src/core/model.rs b/src/core/model.rs
index ade2930..1b19f13 100644
--- a/src/core/model.rs
+++ b/src/core/model.rs
@@ -1,9 +1,13 @@
use crate::core::api;
use crate::core::timers::TimerClient;
use crate::db::Database;
-use serenity::client::bridge::gateway::ShardManager;
+use serenity::client::bridge::{
+ gateway::ShardManager,
+ // voice::ClientVoiceManager
+};
use serenity::model::id::UserId;
use serenity::prelude::Mutex;
+// use serenity::voice;
use std::sync::Arc;
use typemap::Key;
@@ -31,3 +35,8 @@ pub struct TC;
impl Key for TC {
type Value = Arc<Mutex<TimerClient>>;
}
+
+// pub struct VoiceManager;
+// impl Key for VoiceManager {
+// type Value = Arc<Mutex<ClientVoiceManager>>;
+// }
diff --git a/src/core/webserver.rs b/src/core/webserver.rs
new file mode 100644
index 0000000..0234fda
--- /dev/null
+++ b/src/core/webserver.rs
@@ -0,0 +1,22 @@
+use rocket::response::content;
+use rocket::response::NamedFile;
+// use serenity::prelude::*;
+// use std::sync::Arc;
+
+#[get("/favicon.ico")]
+pub fn icon() -> Option<NamedFile> {
+ NamedFile::open("static/favicon.ico").ok()
+}
+
+#[get("/")]
+pub fn index() -> content::Json<&'static str> {
+ content::Json("{\"message\": \"online\"}")
+}
+
+// #[get("/")]
+// pub fn get_context() -> content::Json<&'static str> {
+// let ctx = Arc::new(Context);
+// let ctx_clone = Arc::clone(&ctx);
+
+// content::Json(format!("{\"message\": \"{}\"}", data))
+// }
diff --git a/src/lib.rs b/src/lib.rs
index 0970dcf..ec43ea4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,10 +1,12 @@
#![recursion_limit = "128"]
#![allow(proc_macro_derive_resolution_fallback)]
+// #![feature(decl_macro)]
#[macro_use] extern crate diesel;
#[macro_use] extern crate lazy_static;
#[macro_use] extern crate log;
#[macro_use] extern crate serde_derive;
+// #[macro_use] extern crate rocket;
extern crate serenity;
extern crate chrono;
extern crate forecast;
@@ -22,6 +24,7 @@ extern crate sysinfo;
extern crate threadpool;
extern crate typemap;
extern crate urbandictionary;
+// extern crate rocket_contrib;
pub mod macros;
pub mod core;
diff --git a/src/modules/commands/general/mod.rs b/src/modules/commands/general/mod.rs
index acff760..ce87755 100644
--- a/src/modules/commands/general/mod.rs
+++ b/src/modules/commands/general/mod.rs
@@ -5,6 +5,7 @@ pub mod nsfw;
pub mod fun;
pub mod utilities;
pub mod animals;
+// pub mod voice;
use self::misc::*;
use self::nsfw::*;
@@ -13,6 +14,7 @@ use self::nsfw::*;
use self::fun::*;
use self::utilities::*;
use self::animals::*;
+// use self::voice::*;
use serenity::framework::standard::CreateGroup;
pub fn init_animals() -> CreateGroup {
@@ -119,4 +121,6 @@ pub fn init_utilities() -> CreateGroup {
.cmd("user", UserInfo)
// .cmd("weather", Weather)
.cmd("wisp", Wisp)
+ // .cmd("join", Join)
+ // .cmd("leave", Leave)
}
diff --git a/src/modules/commands/general/voice.rs b/src/modules/commands/general/voice.rs
new file mode 100644
index 0000000..1849f78
--- /dev/null
+++ b/src/modules/commands/general/voice.rs
@@ -0,0 +1,108 @@
+// use crate::core::model::ApiClient;
+// use crate::core::consts::*;
+use crate::core::model::*;
+use serenity::framework::standard::{
+ Args,
+ Command,
+ CommandError,
+ CommandOptions
+};
+use serenity::model::channel::Message;
+use serenity::prelude::Context;
+use std::sync::Arc;
+
+pub struct Join;
+impl Command for Join {
+ fn options(&self) -> Arc<CommandOptions> {
+ let default = CommandOptions::default();
+ let options = CommandOptions {
+ // desc: Some("I see your a individual of culture...".to_string()),
+ // usage: Some("[tags]".to_string()),
+ // example: Some("minecraft".to_string()),
+ guild_only: true,
+ owner_privileges: false,
+ ..default
+ };
+ Arc::new(options)
+ }
+
+ fn execute(&self, ctx: &mut Context, message: &Message, _args: Args) -> Result<(), CommandError> {
+ // if not deafened, ask to please deeafen
+ let channel_id = message.guild().unwrap().read()
+ .voice_states.get(&message.author.id)
+ .and_then(|voice_state| voice_state.channel_id);
+
+ let connect_to = match channel_id {
+ Some(channel) => channel,
+ None => {
+ message.channel_id.say("You aren't in a voice channel...")?;
+
+ return Ok(())
+ }
+ };
+
+ let manager_lock = ctx.data.lock().get::<VoiceManager>().cloned()
+ .expect("Expected VoiceManager in ShareMap."); // mut
+ let mut manager = manager_lock.lock();
+ let has_handler = manager.get(message.guild().unwrap().read().id).is_some();
+
+ if has_handler {
+ message.channel_id.say(format!("Sorry, but I'm already in <#{}>.", connect_to))?;
+ } else {
+ if manager.join(message.guild().unwrap().read().id, connect_to).is_some() {
+ message.channel_id.say(format!("I'm now in <#{}>.", connect_to))?;
+ } else {
+ message.channel_id.say("I've encountered an error while trying to join your voice channel.")?;
+ }
+ }
+
+ Ok(())
+ }
+}
+
+pub struct Leave;
+impl Command for Leave {
+ fn options(&self) -> Arc<CommandOptions> {
+ let default = CommandOptions::default();
+ let options = CommandOptions {
+ // desc: Some("I see your a individual of culture...".to_string()),
+ // usage: Some("[tags]".to_string()),
+ // example: Some("minecraft".to_string()),
+ guild_only: true,
+ owner_privileges: false,
+ ..default
+ };
+ Arc::new(options)
+ }
+
+ fn execute(&self, ctx: &mut Context, message: &Message, _args: Args) -> Result<(), CommandError> {
+ let channel_id = message.guild().unwrap().read()
+ .voice_states.get(&message.author.id)
+ .and_then(|voice_state| voice_state.channel_id);
+
+ let connect_to = match channel_id {
+ Some(channel) => channel,
+ None => {
+ message.channel_id.say("You aren't in a voice channel... Only the people within a given voice channel can make me leave.")?;
+
+ return Ok(())
+ }
+ };
+
+ let manager_lock = ctx.data.lock().get::<VoiceManager>().cloned()
+ .expect("Expected VoiceManager in ShareMap."); // mut
+ let mut manager = manager_lock.lock();
+ let has_handler = manager.get(message.guild().unwrap().read().id).is_some();
+
+ if has_handler {
+ manager.remove(message.guild().unwrap().read().id);
+
+ message.channel_id.say(format!("I've left <#{:?}>.",
+ manager.get(message.guild().unwrap().read().id)))?;
+ } else {
+ message.channel_id.say("Sorry, but I'm not in a voice channel right now.")?;
+ }
+
+ Ok(())
+ }
+}
diff --git a/src/wisp.rs b/src/wisp.rs
index f3ffd9b..e1f2310 100644
--- a/src/wisp.rs
+++ b/src/wisp.rs
@@ -9,6 +9,7 @@ use serenity::Error as SerenityError;
use serenity::http;
use serenity::model::id::UserId;
use serenity::prelude::{Client, Mutex};
+// use serenity::voice;
use std::collections::HashSet;
use std::env;
use std::sync::Arc;
@@ -25,6 +26,7 @@ impl WispClient {
data.insert::<SerenityShardManager>(Arc::clone(&client.shard_manager));
data.insert::<ApiClient>(Arc::new(api_client));
data.insert::<TC>(Arc::new(Mutex::new(tc)));
+ // data.insert::<VoiceManager>(Arc::clone(&client.voice_manager));
}
let owners = match http::get_current_application_info() {
Ok(info) => {
@@ -50,6 +52,7 @@ impl WispClient {
data.insert::<SerenityShardManager>(Arc::clone(&client.shard_manager));
data.insert::<ApiClient>(Arc::new(api_client));
data.insert::<TC>(Arc::new(Mutex::new(tc)));
+ // data.insert::<VoiceManager>(Arc::clone(&client.voice_manager));
}
client.with_framework(WispFramework::new(owners));
WispClient(client)
diff --git a/static/icon-256x256.ico b/static/icon-256x256.ico
new file mode 100644
index 0000000..72267b2
--- /dev/null
+++ b/static/icon-256x256.ico
Binary files differ