示例#1
0
        protected bool GetParameter(string message, out ComplexMessage parameters)
        {
            string[] strs = message.Split(new string[] { " ", Constants.CQNewLine }, 2, StringSplitOptions.RemoveEmptyEntries);

            if (strs.Length > 0 && strs[0].ToLower() == ResponseCommand)
            {
                if (strs.Length == 1)
                {
                    parameters = null;
                }
                else
                {
                    var splitter = new CommandSplitter();
                    var command  = splitter.Split(strs[1]);
                    parameters = command?.Select(x => ComplexMessage.Parse(x).ToMessageElement()).ToComplexMessage();
                }

                return(true);
            }
            else
            {
                parameters = null;
                return(false);
            }
        }
示例#2
0
        internal override void Invoke(MessageReceivedEventArgs e)
        {
            string message   = GetMessage(e.Message.ToString());
            string parameter = GetParameter(message);

            if (message?.Trim().ToLower() == ResponseCommand)
            {
                Invoking(e);
                Handled = true;
            }
            else if (parameter != null)
            {
                if (CanHaveParameter)
                {
                    Invoking(e, ComplexMessage.Parse(parameter));
                }
                else
                {
                    NotifyIncorrectUsage(e);
                }

                Handled = true;
            }
        }