Esempio n. 1
0
        public SendInfo List()
        {
            string commandListStr = string.Join(", ", commandList.ToArray());

            SendInfo info = new SendInfo
            {
                Content = "**The following commands are available: **" + commandListStr,
                File    = false
            };

            return(info);
        }
Esempio n. 2
0
        public SendInfo TryCommand(MessageInfo message)
        {
            string   name = message.Command;
            SendInfo returnText;

            if (commandList.Contains(name))
            {
                switch (name)
                {
                case "dieroll":
                    returnText = DieRoll(message.Content);
                    break;

                case "flip":
                    returnText = Flip(message.Content);
                    break;

                case "list":
                    returnText = List();
                    break;

                case "reload":
                    returnText = Reload(message);
                    break;

                default:
                    returnText = TryCC(message);
                    break;
                }
                return(returnText);
            }
            else
            {
                SendInfo info = new SendInfo
                {
                    Content = "Command does not exist or is not enabled.",
                    File    = false
                };
                return(info);
            }
        }
Esempio n. 3
0
 public SendInfo Reload(MessageInfo message)
 {
     if (message.Channel == Config.ControlChannel)
     {
         LoadData();
         SendInfo info = new SendInfo
         {
             Content = "Custom commands reloaded.",
             File    = false
         };
         return(info);
     }
     else
     {
         SendInfo info = new SendInfo
         {
             Content = "Message not sent in bot control channel.",
             File    = false
         };
         return(info);
     }
 }
Esempio n. 4
0
 public SendInfo DieRoll(string input)
 {
     try
     {
         string   result = Dice.Roll(input).ToString();
         SendInfo info   = new SendInfo
         {
             Content = "**Rolled: " + result + "**",
             File    = false
         };
         return(info);
     }
     catch (ArgumentException e)
     {
         SendInfo info = new SendInfo
         {
             Content = "Invalid dice expression.",
             File    = false
         };
         return(info);
     }
 }
Esempio n. 5
0
 public SendInfo Flip(string input)
 {
     if (input == "PlAcEhOlDeReXt")
     {
         SendInfo info = new SendInfo
         {
             Content = "Invalid usage.",
             File    = false
         };
         return(info);
     }
     else
     {
         int    index       = 0;
         char[] outputArray = input.ToCharArray();
         Array.Reverse(outputArray);
         string output        = new string(outputArray);
         var    outputBuilder = new StringBuilder(output);
         foreach (char c in output)
         {
             if (subsitutes.ContainsKey(c))
             {
                 outputBuilder.Remove(index, 1);
                 outputBuilder.Insert(index, subsitutes[c]);
                 output = outputBuilder.ToString();
             }
             index++;
         }
         SendInfo info = new SendInfo
         {
             Content = output,
             File    = false
         };
         return(info);
     }
 }
Esempio n. 6
0
        public SendInfo TryCC(MessageInfo message)
        {
            string  botName       = Config.Name;
            Command command       = commands[message.Command];
            string  category      = command.Category;
            int     contentLength = command.Content.Length;

            if (contentLength < 1)
            {
                SendInfo info = new SendInfo
                {
                    Content = "No options for command",
                    File    = false
                };
                return(info);
            }
            else
            {
                int    choice      = rnd.Next(0, contentLength - 1);
                string contentText = command.Content[choice];

                if (contentText.Contains("_CONTENT_") & message.Content == "PlAcEhOlDeReXt")
                {
                    SendInfo info = new SendInfo
                    {
                        Content = "Invalid usage.",
                        File    = false
                    };
                    return(info);
                }
                else if (contentText == "_IMAGE_")
                {
                    string image = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config", "Commands", message.Command + ".png");
                    if (File.Exists(image))
                    {
                        SendInfo info = new SendInfo
                        {
                            Content = image,
                            File    = true
                        };
                        return(info);
                    }
                    else
                    {
                        SendInfo info = new SendInfo
                        {
                            Content = "Image not found",
                            File    = false
                        };
                        return(info);
                    }
                }
                else
                {
                    SendInfo info = new SendInfo
                    {
                        Content = contentText.KeywordReplace(message.Author, message.Content),
                        File    = false
                    };
                    return(info);
                }
            }
        }