Class: Lita::Handlers::GithubIssues

Inherits:
Handler
  • Object
show all
Includes:
LitaGithub::Config, LitaGithub::Filters, LitaGithub::General, LitaGithub::Octo, LitaGithub::Org, LitaGithub::Repo
Defined in:
lib/lita/handlers/github_issues.rb

Overview

GitHub Issues Lita Handler

Constant Summary collapse

LI_STATES =

issue states

%w(open closed all)
LI_SM =

issue states

%w(created updated comments)
LI_DIR =

sort direction

%w(asc desc)

Constants included from LitaGithub::Repo

LitaGithub::Repo::PR_LIST_MAX_COUNT

Instance Method Summary collapse

Methods included from LitaGithub::Filters

#func_disabled?

Methods included from LitaGithub::Repo

#repo?, #repo_has_team?, #repo_match, #rpo

Methods included from LitaGithub::Org

#organization, #sort_by_name, #team?, #team_id, #team_id_by_slug

Methods included from LitaGithub::Octo

#access_token, #octo, #setup_octo

Methods included from LitaGithub::Config

#config

Methods included from LitaGithub::General

#opts_parse, #symbolize_opt_key, #to_i_if_numeric

Instance Method Details

#issues_list(response) ⇒ Object

This is the handler for listing issues on a repository

Author:


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/lita/handlers/github_issues.rb', line 58

def issues_list(response)
  full_name = rpo(*repo_match(response.match_data))
  opts = opts_parse(response.message.body)

  oops = validate_list_opts(opts)

  return response.reply(oops) unless oops.empty?

  return response.reply(t('repo_not_found', repo: full_name)) unless repo?(full_name)

  # get the issues that are not pull requests
  begin
    issues = octo.list_issues(full_name, opts).reject { |i| i.key?(:pull_request) }
  rescue Octokit::UnprocessableEntity => e
    return response.reply(t('issues_list.invalid_opts', m: e.message))
  rescue StandardError => e
    return response.reply(t('boom', m: e.message))
  end

  if issues.empty?
    reply = t('issues_list.none', r: full_name)
  else
    reply = t('issues_list.header', n: issues.length, r: full_name)
    issues.each { |i| reply << t('issues_list.item',  i.to_h.merge(u: i[:user][:login], r: full_name)) }
  end

  response.reply(reply)
end