Search in sources :

Example 21 with GitHub

use of org.kohsuke.github.GitHub in project Rubicon by Rubicon-Bot.

the class CommandGitBug method handle.

public static void handle(MessageReceivedEvent event) {
    if (!reportMap.containsKey(event.getAuthor().getIdLong())) {
        return;
    }
    ReportHolder reportHolder = reportMap.get(event.getAuthor().getIdLong());
    if (event.getMessage().getContentDisplay().contains(reportHolder.title))
        return;
    if (!event.getTextChannel().getId().equals(reportHolder.textChannel.getId()))
        return;
    String description = event.getMessage().getContentDisplay();
    try {
        GitHub gitHub = GitHub.connectUsingOAuth(Info.GITHUB_TOKEN);
        GHRepository repository = gitHub.getOrganization("Rubicon-Bot").getRepository("Rubicon");
        GHIssue issue = repository.createIssue(reportHolder.title).body(ISSUE_HEADER + event.getAuthor().getName() + "#" + event.getAuthor().getDiscriminator() + ISSUE_SUFFIX + description).label("Bug").label("Requires Testing").create();
        reportHolder.delete(issue.getHtmlUrl().toString());
        event.getMessage().delete().queue();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : GHRepository(org.kohsuke.github.GHRepository) GitHub(org.kohsuke.github.GitHub) GHIssue(org.kohsuke.github.GHIssue) IOException(java.io.IOException)

Aggregations

GitHub (org.kohsuke.github.GitHub)21 GHRepository (org.kohsuke.github.GHRepository)17 IOException (java.io.IOException)10 Test (org.junit.Test)5 GHRelease (org.kohsuke.github.GHRelease)5 Semver (com.vdurmont.semver4j.Semver)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 GHContent (org.kohsuke.github.GHContent)3 GHIssue (org.kohsuke.github.GHIssue)3 NextProtException (org.nextprot.api.commons.exception.NextProtException)3 Cacheable (org.springframework.cache.annotation.Cacheable)3 FileInputStream (java.io.FileInputStream)2 URL (java.net.URL)2 HashMap (java.util.HashMap)2 GHAsset (org.kohsuke.github.GHAsset)2 GHUser (org.kohsuke.github.GHUser)2 HttpException (org.kohsuke.github.HttpException)2 StandardUsernamePasswordCredentials (com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials)1 ServiceException (io.jenkins.blueocean.commons.ServiceException)1