Compare commits
No commits in common. "408cd38d4c323105f2172e2148172303f1652ed4" and "b7bb17a42c0a0ece3c87b017c5aeb3d371487a81" have entirely different histories.
408cd38d4c
...
b7bb17a42c
4 changed files with 21 additions and 78 deletions
BIN
src/desu.jpg
BIN
src/desu.jpg
Binary file not shown.
Before Width: | Height: | Size: 121 KiB |
|
@ -1,38 +1,18 @@
|
||||||
use futures::future::BoxFuture;
|
use crate::simple_responder;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use serenity::async_trait;
|
use serenity::async_trait;
|
||||||
use serenity::model::channel::Message;
|
use serenity::model::channel::Message;
|
||||||
use serenity::prelude::{Context, EventHandler};
|
use serenity::prelude::{Context, EventHandler};
|
||||||
|
|
||||||
lazy_static! {
|
// Yes, the blocks are necessary, rustc is bugged; check macro declaration
|
||||||
static ref REGEX: Regex = Regex::new("(?:[fF][uU]){3,}").unwrap();
|
// for more info.
|
||||||
}
|
simple_responder!(FufufuResponder, r"(?:[fF][uU]){3,}", { get_desu() });
|
||||||
|
|
||||||
pub(crate) struct FufufuResponder;
|
const DESU_STRINGS: &[&str] = &[
|
||||||
|
"です。",
|
||||||
#[async_trait]
|
"desu~",
|
||||||
impl EventHandler for FufufuResponder {
|
"desu.",
|
||||||
async fn message(&self, ctx: Context, message: Message) {
|
|
||||||
if REGEX.is_match(&message.content_safe(ctx.clone()).await) {
|
|
||||||
use rand::seq::SliceRandom;
|
|
||||||
use rand::thread_rng;
|
|
||||||
let random_action = DESU_ACTIONS.choose(&mut thread_rng()).unwrap().clone();
|
|
||||||
let random_action = random_action(ctx, message);
|
|
||||||
random_action.await.unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type DesuAction<'r, T> = &'r (dyn Fn(Context, Message) -> T + Sync);
|
|
||||||
|
|
||||||
const DESU_ACTIONS: &[DesuAction<BoxFuture<Result<Message, serenity::Error>>>] = &[
|
|
||||||
&|ctx, msg| Box::pin(msg.channel_id.say(ctx, "です。")),
|
|
||||||
&|ctx, msg| Box::pin(msg.channel_id.say(ctx, "desu~")),
|
|
||||||
&|ctx, msg| Box::pin(msg.channel_id.say(ctx, "desu.")),
|
|
||||||
&|ctx, msg| {
|
|
||||||
Box::pin(msg.channel_id.say(
|
|
||||||
ctx,
|
|
||||||
r#"
|
r#"
|
||||||
```
|
```
|
||||||
ででででででででででで すす
|
ででででででででででで すす
|
||||||
|
@ -45,22 +25,16 @@ const DESU_ACTIONS: &[DesuAction<BoxFuture<Result<Message, serenity::Error>>>] =
|
||||||
でで すす
|
でで すす
|
||||||
でで すす
|
でで すす
|
||||||
```"#,
|
```"#,
|
||||||
))
|
|
||||||
},
|
|
||||||
&|ctx, msg| {
|
|
||||||
// https://imgur.com/a/yOb5n
|
|
||||||
// One day.
|
|
||||||
Box::pin(
|
|
||||||
msg.channel_id
|
|
||||||
.say(ctx, "https://www.youtube.com/watch?v=60mLvBWOMb4"),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
&|ctx, msg| {
|
|
||||||
Box::pin(msg.channel_id.send_message(ctx, |m| {
|
|
||||||
m.add_file(serenity::http::AttachmentType::Bytes {
|
|
||||||
data: std::borrow::Cow::from(&include_bytes!("../desu.jpg")[..]),
|
|
||||||
filename: "desu.jpg".to_string(),
|
|
||||||
})
|
|
||||||
}))
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
fn get_desu() -> &'static str {
|
||||||
|
use rand::seq::SliceRandom;
|
||||||
|
use rand::thread_rng;
|
||||||
|
|
||||||
|
DESU_STRINGS.choose(&mut thread_rng()).unwrap()
|
||||||
|
// // https://imgur.com/a/yOb5n
|
||||||
|
// messageList.add(channel -> channel.sendMessage(new MessageBuilder()
|
||||||
|
// .setContent("https://www.youtube.com/watch?v=60mLvBWOMb4").build()));
|
||||||
|
// messageList.add(channel -> channel.sendFile(Desu.class.getResourceAsStream("/desu/desu.jpg"), "desu.jpg"));
|
||||||
|
// messageList.add(channel -> channel.sendMessage("desu~"));
|
||||||
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use ahhhh::YellResponder;
|
use ahhhh::YellResponder;
|
||||||
use best_doctor::BestDoctorResponder;
|
use best_doctor::BestDoctorResponder;
|
||||||
use fufufu::FufufuResponder;
|
use fufufu::FufufuResponder;
|
||||||
use reee::ReeeResponder;
|
|
||||||
use serenity::async_trait;
|
use serenity::async_trait;
|
||||||
use serenity::model::channel::Message;
|
use serenity::model::channel::Message;
|
||||||
use serenity::prelude::{Context, EventHandler};
|
use serenity::prelude::{Context, EventHandler};
|
||||||
|
@ -9,7 +8,6 @@ use serenity::prelude::{Context, EventHandler};
|
||||||
mod ahhhh;
|
mod ahhhh;
|
||||||
mod best_doctor;
|
mod best_doctor;
|
||||||
mod fufufu;
|
mod fufufu;
|
||||||
mod reee;
|
|
||||||
|
|
||||||
pub(crate) struct Handler {
|
pub(crate) struct Handler {
|
||||||
responders: Vec<Box<dyn EventHandler>>,
|
responders: Vec<Box<dyn EventHandler>>,
|
||||||
|
@ -22,7 +20,6 @@ impl Default for Handler {
|
||||||
Box::new(BestDoctorResponder),
|
Box::new(BestDoctorResponder),
|
||||||
Box::new(FufufuResponder),
|
Box::new(FufufuResponder),
|
||||||
Box::new(YellResponder),
|
Box::new(YellResponder),
|
||||||
Box::new(ReeeResponder),
|
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use regex::Regex;
|
|
||||||
use serenity::async_trait;
|
|
||||||
use serenity::model::channel::Message;
|
|
||||||
use serenity::prelude::{Context, EventHandler};
|
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
static ref REGEX: Regex = Regex::new("RE{5,}").unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) struct ReeeResponder;
|
|
||||||
|
|
||||||
#[async_trait]
|
|
||||||
impl EventHandler for ReeeResponder {
|
|
||||||
async fn message(&self, ctx: Context, message: Message) {
|
|
||||||
if REGEX.is_match(&message.content_safe(ctx.clone()).await) {
|
|
||||||
if let Some(guild_id) = message.guild_id {
|
|
||||||
if guild_id == 679888177951277102 {
|
|
||||||
message
|
|
||||||
.channel_id
|
|
||||||
.say(ctx, "<:texaspat:680231475928498217>")
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue