mirror of
https://github.com/Noratrieb/widetom.git
synced 2026-01-14 08:55:02 +01:00
xp command
This commit is contained in:
parent
de4403a891
commit
456584c596
5 changed files with 100 additions and 27 deletions
68
Cargo.lock
generated
68
Cargo.lock
generated
|
|
@ -361,6 +361,17 @@ dependencies = [
|
|||
"wasi 0.9.0+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9495705279e7140bf035dde1f6e750c162df8b625267cd52cc44e0b156732c8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi 0.10.0+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.3.0"
|
||||
|
|
@ -800,11 +811,23 @@ version = "0.7.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.1.16",
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
"rand_chacha 0.2.2",
|
||||
"rand_core 0.5.1",
|
||||
"rand_hc 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha 0.3.0",
|
||||
"rand_core 0.6.2",
|
||||
"rand_hc 0.3.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -814,7 +837,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
"rand_core 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.6.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -823,7 +856,16 @@ version = "0.5.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"getrandom 0.1.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
|
||||
dependencies = [
|
||||
"getrandom 0.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -832,7 +874,16 @@ version = "0.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
"rand_core 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
|
||||
dependencies = [
|
||||
"rand_core 0.6.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -1267,7 +1318,7 @@ dependencies = [
|
|||
"httparse",
|
||||
"input_buffer",
|
||||
"log",
|
||||
"rand",
|
||||
"rand 0.7.3",
|
||||
"sha-1",
|
||||
"url",
|
||||
"utf-8",
|
||||
|
|
@ -1513,6 +1564,7 @@ dependencies = [
|
|||
"async-trait",
|
||||
"fancy-regex",
|
||||
"lazy_static",
|
||||
"rand 0.8.3",
|
||||
"serenity",
|
||||
"tokio",
|
||||
"toml",
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ async-trait = "0.1.50"
|
|||
lazy_static = "1.4.0"
|
||||
toml = "0.5.8"
|
||||
fancy-regex = "0.5.0"
|
||||
rand = "0.8.3"
|
||||
|
||||
[dependencies.serenity]
|
||||
version = "0.10.2"
|
||||
|
|
|
|||
|
|
@ -15,3 +15,9 @@ responses = [
|
|||
["tom", "<:tom:811324632082415626>"],
|
||||
["hui", "PRAISE hUI, THE ALMIGHTY OR PERISH AS FOOLS!!!"],
|
||||
]
|
||||
|
||||
# xp application zitate for the xp command
|
||||
xp = ["Bin n Freund von Brit", "I will learn", "sehr gute experience can approve",
|
||||
"Keine Ahnung Bro", "Das hab ich mich actually auch schon gefragt", "Yo le diría que desactivara el modulo Autonick y reescribiera el nombre sin la parte del nivel",
|
||||
"eject the bot", "i'm getting held gunpoint to fill out this formular and i have no clue why...", "what Bot", "sex", "dude wtf why are fucjk you", "dreckscode",
|
||||
"ich brauche immer #command-testing, sonst recht gut", "#faq you", "<leere>", "I would call myself a friend of Conny"]
|
||||
32
src/lib.rs
32
src/lib.rs
|
|
@ -9,34 +9,34 @@ use serenity::model::id::EmojiId;
|
|||
use toml::Value;
|
||||
use fancy_regex::Regex;
|
||||
|
||||
pub static CONFIG_ERR: &'static str = "Invalid config file";
|
||||
|
||||
lazy_static! {
|
||||
static ref REACTION_EMOTES: HashMap<String, EmojiId> = {
|
||||
let err = "Invalid config file";
|
||||
let mut m = HashMap::new();
|
||||
|
||||
pub static ref CONFIG: Value = {
|
||||
let config = fs::read_to_string("config.toml").expect("Config file not found. Add 'config.toml' to this directory");
|
||||
let value = config.parse::<Value>().expect(err);
|
||||
let emotes = value.get("emotes").expect(err);
|
||||
config.parse::<Value>().expect(CONFIG_ERR)
|
||||
};
|
||||
|
||||
for v in emotes.as_array().expect(err) {
|
||||
let name = v[0].as_str().expect(err).to_string();
|
||||
let id = EmojiId(v[1].as_integer().expect(err).clone() as u64);
|
||||
static ref REACTION_EMOTES: HashMap<String, EmojiId> = {
|
||||
let mut m = HashMap::new();
|
||||
let emotes = CONFIG.get("emotes").expect(CONFIG_ERR);
|
||||
|
||||
for v in emotes.as_array().expect(CONFIG_ERR) {
|
||||
let name = v[0].as_str().expect(CONFIG_ERR).to_string();
|
||||
let id = EmojiId(v[1].as_integer().expect(CONFIG_ERR).clone() as u64);
|
||||
m.insert(name, id);
|
||||
}
|
||||
m
|
||||
};
|
||||
|
||||
static ref RESPONSES: HashMap<String, String> = {
|
||||
let err = "Invalid config file";
|
||||
let mut m = HashMap::new();
|
||||
|
||||
let config = fs::read_to_string("config.toml").expect("Config file not found. Add 'config.toml' to this directory");
|
||||
let value = config.parse::<Value>().expect(err);
|
||||
let emotes = value.get("responses").expect(err);
|
||||
let emotes = CONFIG.get("responses").expect(CONFIG_ERR);
|
||||
|
||||
for v in emotes.as_array().expect(err) {
|
||||
let trigger = v[0].as_str().expect(err).to_string();
|
||||
let response = v[1].as_str().expect(err).to_string();
|
||||
for v in emotes.as_array().expect(CONFIG_ERR) {
|
||||
let trigger = v[0].as_str().expect(CONFIG_ERR).to_string();
|
||||
let response = v[1].as_str().expect(CONFIG_ERR).to_string();
|
||||
m.insert(trigger, response);
|
||||
}
|
||||
m
|
||||
|
|
|
|||
18
src/main.rs
18
src/main.rs
|
|
@ -13,8 +13,11 @@ use serenity::http::Http;
|
|||
use serenity::model::id::UserId;
|
||||
use serenity::utils::{content_safe, ContentSafeOptions};
|
||||
use uwuifier::uwuify_str_sse;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use widertom::{normal_message, reply};
|
||||
use widertom::{normal_message, reply, CONFIG, CONFIG_ERR};
|
||||
use rand::Rng;
|
||||
use toml::Value;
|
||||
|
||||
#[group]
|
||||
#[commands(say)]
|
||||
|
|
@ -22,7 +25,7 @@ use widertom::{normal_message, reply};
|
|||
struct General;
|
||||
|
||||
#[group]
|
||||
#[commands(uwuify)]
|
||||
#[commands(uwuify, xp)]
|
||||
#[description = "meme commands"]
|
||||
struct Meme;
|
||||
|
||||
|
|
@ -118,6 +121,17 @@ async fn shutdown(ctx: &Context, msg: &Message, _: Args) -> CommandResult {
|
|||
}
|
||||
|
||||
|
||||
#[command]
|
||||
async fn xp(ctx: &Context, msg: &Message, _: Args) -> CommandResult {
|
||||
lazy_static! {
|
||||
static ref XP_RESPONSES: &'static Vec<Value> = CONFIG.get("xp").expect(CONFIG_ERR).as_array().expect(CONFIG_ERR);
|
||||
}
|
||||
let index = rand::thread_rng().gen_range(0..XP_RESPONSES.len());
|
||||
let random_value = XP_RESPONSES[index].as_str().expect(CONFIG_ERR);
|
||||
msg.channel_id.say(&ctx.http, random_value).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[help]
|
||||
#[individual_command_tip =
|
||||
"w i d e t o m\n\n\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue