ヤマカサのプログラミング勉強日記

プログラミングに関する日記とどうでもよい雑記からなるブログです。

[N予備校]【2019年度】プログラミング入門 Webアプリ その9

【2019年度】プログラミング入門 Webアプリ

前回に続いて3章をやっていきます。

第3章 サーバーサイドプログラミング

06. Hubot と Slack アダプタ

Yarn を用いて、yo, generator-hubot, coffescript の三つのパッケージをインストールします。

Hubot を使い、チャットボットを作ります。

'use strict'
module.exports = (robot) => {
  robot.hear(/hello/i, (msg) => {
    const username = msg.message.user.name;
    msg.send('Hello, ' + username);
  });
  robot.hear(/lot/i, (msg) => {
    const username = msg.message.user.name;
    const lots = ['大吉', '吉', '中吉', '末吉', '凶'];
    const lot = lots[Math.floor(Math.random() * lots.length)];
    msg.send(lot + ', ' + username);
  })
};

07. モジュール化された処理

モジュールの実装をします。

感想

何をやっているのかよく分からないですね。