Sha256: 866d22ce228a6f69573100379c07c8fca07b9b3c6fe69308b1484a2b3d65f46b

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 KB

Contents

# -*- coding: UTF-8 -*-
#
# Copyright 2014 PagerDuty, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require 'octokit'
require 'lita-github/version'
require 'lita-github/r'
require 'lita-github/config'
require 'lita-github/octo'

module Lita
  # Lita Handler
  module Handlers
    # GitHub Lita Handler
    class Github < Handler
      include LitaGithub::R       # Github handler common-use regex constants
      include LitaGithub::Config  # Github handler Lita configuration methods
      include LitaGithub::Octo    # Github handler common-use Octokit methods

      on :loaded, :setup_octo # from LitaGithub::Octo

      route(
        /#{LitaGithub::R::A_REG}status/, :gh_status,
        command: true,
        help: {
          'github status' => 'get the system status from GitHub',
          'gh status' => 'get the system status from GitHub using short alias'
        }
      )

      route(
        /#{LitaGithub::R::A_REG}(?:v|version|build)/, :gh_version,
        command: true,
        help: {
          'gh version' => 'get the lita-github version'
        }
      )

      def self.default_config(config)
        config.repo_delete_enabled = false
        config.repo_private_default = true
      end

      def gh_status(response)
        status = octo.github_status_last_message
        response.reply(t("status.#{status[:status]}", status))
      end

      def gh_version(response)
        response.reply("lita-github v#{LitaGithub::VERSION}")
      end
    end

    Lita.register_handler(Github)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lita-github-0.0.1 lib/lita/handlers/github.rb