Giter VIP home page Giter VIP logo

nippo's Introduction

nippo

分報から日報を作り出すためのnpm。 1日分の分報を日報として出力します。

input(slack) → 加工 → output(qiita team or esa.io)に出力。 みたいなイメージです。

分報?って方はこちらの記事をよんでもらえるとわかるかと思います。
Slackで簡単に「日報」ならぬ「分報」をチームで実現する3ステップ 〜 Problemが10分で解決するチャットを作ろう

v0.2.0現在で対応しているサービスは以下のとおり。

使い方

まずはインストールしましょう。

$ npm install nippo

あとはjsをちょこっと書くだけ

var nippo = require("nippo")

var config = {
  "output": {
    "service": "esa",
    "team": "your team name",
    "token": "your token",
    "category": "report/%year%/%month%"
  },
  "input": {
    "service": "slack",
    "token": "your token",
    "channel": "report"
  },
  "formatter": {
    "service": "default"
  }
};

nippo(config, 1); // 1を指定することで、1日前の日報を作成します。

// ちなみにこんな事もできます
nippo(config, 1).then(function(outputResponse){
  console.log(outputResponse);
});

QiitaTeamで使ってみる。

var nippo = require("nippo")

var config = {
  "output": {
    "service": "qiitateam",
    "team": "hoge", // https://hoge.qiita.com
    "token": "your token",
    "category": "report/%year%/%month%"
  },
  "input": {
    "service": "slack",
    "token": "your token",
    "channel": "report"
  },
  "formatter": {
    "service": "default"
  }
};

nippo(config, 1); // 1を指定することで、1日前の日報を作成します。

// ちなみにこんな事もできます
nippo(config, 1).then(function(outputResponse){
  console.log(outputResponse);
});

日報に反映するときのフォーマットを変更する

esa.ioやqiita teamに投稿するドキュメントを加工することも可能です。

まずは適当なディレクトリにフォーマッターを用意します。

$ mkdir ./formatter

次にフォーマッターファイルを用意します。

vi ./formatter/my_formatter.js

function tsToTimeName(d) {
  var hour = ( d.getHours()   < 10 ) ? '0' + d.getHours()   : d.getHours();
  var min  = ( d.getMinutes() < 10 ) ? '0' + d.getMinutes() : d.getMinutes();
  var sec   = ( d.getSeconds() < 10 ) ? '0' + d.getSeconds() : d.getSeconds();
  return hour + ":" + min + ":" + sec
}

module.exports = function(messages) {
    return messages.map(function(message){
      var d = message.date;
      var text = message.user.name + " 投稿時間 " + tsToTimeName(message.date) + "\n #メッセージ\n\n" + message.messages;
      return text;
    }).join("\n\n");
}

最後に、フォーマッターファイルの位置をしていします。

serviceを先ほど作成したmy_formatter.jsにし、dirでディレクトリを指定します。

var nippo = require("nippo");


nippo({
  "output": {
    "service": "esa",
    "team": "polidog",
    "token": "access token",
    "category": "report/%year%/%month%"
  },
  "input": {
    "service": "slack",
    "token": "access token",
    "channel": "report"
  },
  "formatter": {
    "service": "my_formatter",
    "dir": __dirname + "/formatter"
  }
},1);

これでカスタムのフォーマッターを使うことが出来ます。

イメージ的なあれ

こんなSlackで投稿したものが

slack

こんな風にまとめられます。

esa

qiita

最後に

コードは糞コードですごめんなさい・・・ テストはこれから頑張って書きます。。

nippo's People

Contributors

bl-lia avatar polidog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

bl-lia

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.