aboutsummaryrefslogtreecommitdiff
path: root/src/ext/framework
diff options
context:
space:
mode:
authorIllia <[email protected]>2016-12-18 10:18:22 -0800
committerAustin Hellyer <[email protected]>2016-12-18 10:18:57 -0800
commit8e2c052a55e5e08c6e7ed643b399f1a7f69a2b25 (patch)
tree779e3d0632e6d0a0c4b4b0301c1368bb1d40acff /src/ext/framework
parentFix current application decoding (diff)
downloadserenity-8e2c052a55e5e08c6e7ed643b399f1a7f69a2b25.tar.xz
serenity-8e2c052a55e5e08c6e7ed643b399f1a7f69a2b25.zip
Add framework config to ignore webhook messages
Diffstat (limited to 'src/ext/framework')
-rw-r--r--src/ext/framework/configuration.rs18
-rw-r--r--src/ext/framework/mod.rs6
2 files changed, 23 insertions, 1 deletions
diff --git a/src/ext/framework/configuration.rs b/src/ext/framework/configuration.rs
index 404b248..d4ebb3e 100644
--- a/src/ext/framework/configuration.rs
+++ b/src/ext/framework/configuration.rs
@@ -81,6 +81,8 @@ pub struct Configuration {
pub disabled_commands: HashSet<String>,
#[doc(hidden)]
pub allow_dm: bool,
+ #[doc(hidden)]
+ pub ignore_webhooks: bool,
}
impl Configuration {
@@ -121,6 +123,21 @@ impl Configuration {
self
}
+ /// If set to false, bot will ignore any private messages.
+ pub fn allow_dm(mut self, allow_dm: bool) -> Self {
+ self.allow_dm = allow_dm;
+
+ self
+ }
+
+ /// If set to true, bot will ignore all commands called by webhooks.
+ /// True by default.
+ pub fn ignore_webhooks(mut self, ignore_webhooks: bool) -> Self {
+ self.ignore_webhooks = ignore_webhooks;
+
+ self
+ }
+
/// HashSet of user Ids whose commands will be ignored.
/// Guilds owned by user Ids will also be ignored.
pub fn blocked_users(mut self, users: HashSet<UserId>) -> Self {
@@ -340,6 +357,7 @@ impl Default for Configuration {
blocked_guilds: HashSet::default(),
disabled_commands: HashSet::default(),
allow_dm: true,
+ ignore_webhooks: true,
}
}
}
diff --git a/src/ext/framework/mod.rs b/src/ext/framework/mod.rs
index fb8c05c..777736f 100644
--- a/src/ext/framework/mod.rs
+++ b/src/ext/framework/mod.rs
@@ -341,7 +341,11 @@ impl Framework {
return;
}
- if !self.configuration.allow_dm {
+ if self.configuration.ignore_webhooks && message.is_webhook() {
+ return;
+ }
+
+ if !self.configuration.allow_dm && message.is_private() {
if let Some(ref message) = self.configuration.no_dm_message {
let _ = context.say(message);
}