All Projects → mashabow → slack-rota

mashabow / slack-rota

Licence: MIT License
日々のローテーションをお知らせする Slack アプリ

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to slack-rota

Awesome Bots
The most awesome list about bots ⭐️🤖
Stars: ✭ 2,864 (+20357.14%)
Mutual labels:  slack, slack-bot
iou-slack-bot
💸 IOU Slack Bot - Keep track of your debts with your peers.
Stars: ✭ 13 (-7.14%)
Mutual labels:  slack, slack-bot
captcha-generator
An NPM package to generate captcha images that can be used in Discord bots or various other projects
Stars: ✭ 45 (+221.43%)
Mutual labels:  slack, slack-bot
Chatskills
Run and debug Alexa skills on the command-line. Create bots. Run them in Slack. Run them anywhere!
Stars: ✭ 171 (+1121.43%)
Mutual labels:  slack, slack-bot
slack widgets
An abstraction of the JSON structure needed to create widgets in Slack message attachments
Stars: ✭ 14 (+0%)
Mutual labels:  slack, slack-bot
Go Sarah
Simple yet customizable bot framework written in Go.
Stars: ✭ 188 (+1242.86%)
Mutual labels:  slack, slack-bot
emojibot
Emojibot is a Slack bot that announces new custom emoji to a specific channel.
Stars: ✭ 17 (+21.43%)
Mutual labels:  slack, slack-bot
Slick
Slick, a Slack bot in Go
Stars: ✭ 150 (+971.43%)
Mutual labels:  slack, slack-bot
dienstplan
Slack bot app for duty rotations
Stars: ✭ 14 (+0%)
Mutual labels:  slack, slack-bot
git-slack-notify
Sends Slack notifications for new commits in Git repositories
Stars: ✭ 12 (-14.29%)
Mutual labels:  slack, slack-bot
Secret Santa
🎅 The code behind Secret Santa, the holiday bot for Slack / Discord / Zoom
Stars: ✭ 170 (+1114.29%)
Mutual labels:  slack, slack-bot
SlackWebhooksGithubCrawler
Search for Slack Webhooks token publicly exposed on Github
Stars: ✭ 21 (+50%)
Mutual labels:  slack, slack-bot
Fantasy football chat bot
GroupMe Discord and Slack Chatbot for ESPN Fantasy Football
Stars: ✭ 166 (+1085.71%)
Mutual labels:  slack, slack-bot
Sactive Bot
😈 An extensible chat bot framework. sactive-bot is an evolution of the open source hubot project. - https://www.shipengqi.top/sactive-bot .
Stars: ✭ 212 (+1414.29%)
Mutual labels:  slack, slack-bot
Php Slack Bot
Slack bot user written in PHP
Stars: ✭ 161 (+1050%)
Mutual labels:  slack, slack-bot
Yasuf
Very simple way of controlling your Python application via Slack
Stars: ✭ 23 (+64.29%)
Mutual labels:  slack, slack-bot
Norrisbot
a Slack bot that kicks asses (roundhouse-kicks to be accurate...)
Stars: ✭ 134 (+857.14%)
Mutual labels:  slack, slack-bot
Lita Slack
A Slack adapter for Lita.
Stars: ✭ 138 (+885.71%)
Mutual labels:  slack, slack-bot
SlackLateX
Bot that posts posts Latex pictures
Stars: ✭ 39 (+178.57%)
Mutual labels:  slack, slack-bot
slack-php-app-framework
Robust PHP framework for building Slack apps in PHP
Stars: ✭ 29 (+107.14%)
Mutual labels:  slack, slack-bot

Rota

日々のローテーションをお知らせする Slack アプリ

お知らせの例

使い方

ローテーションの作成

ローテーションをお知らせしたいチャンネルで、/rota コマンドを実行します。

/rota コマンドを実行する

すると、ローテーションを作成するためのモーダルが開きます。ローテーションを回すメンバーや、お知らせするメッセージ、曜日・時刻を入力しましょう。

作成モーダル

お知らせ時にメンションする範囲を選ぶこともできます(スクロールで隠れていて少々わかりにくいですが…)。

作成モーダル下部

[作成する] をクリックして完了です。「ローテーションを作成しました!」というメッセージが表示されます。

作成成功メッセージ

Rota からのお知らせ

指定した日時になると、Rota が今日の担当者をお知らせします。

お知らせ1回目

指定した日時がもう一度来ると、ローテーションがひとつ進み、次の担当者になります。以降も同様です。

お知らせ2回目

右端の […] メニューから、手動でローテーションを進めたり、戻したりもできます。ローテーションの編集も、ここからできます。

[…] メニュー

補足

  • メッセージ部分には Slack の mrkdwn フォーマットが使えます。作成モーダル上では整形表示されませんが、実際のお知らせではきちんと表示されます。
  • 権限上、Rota はパブリックチャンネルのみで動作します。プライベートチャンネルや DM では利用できません。

インストール

Firebase プロジェクトの作成

