Help us understand the problem. What is going on with this article?

githubのtrending repositoriesを取得するhubotスクリプト

More than 5 years have passed since last update.


  • hubot g tr [since] <対象言語> と送信するとtrending repositoriesを一覧表示する
  • 任意パラメータ "since" について
    • d (デフォルト) - "daily"
    • w - "weekly"
    • m - "monthly"
me> hubot g tr go

hubot> - HTTP/2 support for Go (in active development) (120 stars)
hubot> - Docker - the open-source application container engine (48 stars)
hubot> - Open Source Continuous File Synchronization (34 stars)
hubot> - Simulating shitty network connections so you can build better systems. (28 stars)
hubot> - Log routing for Docker container logs (26 stars)
hubot> - Container Cluster Manager (23 stars)
hubot> - A realtime distributed messaging platform (24 stars)
hubot> - A Scalable, Geo-Replicated, Transactional Datastore (21 stars)
hubot> - Go debugger (18 stars)
hubot> - A next generation open source platform as a service (PaaS) (14 stars)
hubot> - Gogs(Go Git Service) is a painless self-hosted Git Service written in Go. (13 stars)
hubot> - A modern text indexing library for go (11 stars)
hubot> - Package mafsa implements Minimal Acyclic Finite State Automata in Go, essentially a high-speed, memory-efficient, Unicode-friendly set of strings. (13 stars)
hubot> - A highly-available key value store for shared configuration and service discovery (11 stars)
hubot> - The Docker Network (11 stars)
hubot> - Your PaaS. Your Rules. (11 stars)
hubot> - A Fast and Flexible Static Site Generator built with love by spf13 in GoLang (10 stars)
hubot> - hub helps you win at git. (11 stars)
hubot> - Web-based PostgreSQL database browser (11 stars)
hubot> - Scalable datastore for metrics, events, and real-time analytics (9 stars)
hubot> - vitess provides servers and tools which facilitate scaling of MySQL databases for large scale web services. (9 stars)
hubot> - Consul is a tool for service discovery, monitoring and configuration. (8 stars)
hubot> - Open source API-compatible alternative to Sublime Text (7 stars)
hubot> - A high productivity, full-stack web framework for the Go language. (8 stars)
hubot> - Classy web framework for Go (8 stars)


  • Gistはこちら
  • 依存モジュール×2
    • "request": "^2.42.0"
    • "cheerio": "^0.17.0"
request = require 'request'

module.exports = (robot) ->

  trim = (str) ->
    str.replace(/(^\s+)|(\s+$)/g, '').replace(/\r?\n/g, '')

  robot.respond /g tr(?:\s+)?((m|w|d)\s+)?([^\s]+)?/i, (msg) ->
    since = "daily"
    if msg.match[2]?
      switch msg.match[2]
        when "m"
          since = "monthly"
        when "w"
          since = "weekly"
    l = if msg.match[3]? then "&l=#{msg.match[3]}" else ""
    url = "{since}" + l

    options =
      url: url
      method: "GET"
    request options, (error, response, body) =>
      if error
        console.log "A problem was caused: #{error}"

      status = response.statusCode
      if status == 200
        cheerio = require 'cheerio'
        $ = cheerio.load body
        m = ""
        $('ol.repo-list > li').each (i, e) ->
          $$ = cheerio.load e
          repo = "" + $$('h3.repo-list-name > a').attr('href')
          desc = trim $$('p.repo-list-description').text()
          meta = trim $$('p.repo-list-meta').text()
          star = trim meta.replace(/stars.+/g, '').split('•')[1]
          repoInfo = "#{repo} - #{desc} (#{star} stars)"
          m = m + "\n" + repoInfo
        msg.send m
        console.log "Status(#{status}) is error: #{body}"


Ruby/Rails/Go/PHP/Java/Linux/MySQL/Docker/AWS(Solutions Architect Associate & Developer Associate)/Vim/Fintech/Payment
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away