Beispiel #1
0
  @Override
  public void run() {
    try {
      LinkedList<URL> gitUrls;
      gitUrls = this.buildUrls();

      Iterator<URL> it = gitUrls.iterator();

      while (it.hasNext()) {
        BotURLConnection conn = new BotURLConnection(it.next());

        JSONArray commits = new JSONArray(conn.fetchURL());

        this.showAnswer(commits);
      }
    } catch (Exception e) {
      BotLogger.getDebugLogger().debug(e.getMessage());
    }
  }
Beispiel #2
0
  private void showAnswer(JSONArray commits) throws JSONException {
    int i = 0;
    Boolean fCommit = true;

    String url = commits.getJSONObject(0).getJSONObject("commit").optString("url");
    String[] userRepo = url.split("/");
    while (i < this.ncommits) {
      JSONObject commit = commits.getJSONObject(i).getJSONObject("commit");
      String sha = commit.getJSONObject("tree").optString("sha");

      if (this.seenCommit(fCommit, userRepo[5], sha)) break;
      fCommit = false;

      // Display the commit in channel
      for (String channel : this.getChannels()) {
        this.getConnection()
            .doPrivmsg(
                channel,
                "(github) "
                    + userRepo[4]
                    + "/"
                    + userRepo[5]
                    + " - Commit: "
                    + commit.optString("message")
                    + ", "
                    + commit.getJSONObject("author").optString("email")
                    + ", "
                    + commit.getJSONObject("author").optString("date"));
      }

      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        BotLogger.getDebugLogger().debug(e);
      }
      ++i;
    }
    this.newestCommit.put(userRepo[5], this.firstCommit);
  }