idk
This commit is contained in:
Generated
+226
-227
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
||||
\n,\n
|
||||
,
|
||||
.,sk
|
||||
,,sw
|
||||
0,sqs
|
||||
1,sqk
|
||||
2,sqw
|
||||
3,sqqs
|
||||
4,sqqk
|
||||
5,sqqw
|
||||
6,sqqq
|
||||
7,ks
|
||||
8,kk
|
||||
9,kw
|
||||
a,kqs
|
||||
b,kqk
|
||||
c,kqw
|
||||
d,kqqk
|
||||
e,kqqw
|
||||
f,kqqq
|
||||
g,ws
|
||||
h,wk
|
||||
i,ww
|
||||
j,wqs
|
||||
k,wqk
|
||||
l,wqw
|
||||
m,wqqk
|
||||
n,wqqw
|
||||
o,wqqq
|
||||
p,qs
|
||||
q,qk
|
||||
r,qw
|
||||
s,qqs
|
||||
t,qqk
|
||||
u,qqw
|
||||
v,qqqs
|
||||
w,qqqk
|
||||
x,qqqw
|
||||
y,qqqqw
|
||||
z,qqqqq
|
||||
+76
-26
@@ -1,7 +1,7 @@
|
||||
#![feature(pattern)]
|
||||
|
||||
use dotenv::dotenv;
|
||||
use serenity::all::{MessageReaction, RoleId, User, UserId};
|
||||
use serenity::all::{Command, CreateInteractionResponse, CreateInteractionResponseFollowup, CreateInteractionResponseMessage, GuildId, Interaction, MessageReaction, RoleId, User, UserId};
|
||||
use serenity::async_trait;
|
||||
use serenity::model::channel::Message;
|
||||
use serenity::model::gateway::Ready;
|
||||
@@ -10,6 +10,8 @@ use std::env;
|
||||
use std::str::pattern::Pattern;
|
||||
use std::sync::Arc;
|
||||
|
||||
mod translate;
|
||||
|
||||
struct Handler;
|
||||
|
||||
const STEVENIST_ROLE: u64 = 1315038173730181140;
|
||||
@@ -44,7 +46,7 @@ impl EventHandler for Handler {
|
||||
.await;
|
||||
}
|
||||
|
||||
if msg.channel_id == 1315118069101629530 && !msg.is_own(ctx.clone()) {
|
||||
if msg.channel_id == 1315118069101629530 && msg.author != **ctx.cache.current_user() {
|
||||
if message != "fr" {
|
||||
let _ = msg.react(ctx.clone(), '❗').await;
|
||||
let _ = msg.reply(ctx.clone(), "NON 'FR' MESSAGE DETECTED").await;
|
||||
@@ -73,35 +75,62 @@ impl EventHandler for Handler {
|
||||
}
|
||||
|
||||
let message = parse(&message);
|
||||
|
||||
if let Some(&"<@1315046876969566218>") = message.get(0) {
|
||||
println!("detected");
|
||||
if let Some(&"judge") = message.get(1) {
|
||||
if let Some(user) = message.get(2) {
|
||||
let user_id_str = user
|
||||
.strip_prefix("<@")
|
||||
.unwrap()
|
||||
.strip_suffix(">")
|
||||
.unwrap()
|
||||
.parse::<u64>()
|
||||
.unwrap();
|
||||
println!("{}", user_id_str);
|
||||
let user_id = UserId::new(user_id_str);
|
||||
if let Ok(user) = &ctx.http.get_member(guild_id.unwrap(), user_id).await {
|
||||
if user.roles.contains(&RoleId::new(HERETIC_ROLE)) {
|
||||
let _ = msg.reply(&ctx, "Heretic").await;
|
||||
} else if user.roles.contains(&RoleId::new(STEVENIST_ROLE)) {
|
||||
let _ = msg.reply(&ctx, "A Loyal Servant of Steven.").await;
|
||||
} else {
|
||||
let _ = msg.reply(&ctx, "Not a Heretic").await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
judge(&ctx, &msg, &message, guild_id).await;
|
||||
}
|
||||
}
|
||||
|
||||
async fn ready(&self, _: Context, ready: Ready) {
|
||||
if let Some(&"mods" | &"mods,") = message.get(0) {
|
||||
println!("mods");
|
||||
if let None = message.get(1) {
|
||||
msg.reply(&ctx, "...").await.unwrap();
|
||||
}
|
||||
|
||||
let verb = match *message.get(1).unwrap() {
|
||||
"drop" => "dropping".to_string(),
|
||||
"make" => "making".to_string(),
|
||||
"praise" => "praising".to_string(),
|
||||
"give" => "giving".to_string(),
|
||||
"shut" => "shutting".to_string(),
|
||||
"smite" => "smiting".to_string(),
|
||||
x => format!("{}ing", x),
|
||||
};
|
||||
|
||||
let response = verb + " " + &message[2..].join(" ");
|
||||
msg.reply(&ctx, response).await.unwrap();
|
||||
};
|
||||
}
|
||||
|
||||
async fn interaction_create(&self, ctx: Context, interaction: Interaction) {
|
||||
if let Interaction::Command(c) = interaction {
|
||||
let content = match c.data.name.as_str() {
|
||||
"say" => {
|
||||
if c.user.id != UserId::new(771822887421345812) {
|
||||
return;
|
||||
}
|
||||
|
||||
translate::run_say(c.data.options()[0].clone())
|
||||
},
|
||||
_ => String::new(),
|
||||
};
|
||||
|
||||
let _ = c.channel_id.say(&ctx.http, content).await;
|
||||
|
||||
let data = CreateInteractionResponseMessage::new().content("");
|
||||
let builder = CreateInteractionResponse::Message(data);
|
||||
let _ = c.create_response(&ctx.http, builder).await;
|
||||
};
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
async fn ready(&self, ctx: Context, ready: Ready) {
|
||||
|
||||
// set commands
|
||||
Command::create_global_command(&ctx.http, translate::register_say()).await.unwrap();
|
||||
|
||||
println!("{} is connected!", ready.user.name);
|
||||
}
|
||||
}
|
||||
@@ -126,7 +155,28 @@ async fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
fn judge(ctx: Context, msg: Message) {}
|
||||
async fn judge(ctx: &Context, msg: &Message, message: &Vec<&str>, guild_id: Option<GuildId>) {
|
||||
if let Some(user) = message.get(2) {
|
||||
let user_id_str = user
|
||||
.strip_prefix("<@")
|
||||
.unwrap()
|
||||
.strip_suffix(">")
|
||||
.unwrap()
|
||||
.parse::<u64>()
|
||||
.unwrap();
|
||||
println!("{}", user_id_str);
|
||||
let user_id = UserId::new(user_id_str);
|
||||
if let Ok(user) = &ctx.http.get_member(guild_id.unwrap(), user_id).await {
|
||||
if user.roles.contains(&RoleId::new(HERETIC_ROLE)) {
|
||||
let _ = msg.reply(&ctx, "Heretic").await;
|
||||
} else if user.roles.contains(&RoleId::new(STEVENIST_ROLE)) {
|
||||
let _ = msg.reply(&ctx, "A Loyal Servant of Steven.").await;
|
||||
} else {
|
||||
let _ = msg.reply(&ctx, "Not a Heretic").await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parse(message: &str) -> Vec<&str> {
|
||||
message
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
use std::collections::HashMap;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use serenity::all::{CreateCommand, CreateCommandOption, ResolvedOption, ResolvedValue};
|
||||
|
||||
|
||||
pub fn register_say() -> CreateCommand {
|
||||
CreateCommand::new("say")
|
||||
.dm_permission(true)
|
||||
.description("uhhhhhhhhhmm anyway")
|
||||
.add_option(
|
||||
CreateCommandOption::new(serenity::all::CommandOptionType::String, "text", "text")
|
||||
.required(true),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn run_say(resolved: ResolvedOption) -> String {
|
||||
if let ResolvedOption { value: ResolvedValue::String(text), .. } = resolved {
|
||||
encode(text)
|
||||
} else {
|
||||
String::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const MAPFILE: &str = include_str!("../mappings.txt");
|
||||
const MAPPINGS: LazyLock<(HashMap<&str, &str>, HashMap<&str, &str>)> = LazyLock::new(||{
|
||||
let mut forward_map = HashMap::new();
|
||||
let mut reverse_map = HashMap::new();
|
||||
|
||||
for line in MAPFILE.lines() {
|
||||
let (k, v) = line.split_once(",").unwrap();
|
||||
forward_map.insert(k, v);
|
||||
reverse_map.insert(v, k);
|
||||
}
|
||||
(forward_map, reverse_map)
|
||||
});
|
||||
|
||||
fn encode(data: &str) -> String {
|
||||
data.chars().map(|c| {
|
||||
*MAPPINGS.0.get(format!("{}", c).as_str()).unwrap()
|
||||
}).collect::<Vec<&str>>().join("")
|
||||
}
|
||||
|
||||
fn decode(data: &str) -> String {
|
||||
let mut buff = String::new();
|
||||
let mut res = String::new();
|
||||
|
||||
for ch in data.chars() {
|
||||
buff.push(ch);
|
||||
if MAPPINGS.1.contains_key(buff.as_str()) {
|
||||
res.push_str(MAPPINGS.1.get(buff.as_str()).unwrap());
|
||||
buff.clear();
|
||||
}
|
||||
}
|
||||
res
|
||||
}
|
||||
Reference in New Issue
Block a user