Ejemplo n.º 1
0
        /// <summary>
        /// Takes in the ParsedMessage and sends a message back to the sender with a message containing the description for the specified plugin
        /// </summary>
        /// <param name="message">Message containing information</param>
        /// <param name="service">Service to send/recieve messages through</param>
        /// <param name="controller">Database to pull from</param>
        public void Run(ParsedMessage message, AWatcherService service, IDBController controller)
        {
            Message msg = new Message();
            StringBuilder fullMsg = new StringBuilder();
            if (message.Arguments.Count <= 0)
            {
                fullMsg.Append("Please specify which plugin you would like information about.");
            }
            else
            {
                try
                {
                    PluginDAO plugin = controller.RetrievePlugin(message.Arguments[0]);
                    if ((controller.GetAllEnabledGroupPlugins(message.Group.GroupID)).Contains(plugin))
                    {
                        fullMsg.Append(plugin.Name);
                        fullMsg.Append(": ");
                        fullMsg.Append(plugin.Description);
                    }
                    else
                    {
                        fullMsg.Append("This plugin is not enabled for this group.");
                    }
                }
                catch (CouldNotFindException)
                {
                    fullMsg.Append("Can not find plugin ");
                    fullMsg.Append(message.Arguments[0]);
                }
            }

            msg.FullMessage = fullMsg.ToString();
            msg.Reciever.Add(message.Sender.PhoneEmail);
            service.SendMessage(msg);
        }