まずは、アプリを動かすための Firebase プロジェクトを用意します。

  1. Firebase コンソールから、新規プロジェクトを作成

  2. ⚙️ > プロジェクトを設定 > 全般 のページに移動し、デフォルトのリソースロケーションを asia-northeast1(東京)に設定

  3. ⚙️ > 使用量と請求額 > 詳細と設定 のページに移動し、料金プランを Spark(無料)から Blaze(従量制)に変更

  4. 開発 > Database のページに移動し、Cloud Firestore データベースを作成

  5. Firebase CLI をインストール

    $ npm install -g firebase-tools
  6. 作成したプロジェクトを選択し、適当なエイリアス名を設定

    $ firebase use --add

Slack アプリの作成

  1. Bolt 入門ガイド の「アプリを作成する」を参考にして、Slack アプリを作成

    1. アプリ作成ページ に移動
    2. 適当なアプリ名と、インストール先のワークスペースを入力し、アプリを作成
    3. Manage Distribution > Share Your App with Other Workspaces を開き、Remove Hard Coded Information のチェックを入れたら [Activate Public Distribution] をクリック
    4. Scopes > Bot Token Scopes に chat:write, chat:write.public, commands, users:read を追加

Firebase へのデプロイ

Slack アプリの Basic Information > App Credentials の情報を Firebase に設定し、デプロイします。

  1. Slack アプリの Client ID, Client Secret, Signing Secret を、Firebase Functions の slack.* に設定

    $ firebase functions:config:set \
      slack.client_id="012345678.1234567..." \
      slack.client_secret="01234567890abcdef..." \
      slack.signing_secret="01234567890abcdef..."
  2. Firebase Functions の rota.* に任意のランダム値を設定

    $ firebase functions:config:set \
      rota.state_secret="state_secret" \
      rota.encryption_secret="encryption_secret"
  3. Firebase にデプロイ 🚀

    $ firebase deploy

Slack アプリの追加設定

Slack から Firebase Functions を呼び出せるようにします。

  1. アクションの送信と応答」を参考にして Interactivity を有効化

    1. Interactivity & Shortcuts の Interactivity を On に変更
    2. Request URL に https://asia-northeast1-<FirebaseのプロジェクトID>.cloudfunctions.net/slack/events と入力
    3. 設定を保存
  2. Slash Commands を設定

    1. Slash Commands の [Create New Command] をクリック
    2. Command に /rota と入力
    3. Request URL に https://asia-northeast1-<FirebaseのプロジェクトID>.cloudfunctions.net/slack/events と入力
    4. 設定を保存
  3. Redirect URLs を設定

    1. OAuth & Permissions の Redirect URLs に https://asia-northeast1-<FirebaseのプロジェクトID>.cloudfunctions.net/slack/oauth_redirect と入力して、[Add] をクリック
    2. [Save URLs] をクリックして設定を保存

ワークスペースへのインストール

https://asia-northeast1-<FirebaseのプロジェクトID>.cloudfunctions.net/slack/install にアクセスして、ワークスペースにインストールします。

動作確認

以上で完了です。適当なパブリックチャンネル上で /rota コマンドを実行し、Rota が動作するか確認してください。

開発

ローカル環境で動かす

Firebase Emulator で Functions と Firestore を起動します。

$ cd functions/
$ firebase functions:config:get > .runtimeconfig.json
$ npm run serve

http://localhost:4000 で、Functions のログや Firestore の状態を確認することができます。slack 関数のエンドポイントは、http://localhost:5001/your-project-id/asia-northeast1/slack になります。

Slack からのイベントを受け取るためには、ngrok などを利用して、このエンドポイントを外部に公開する必要があります。別のターミナルで

$ ngrok http 5001

を実行すると、https://12345abcde.ngrok.io のような URL で、http://localhost:5001 にアクセスできるようになります。Slack アプリの以下の設定に、ngrok の URL をそれぞれ指定しましょう。Firebase で動かす本番用 Slack アプリとは別に、開発用の Slack アプリを作成しておくと楽です。

  • Interactivity & Shortcuts > Interactivity > Request URL
    • https://12345abcde.ngrok.io/your-project-id/asia-northeast1/slack/events
  • Slash Commands > /rota > Request URL
    • https://12345abcde.ngrok.io/your-project-id/asia-northeast1/slack/events
  • OAuth & Permissions > Redirect URLs
    • https://12345abcde.ngrok.io/your-project-id/asia-northeast1/slack/oauth_redirect

Cloud Functions シェルを使うと、Firebase Emulator 上の cron 関数を手動で実行することができます。

$ npm start
firebase > cron()
'Successfully invoked function.'

テスト

$ npm run test

firebase-functions-test によるオンラインテスト

functions/src/__tests__/index.test.tsオンラインテストになっているため、Firebase 上にある実物の Firestore を使用します(一方、Functions はローカルで動作します)。以下の手順で、テスト用のプロジェクトを用意してください。

  1. テスト用の Firebase プロジェクトを作成する
  2. プロジェクトにウェブアプリを追加する
  3. ⚙️ > プロジェクトを設定 > サービス アカウント > Firebase Admin SDK を表示し、[新しい秘密鍵の生成] をクリックする
  4. ダウンロードした秘密鍵ファイルをリネームし、ルートディレクトリの serviceAccountKey.json に配置する
  5. プロジェクト ID を .env ファイルの TEST_PROJECT_ID に設定する

License

MIT

Author

Masaya Nakamura (@mashabow)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].