fix multiline reminders. disable unused gateways if dm disabled
This commit is contained in:
parent
88976dc244
commit
9003beb1bb
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1314,7 +1314,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reminder_rs"
|
name = "reminder_rs"
|
||||||
version = "1.4.0"
|
version = "1.4.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"Inflector",
|
"Inflector",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "reminder_rs"
|
name = "reminder_rs"
|
||||||
version = "1.4.0"
|
version = "1.4.1"
|
||||||
authors = ["jellywx <judesouthworth@pm.me>"]
|
authors = ["jellywx <judesouthworth@pm.me>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ const THEME_COLOR_FALLBACK: u32 = 0x8fb677;
|
|||||||
|
|
||||||
use std::{collections::HashSet, env, iter::FromIterator};
|
use std::{collections::HashSet, env, iter::FromIterator};
|
||||||
|
|
||||||
use regex::Regex;
|
use regex::{Regex, RegexBuilder};
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref REGEX_CHANNEL: Regex = Regex::new(r#"^\s*<#(\d+)>\s*$"#).unwrap();
|
pub static ref REGEX_CHANNEL: Regex = Regex::new(r#"^\s*<#(\d+)>\s*$"#).unwrap();
|
||||||
@ -49,19 +49,25 @@ lazy_static! {
|
|||||||
|
|
||||||
pub static ref REGEX_CHANNEL_USER: Regex = Regex::new(r#"\s*<(#|@)(?:!)?(\d+)>\s*"#).unwrap();
|
pub static ref REGEX_CHANNEL_USER: Regex = Regex::new(r#"\s*<(#|@)(?:!)?(\d+)>\s*"#).unwrap();
|
||||||
|
|
||||||
pub static ref REGEX_REMIND_COMMAND: Regex = Regex::new(
|
pub static ref REGEX_REMIND_COMMAND: Regex = RegexBuilder::new(
|
||||||
r#"(?P<mentions>(?:<@\d+>\s|<@!\d+>\s|<#\d+>\s)*)(?P<time>(?:(?:\d+)(?:s|m|h|d|:|/|-|))+)(?:\s+(?P<interval>(?:(?:\d+)(?:s|m|h|d|))+))?(?:\s+(?P<expires>(?:(?:\d+)(?:s|m|h|d|:|/|-|))+))?\s+(?P<content>.*)"#
|
r#"(?P<mentions>(?:<@\d+>\s|<@!\d+>\s|<#\d+>\s)*)(?P<time>(?:(?:\d+)(?:s|m|h|d|:|/|-|))+)(?:\s+(?P<interval>(?:(?:\d+)(?:s|m|h|d|))+))?(?:\s+(?P<expires>(?:(?:\d+)(?:s|m|h|d|:|/|-|))+))?\s+(?P<content>.*)"#
|
||||||
)
|
)
|
||||||
|
.dot_matches_new_line(true)
|
||||||
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
pub static ref REGEX_NATURAL_COMMAND_1: Regex = Regex::new(
|
pub static ref REGEX_NATURAL_COMMAND_1: Regex = RegexBuilder::new(
|
||||||
r#"(?P<time>.*?) (?:send|say) (?P<msg>.*?)(?: to (?P<mentions>((?:<@\d+>)|(?:<@!\d+>)|(?:<#\d+>)|(?:\s+))+))?$"#
|
r#"(?P<time>.*?) (?:send|say) (?P<msg>.*?)(?: to (?P<mentions>((?:<@\d+>)|(?:<@!\d+>)|(?:<#\d+>)|(?:\s+))+))?$"#
|
||||||
)
|
)
|
||||||
|
.dot_matches_new_line(true)
|
||||||
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
pub static ref REGEX_NATURAL_COMMAND_2: Regex = Regex::new(
|
pub static ref REGEX_NATURAL_COMMAND_2: Regex = RegexBuilder::new(
|
||||||
r#"(?P<msg>.*) every (?P<interval>.*?)(?: (?:until|for) (?P<expires>.*?))?$"#
|
r#"(?P<msg>.*) every (?P<interval>.*?)(?: (?:until|for) (?P<expires>.*?))?$"#
|
||||||
)
|
)
|
||||||
|
.dot_matches_new_line(true)
|
||||||
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
pub static ref SUBSCRIPTION_ROLES: HashSet<u64> = HashSet::from_iter(
|
pub static ref SUBSCRIPTION_ROLES: HashSet<u64> = HashSet::from_iter(
|
||||||
|
14
src/main.rs
14
src/main.rs
@ -167,11 +167,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|||||||
.map_ok(|user| user.id.as_u64().to_owned())
|
.map_ok(|user| user.id.as_u64().to_owned())
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
let dm_enabled = env::var("DM_ENABLED").map_or(true, |var| var == "1");
|
||||||
|
|
||||||
let framework = RegexFramework::new(logged_in_id)
|
let framework = RegexFramework::new(logged_in_id)
|
||||||
.default_prefix(DEFAULT_PREFIX.clone())
|
.default_prefix(DEFAULT_PREFIX.clone())
|
||||||
.case_insensitive(env::var("CASE_INSENSITIVE").map_or(true, |var| var == "1"))
|
.case_insensitive(env::var("CASE_INSENSITIVE").map_or(true, |var| var == "1"))
|
||||||
.ignore_bots(env::var("IGNORE_BOTS").map_or(true, |var| var == "1"))
|
.ignore_bots(env::var("IGNORE_BOTS").map_or(true, |var| var == "1"))
|
||||||
.dm_enabled(env::var("DM_ENABLED").map_or(true, |var| var == "1"))
|
.dm_enabled(dm_enabled)
|
||||||
// info commands
|
// info commands
|
||||||
.add_command("ping", &info_cmds::PING_COMMAND)
|
.add_command("ping", &info_cmds::PING_COMMAND)
|
||||||
.add_command("help", &info_cmds::HELP_COMMAND)
|
.add_command("help", &info_cmds::HELP_COMMAND)
|
||||||
@ -217,13 +219,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
|||||||
let framework_arc = Arc::new(Box::new(framework) as Box<dyn Framework + Send + Sync>);
|
let framework_arc = Arc::new(Box::new(framework) as Box<dyn Framework + Send + Sync>);
|
||||||
|
|
||||||
let mut client = Client::builder(&token)
|
let mut client = Client::builder(&token)
|
||||||
.intents(
|
.intents(if dm_enabled {
|
||||||
GatewayIntents::GUILD_MESSAGES
|
GatewayIntents::GUILD_MESSAGES
|
||||||
| GatewayIntents::GUILDS
|
| GatewayIntents::GUILDS
|
||||||
| GatewayIntents::GUILD_MESSAGE_REACTIONS
|
| GatewayIntents::GUILD_MESSAGE_REACTIONS
|
||||||
| GatewayIntents::DIRECT_MESSAGES
|
| GatewayIntents::DIRECT_MESSAGES
|
||||||
| GatewayIntents::DIRECT_MESSAGE_REACTIONS,
|
| GatewayIntents::DIRECT_MESSAGE_REACTIONS
|
||||||
)
|
} else {
|
||||||
|
GatewayIntents::GUILD_MESSAGES
|
||||||
|
| GatewayIntents::GUILDS
|
||||||
|
| GatewayIntents::GUILD_MESSAGE_REACTIONS
|
||||||
|
})
|
||||||
.event_handler(Handler)
|
.event_handler(Handler)
|
||||||
.framework_arc(framework_arc.clone())
|
.framework_arc(framework_arc.clone())
|
||||||
.await
|
.await
|
||||||
|
Loading…
Reference in New Issue
Block a user