From 87002e0f1cc17f6a6ecc46f964560de56fa88be5 Mon Sep 17 00:00:00 2001 From: ilim Date: Sat, 8 Dec 2018 18:41:44 +0900 Subject: [PATCH] =?UTF-8?q?=E5=AE=9F=E9=9A=9B=E3=81=AB=E5=AE=9F=E8=A1=8C?= =?UTF-8?q?=E3=81=99=E3=82=8B=E4=BB=AE=E3=81=AE=E9=96=A2=E6=95=B0=E3=82=92?= =?UTF-8?q?=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 ++++++- app.js | 27 ++++++++++++++++++++++++++- package-lock.json | 41 +++++++++++++++++++++++++++++++++++++++++ slack.js | 2 +- 4 files changed, 74 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e6dc4b0..34ca9f7 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,9 @@ brew install imagesnap Ubuntuは ```shell sudo apt-get install fswebcam -``` \ No newline at end of file +``` + +## Usage +1. `npm install` +1. `npm start` +を実行 \ No newline at end of file diff --git a/app.js b/app.js index a726efc..d47a2cc 100644 --- a/app.js +++ b/app.js @@ -1 +1,26 @@ -'use strict'; \ No newline at end of file +"use strict"; + +const photoapi = require("./photoAPI"); +const {capture} = require("./caputure"); +const slack = require("./slack"); + +const main = async () => { + const oAuth2Client = await photoapi.getOAuthToken(); + + const albumTitle = "bushitsuchan_album"; + const albums = await photoapi.getAlbumList(oAuth2Client); + let album = albums.filter((album) => album.title === albumTitle); + if (!album.length) { + album = await photoapi.createAlbum(oAuth2Client, albumTitle); + await photoapi.shareAlbum(oAuth2Client, album.id); + } + setInterval(async () => { + const url = await capture(oAuth2Client, album); + slack.send(url); // ここをカスタマイズしてください + }, 5000); +}; + + +if (require.main === module) { + main().catch(console.error); +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e2b898c..d3e6f1d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,11 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, "agent-base": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", @@ -423,11 +428,47 @@ "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.6.tgz", "integrity": "sha512-sol30LUpz1jQFBjOKwbjxijiE3b6pjd74YwfD0fJOKPjF+fONKb2Yg8rYgS6+bK6VDl+/wfr4IYpC7jDzLUIfw==" }, + "node-webcam": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/node-webcam/-/node-webcam-0.4.6.tgz", + "integrity": "sha512-TSiTag0jhTlWralSuX3MDbQtagQN/covkZI6S8Ie2gT/xthsmVdBA+GnJVeVLDIeqTKVsl90lsy8vYiLWMVx4w==", + "requires": { + "nopt": "*" + } + }, + "nopt": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", + "requires": { + "abbrev": "1", + "osenv": "^0.1.4" + } + }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, + "os-homedir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "http://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + }, + "osenv": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } + }, "path": { "version": "0.12.7", "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", diff --git a/slack.js b/slack.js index 2d8efe4..eb92dbc 100644 --- a/slack.js +++ b/slack.js @@ -1,6 +1,6 @@ "use strict"; -module.exports.send = (value, value2) => { +module.exports.send = value => { console.log(`未実装ですが以下を投稿したことになりました ${value}`) }; \ No newline at end of file