Skip to content

Commit

Permalink
feat: gemini question & deps update
Browse files Browse the repository at this point in the history
  • Loading branch information
GreeFine committed Dec 16, 2023
1 parent ea24535 commit 9d225a5
Show file tree
Hide file tree
Showing 11 changed files with 1,015 additions and 455 deletions.
1,001 changes: 585 additions & 416 deletions Cargo.lock

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ production = []

[dependencies]
procedural_macros = { path = "./procedural_macros" }
serenity = { version = "0.11.5", default-features = false, features = [
serenity = { version = "0.11", default-features = false, features = [
"builder",
"cache",
"client",
Expand All @@ -29,24 +29,25 @@ diesel = { version = "1.4", features = ["postgres", "r2d2", "chrono"] }
tokio = { version = "1.24", features = ["macros", "rt-multi-thread"] }
rocket = { version = "0.5.0-rc.1", features = ["json"] }
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", branch = "master" }
lazy_static = "1.4.0"
lazy_static = "1.4"
serde = "1.0"
serde_json = "1.0"
serde_derive = "1.0"
rand = "0.8"
chrono = "0.4"
log = "0.4"
pretty_env_logger = "0.4"
futures = "0.3.1"
pretty_env_logger = "0.5"
futures = "0.3"
reqwest = { version = "0.11", default-features = false, features = [
"blocking",
"json",
"rustls-tls",
] }
dotenv = "0.15.0"
strum = "0.20"
strum_macros = "0.20"
dotenv = "0.15"
strum = "0.25"
strum_macros = "0.25"
regex = "1"
base64 = "0.13"
chrono-tz = "0.6.3"
anyhow = "1.0.68"
base64 = "0.21"
chrono-tz = "0.8"
anyhow = "1.0"
yup-oauth2 = "8.3"
16 changes: 0 additions & 16 deletions docker-compose.postgres.yml

This file was deleted.

14 changes: 7 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
version: "3"

services:
bot:
build: .
container_name: "discord-rbot"
ports:
- 8080:8080
env_file: .env
# bot:
# build: .
# container_name: "discord-rbot"
# ports:
# - 8080:8080
# env_file: .env

postgres:
image: postgres
image: postgres:15
restart: always
ports:
- 5432:5432
Expand Down
4 changes: 2 additions & 2 deletions src/core/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ impl<'r> FromRequest<'r> for ApiKey<'r> {
}

match req.headers().get_one("Authorization") {
None => Outcome::Failure((Status::Unauthorized, ApiKeyError::Missing)),
None => Outcome::Error((Status::Unauthorized, ApiKeyError::Missing)),
Some(key) if is_valid(key) => Outcome::Success(ApiKey(key)),
Some(_) => Outcome::Failure((Status::Unauthorized, ApiKeyError::Invalid)),
Some(_) => Outcome::Error((Status::Unauthorized, ApiKeyError::Invalid)),
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion src/core/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
use std::{collections::HashMap, error::Error, fmt::Write, process, str::FromStr};

use super::{parse, slash_command};
use crate::features::anyone::anyone;
use crate::features::calendar::check_calendar;
use crate::features::{anyone::anyone, gemini};
use crate::features::{
archivage, emoji, funny, invite_action, ordering, project_manager, renaming,
};
Expand Down Expand Up @@ -329,6 +329,15 @@ lazy_static! {
channel: None,
usage: "@BOT emoji-steal (expected to be used as a reply to a message containing an emoji)",
permission: Role::User,
},
"question" =>
Command {
exec: gemini::question,
argument_min: 1,
argument_max: 100,
channel: None,
usage: "@BOT question \"What is the capital of France ?\"",
permission: Role::User,
}
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/eventhandler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl EventHandler for Handler {
async fn resume(&self, ctx: Context, _: ResumedEvent) {
info!("Resumed");
let data = &mut ctx.data.write().await;
// FIXME: This is cool but we never get a stoped event
// FIXME: This is cool but we never get a stopped event
data.get_mut::<Features>().unwrap().thread_control.resume();
}

Expand Down
5 changes: 3 additions & 2 deletions src/features/emoji.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use base64::{engine::general_purpose, Engine as _};
use procedural_macros::command;
use serenity::model::prelude::GuildId;

Expand All @@ -24,7 +25,7 @@ pub async fn add(params: CallBackParams<'_>) -> CallbackReturn {
let base64_img = format!(
"data:image/{};base64,{}",
extension,
base64::encode(response_body)
general_purpose::STANDARD.encode(response_body)
);

let guild = params.message.guild_id.unwrap_or(GuildId(GUILD_ID));
Expand Down Expand Up @@ -63,7 +64,7 @@ pub async fn emoji_steal(params: CallBackParams<'_>) -> CallbackReturn {
let base64_img = format!(
"data:image/{};base64,{}",
extension,
base64::encode(response_body)
general_purpose::STANDARD.encode(response_body)
);

let guild = params.message.guild_id.unwrap_or(GuildId(GUILD_ID));
Expand Down
Loading

0 comments on commit 9d225a5

Please sign in to comment.