{"id":13823864,"url":"https://github.com/masuidrive/miyamoto","last_synced_at":"2025-07-08T18:31:08.266Z","repository":{"id":20910641,"uuid":"24198437","full_name":"masuidrive/miyamoto","owner":"masuidrive","description":"Google Apps Scriptで書かれたSlack用勤怠管理Botの「みやもとさん」","archived":false,"fork":false,"pushed_at":"2023-12-07T15:34:46.000Z","size":1547,"stargazers_count":521,"open_issues_count":5,"forks_count":110,"subscribers_count":31,"default_branch":"master","last_synced_at":"2024-11-20T01:33:18.931Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/masuidrive.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-09-18T17:43:17.000Z","updated_at":"2024-03-25T14:13:15.000Z","dependencies_parsed_at":"2024-11-20T03:45:40.005Z","dependency_job_id":null,"html_url":"https://github.com/masuidrive/miyamoto","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/masuidrive/miyamoto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masuidrive%2Fmiyamoto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masuidrive%2Fmiyamoto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masuidrive%2Fmiyamoto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masuidrive%2Fmiyamoto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/masuidrive","download_url":"https://codeload.github.com/masuidrive/miyamoto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masuidrive%2Fmiyamoto/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264323887,"owners_count":23590757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T09:00:47.338Z","updated_at":"2025-07-08T18:31:07.917Z","avatar_url":"https://github.com/masuidrive.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# 勤怠管理bot - みやもとさん\n\nGoogle Apps Scriptで書かれた、Slack上で動く勤怠管理Bot。\n\nSlackで下記の様につぶやくと、みやもとさんがGoogle Spreadsheetに勤怠を記録してくれます。\n\n![demo1](https://raw.githubusercontent.com/masuidrive/miyamoto/master/docs/images/demo1.png)\n\n\n## 会話例\n\n- おはようございます ← 現在時刻で出勤\n- おはようございます 12:00 ← 指定時刻で出勤\n- おはようございます 10/2 12:00 ← 過去に遡って出勤を記録する\n- 12:00に出勤しました ← 指定時刻で出勤\n- お疲れ様でした ← 現在時刻で退勤\n- お疲れ様でした 20:00 ← 指定時刻で退勤\n- 20時に退勤しました ← 指定時刻で退勤\n- 明日はお休みです ← 休暇申請\n- 10/1はお休みです ← 休暇申請\n- 明日のお休みを取り消します ← 休暇申請取り消し\n- 明日はやっぱり出勤します ← 休暇申請取り消し\n\n- 誰がいる？ ← 出勤中のリスト\n- 誰がお休み？ ← 休暇中のリスト\n- 9/21は誰がお休み？ ← 指定日の休暇リスト\n\n\n# 設置方法\n\nみやもとさんは、プログラム本体をGoogle Driveに保存して実行します。データはGoogle Spreadsheetに保存されます。\n\nインストールは下記の手順に従ってください。\n\n\n## Google Apps Scriptへ設置\n\n### プログラム本体を設置\n\n- https://drive.google.com/ を開いて画面左にある、赤い「作成」ボタンを押します。\n- 最下部の「アプリを追加」を押してダイアログを開きます。\n- ダイアログの検索ボックスに「script」と入力してリストに出てきた「Google Apps Script」の「＋接続」ボタンを押します。\n\n![drive0](https://raw.githubusercontent.com/masuidrive/miyamoto/master/docs/images/drive0.png)\n\n\n- もう一度「作成」ボタンを押して「スクリプト」選択します。\n- 「スクリプトを作成」の下にある「空のプロジェクト」を選択します。\n- 新しいスクリプトを作る画面へ遷移するので、左上の「無題のプロジェクト」をクリックして、「Miyamoto-san」に変更します。\n\n![gas03](https://raw.githubusercontent.com/masuidrive/miyamoto/master/docs/images/gas03.png)\n\n\n- [main.gs](https://raw.githubusercontent.com/masuidrive/miyamoto/master/main.gs)をコピーして、ブラウザ内のエディタ部に貼り付けます。\n- メニューから「ファイル」→「保存」を選択して保存します。\n- メニューの「ファイル」→「プロジェクトのプロパティ」を開いて「Time zone」を「東京」に合わせてください。\n\n\n### 初期化\n\n- ツールバーの「関数を選択」から「setUp」を選び、左の再生ボタンを押します。\n\n![gas11](https://raw.githubusercontent.com/masuidrive/miyamoto/master/docs/images/gas11.png)\n\n- 権限の承認画面が出たら「承認する」を押してください。\n- Google Drive上に「Slack Timesheets」というSpreadsheetが生成されます。\n\n\n### APIの公開\n\n- メニューから「公開」→「ウェブアプリケーションとして導入...」を選びます。\n- 先に「新しいバージョンを保存」ボタンを押した後、「アプリケーションにアクセスできるユーザ」から「全員（匿名ユーザを含む）」を選択します。\n- 同時に「次のユーザーとしてアプリケーションを実行」を「自分」に変更します。\n- 登録完了後に出るウインドーの「現在のウェブアプリケーションのURL」をどこかにメモしておいてください。\n\n![gas20](https://raw.githubusercontent.com/masuidrive/miyamoto/master/docs/images/gas20.png)\n\n\n- 「全員（匿名ユーザを含む）」が見つからない場合は、https://admin.google.com/ から「Google Apps」→「ドライブ」を選択して、「共有設定」の「ユーザは組織外のユーザとファイルを共有できる」を選択します。\n\n![admin2](https://raw.githubusercontent.com/masuidrive/miyamoto/master/docs/images/admin2.png)\n\n\n\n## Slackへの設定\n\n- SlackのWebサイトへログインし、「timesheets」チャンネルを追加します。\n\n### Slack Outgoingの設定\n\n- 左上のメニューから「Configure Integration」を選びます。\n\n![slack11](https://raw.githubusercontent.com/masuidrive/miyamoto/master/docs/images/slack11.png)\n\n- ページ下部の「DIY Integrations \u0026 Customizations」から「Outgoing WebHooks」を選びます。\n- 緑の「Add Outgoing Webhook」を押します。\n- 「Integration Settings」の「Channel」を「#timesheets」を選択し、「URL(s)」には「APIの公開」でメモをした「現在のウェブアプリケーションのURL」を入力し、「Save Integration」を押します。\n\n![slack13](https://raw.githubusercontent.com/masuidrive/miyamoto/master/docs/images/slack13.png)\n\n\n### Slack Incomingの設定\n\n- 左のサイドバーの「Add New Integration」から「Incoming WebHooks」を選びます。\n- ページ最下部の「Choose a channel...」から「#timesheets」を選択して、「Add Incoming WebHook」を選択します。\n- 遷移したページの「Your Unique Webhook URL」の下に書かれているURLをどこかにメモしておきます。\n\n![slack21](https://raw.githubusercontent.com/masuidrive/miyamoto/master/docs/images/slack21.png)\n\n- 「Integration Settings」右の「Expand」を押して、「change the name of your bot」をクリックし「miyamoto」を指定します。\n\n![slack22](https://raw.githubusercontent.com/masuidrive/miyamoto/master/docs/images/slack22.png)\n\n- 「miyamoto」以外の名前を指定する場合は、Spreadsheetの「_設定」の「無視するユーザ」にその名前を加えてください。\n\n## みやもとさんの設定\n\n- https://drive.google.com/ から「Slack Timesheets」を選びます。\n- メニューの「ファイル」→「スプレッドシートの設定」を開いて「タイムゾーン」を「東京」に合わせてください。\n- 下のタブから「_設定」を開き、「Slack Incoming URL」がある「B1」に「Slackへの設定」でメモした「Your Unique Webhook URL」を入力します。\n- このbotの名前を変更した場合は、「無視するユーザ」にその名前を加えてください。\n\n![gs3](https://raw.githubusercontent.com/masuidrive/miyamoto/master/docs/images/gs3.png)\n\n\n# 動かす\n\nSlackの#timesheetsチャンネルで「おはよう」と発言すると、先の「Slack Timesheets」にユーザ名のタブが作られて、時間が記録されます。\n\n当日の日付が二つ並んでいますが、B〜C列を時間表示に切り替える必要があります。範囲指定をしてメニューの「表示形式」→「数字」→「時間」を選択してください。\n\n週の休日は「Day Off」の欄に,(カンマ)区切りで入力します。\n\n![gs2](https://raw.githubusercontent.com/masuidrive/miyamoto/master/docs/images/gs2.png)\n\nこれで設置が終わりました。どんなメッセージに反応するかは、[timesheets.js](https://github.com/masuidrive/miyamoto/blob/master/scripts/timesheets.js#L29)の正規表現を読み解いてください。\n\nまた、このシートを編集不可で共有することで、勤務時間の確認などが簡単に行えるようになります。\n\n## ご協力ください\n\nみやもとさんを使ってる方は、ぜひ[みやもとさん調査](https://docs.google.com/forms/d/1Rnis14t2OImkwvfOc2L0B3GmvByxu6jVRoAcxJLY1tc/viewform?usp=send_form)にご協力ください。\n\n開発の参考にさせていただきます。\n\n\n## メッセージの変更\n\nSpreadsheetの「_メッセージ」シートに各メッセージのテンプレートが書かれています。縦に複数設定すると、ランダムで選択されます。\n\nココを変更するとみやもとさんのキャラが変わります。ぜひ面白い設定をしてください。\n\n\n## 仕様\n\n- ユーザ名に.(ドット)が入っている場合に、mentionにならないのはSlack Webhookの仕様です。\n- Private Groupに設置することはできません\n- ユーザは一部屋90人ぐらいまでです。それ以上でお使いの場合は部単位などで部屋を分けて下さい。\n\n# 開発\n\n- コードを変更したときには、メニューの「ファイル」→「版の管理...」で「新しいバージョンを保存」してから、「公開」→「ウェブアプリケーションとして導入...」の「プロジェクトバージョン」を最新にする必要があります。\n\n\n## Todo\n\n- 出勤日数の管理\n- 時間外労働の扱い\n- 休憩時間\n\n\n## テストの実行\n\nみやもとさんはロジックの検証をNodeを使って行う事ができます。Nodeの実行環境を整えたら下記のコマンドを実行してください。\n\n```\nnpm install\nmake test\n```\n\n## ソースコード\n\n- main.js\n  - HTTPを受け取る\n\n- 入力内容を解析して、メソッドを呼び出す\n  - Slackへの入出力\n\n- gs_template.js\n  - Google Spreadsheetを使ったメッセージテンプレート\n\n- gs_properties.js\n  - Google Spreadsheetを使った設定key-value store\n\n- gs_timesheets.js\n  - timesheetsをGoogle Spreadsheetに保存する処理\n\n- gas_properties.js\n  - Google Apps Scriptを使った設定key-value store\n\n- gas_utils.js\n  - Google Apps Script用のユーティリティ\n\n- utils.js\n  - globalで使うユーティリティ\n\n- date_utils.js\n  - 日付関係のユーティリティ\n\n- underscore.js\n  - _.で始まるユーティリティ集\n  - http://underscorejs.org\n\n\n# License\n\n- [MIT License](http://opensource.org/licenses/MIT)\n- Copyright 2014- Yuichiro MASUI \u003cmasui@masuidrive.jp\u003e\n- https://github.com/masuidrive/miyamoto\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasuidrive%2Fmiyamoto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasuidrive%2Fmiyamoto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasuidrive%2Fmiyamoto/lists"}