From 18cc152769a35cd1705f045b9815cc90446034ef Mon Sep 17 00:00:00 2001 From: Taavi Date: Mon, 2 Jan 2017 03:38:36 +0300 Subject: Implement context message queueing Also the dreaded `ctx <<= "something"` which is actually a mistake. --- src/ext/framework/command.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/ext/framework/command.rs') diff --git a/src/ext/framework/command.rs b/src/ext/framework/command.rs index 92e6e93..70ee4ff 100644 --- a/src/ext/framework/command.rs +++ b/src/ext/framework/command.rs @@ -5,14 +5,14 @@ use ::model::Message; use ::model::Permissions; use std::collections::HashMap; -pub type Check = Fn(&Context, &Message) -> bool + Send + Sync + 'static; -pub type Exec = Fn(&Context, &Message, Vec) -> Result<(), String> + Send + Sync + 'static; -pub type Help = Fn(&Context, &Message, HashMap>, Vec) -> Result<(), String> + Send + Sync + 'static; -pub type BeforeHook = Fn(&Context, &Message, &String) -> bool + Send + Sync + 'static; -pub type AfterHook = Fn(&Context, &Message, &String, Result<(), String>) + Send + Sync + 'static; +pub type Check = Fn(&mut Context, &Message) -> bool + Send + Sync + 'static; +pub type Exec = Fn(&mut Context, &Message, Vec) -> Result<(), String> + Send + Sync + 'static; +pub type Help = Fn(&mut Context, &Message, HashMap>, Vec) -> Result<(), String> + Send + Sync + 'static; +pub type BeforeHook = Fn(&mut Context, &Message, &String) -> bool + Send + Sync + 'static; +pub type AfterHook = Fn(&mut Context, &Message, &String, Result<(), String>) + Send + Sync + 'static; #[doc(hidden)] pub type InternalCommand = Arc; -pub type PrefixCheck = Fn(&Context) -> Option + Send + Sync + 'static; +pub type PrefixCheck = Fn(&mut Context) -> Option + Send + Sync + 'static; #[doc(hidden)] pub enum CommandOrAlias { @@ -71,7 +71,7 @@ pub struct Command { impl Command { pub fn new(f: F) -> Self - where F: Fn(&Context, &Message, Vec) -> Result<(), String> + Send + Sync + 'static { + where F: Fn(&mut Context, &Message, Vec) -> Result<(), String> + Send + Sync + 'static { Command { aliases: Vec::new(), checks: Vec::default(), @@ -92,7 +92,7 @@ impl Command { } } -pub fn positions(ctx: &Context, content: &str, conf: &Configuration) -> Option> { +pub fn positions(ctx: &mut Context, content: &str, conf: &Configuration) -> Option> { if !conf.prefixes.is_empty() || conf.dynamic_prefix.is_some() { // Find out if they were mentioned. If not, determine if the prefix // was used. If not, return None. -- cgit v1.2.3