Пример #1
0
    public async static Task HandleInformationCommand(SocketMessage message, CommunityRepository repository)
    {
        string originalMessage = message.Content;

        string[] splitMessage = originalMessage.Split(new char[] { ' ' }, 2);
        string   stageName    = splitMessage[1];

        Stage stage = new Stage()
        {
            Name = stageName.ToLower(),
        };

        if (!repository.StageExists(stage))
        {
            string possibleStrings = repository.GetPossibleStageNames(stage.Name);

            if (possibleStrings != String.Empty)
            {
                string reply = String.Format("Failed to grab information for the stage \"{0}\" because it does not exist in the repository.\n\n Could you mean one of these?\n\n{1}", stageName, possibleStrings);
                await message.Channel.SendMessageAsync(reply);

                return;
            }

            string response = String.Format(@"Failed to grab information for the stage ""{0}""  because it does not exist in the community repository", stageName);
            await message.Channel.SendMessageAsync(response);

            return;
        }

        Stage foundStage = repository.GetStage(stage.Name);

        string reponse = String.Format("Information for stage {0}\n\nAuthor: {1}\n\nUpload Date: {2}\n\nDescription: {3}", foundStage.Name, foundStage.Author, foundStage.Date, foundStage.Description);
        await message.Channel.SendMessageAsync(reponse);
    }
Пример #2
0
    public async static Task HandleSearchCommand(SocketMessage message, CommunityRepository repository)
    {
        string originalMessage = message.Content;

        string[] splitMessage = originalMessage.Split(new char[] { ' ' }, 2);
        string   stageName    = splitMessage[1];

        Stage stage = new Stage()
        {
            Name = stageName.ToLower(),
        };

        string possibleStrings = repository.GetPossibleStageNames(stage.Name);

        if (possibleStrings == String.Empty)
        {
            await message.Channel.SendMessageAsync("I did not found any stages matching your query :(");

            return;
        }

        string response = String.Format("Here are the stages that I have found that contains the search query \"{0}\" within the stage name.\n\n{1}", stageName, possibleStrings);
        await message.Channel.SendMessageAsync(response);

        return;
    }