From 96bd347199db2a6ca02f80ada2176ac015d52a3a Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Thu, 9 Apr 2020 00:16:46 +0900 Subject: [PATCH] format --- app.js | 2 +- index.js | 8 +++----- package.json | 14 +++++++------- scripts/apod.js | 2 +- scripts/dns.js | 2 +- scripts/faiz.js | 6 +++--- scripts/goku.js | 2 +- scripts/ipinfo.js | 4 ++-- scripts/json.js | 2 +- scripts/morpheme.js | 2 +- scripts/nurupo.js | 39 ++++++++++++++++++++------------------- scripts/nyanchu.js | 4 ++-- scripts/random.js | 4 ++-- scripts/tellme.js | 2 +- scripts/unchiku.js | 10 +++++----- scripts/util/morpheme.js | 10 +++++----- scripts/util/random.js | 2 +- scripts/util/tellme.js | 4 ++-- scripts/weather.js | 10 +++++----- scripts/yakitori.js | 5 +++-- 20 files changed, 67 insertions(+), 67 deletions(-) diff --git a/app.js b/app.js index 79c18f3..926a767 100644 --- a/app.js +++ b/app.js @@ -4,7 +4,7 @@ const daraz = require("./"); const app = daraz( new App({ token: process.env.SLACK_BOT_TOKEN, - signingSecret: process.env.SLACK_SIGNING_SECRET + signingSecret: process.env.SLACK_SIGNING_SECRET, }) ); diff --git a/index.js b/index.js index cdae240..5efe3e9 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,7 @@ -const scripts = require("glob") - .sync("./scripts/*.js") - .map(require); +const scripts = require("glob").sync("./scripts/*.js").map(require); -module.exports = app => { - scripts.forEach(script => { +module.exports = (app) => { + scripts.forEach((script) => { if (Array.isArray(script)) return app.message(...script); if (script instanceof Function) return script(app); }); diff --git a/package.json b/package.json index ff3ebf5..df2376e 100644 --- a/package.json +++ b/package.json @@ -15,14 +15,14 @@ "start": "node app.js" }, "dependencies": { - "@slack/bolt": "~2.0.0", - "date-fns": "~2", - "date-fns-tz": "~1", - "get-video-id": "~3", - "glob": "~7", + "@slack/bolt": "2.x", + "date-fns": "2.x", + "date-fns-tz": "1.x", + "get-video-id": "3.x", + "glob": "7.x", "kuromoji": "0.1.x", - "node-fetch": "~2", - "tldjs": "~2" + "node-fetch": "2.x", + "tldjs": "2.x" }, "engines": { "yarn": "1.x" diff --git a/scripts/apod.js b/scripts/apod.js index 3915b88..6156af1 100644 --- a/scripts/apod.js +++ b/scripts/apod.js @@ -19,5 +19,5 @@ module.exports = [ ? `https://www.youtube.com/watch?v=${get_video_id(dict.url)}` : dict.url; say(`宇宙って良いにゃーん\n${dict.title}\n${url}`); - } + }, ]; diff --git a/scripts/dns.js b/scripts/dns.js index 3cd5747..70af3ff 100644 --- a/scripts/dns.js +++ b/scripts/dns.js @@ -18,5 +18,5 @@ module.exports = [ } catch { say(`:nya-n: < ${domain} はわかんなかったにゃん`); } - } + }, ]; diff --git a/scripts/faiz.js b/scripts/faiz.js index d0a9a1b..b06afa0 100644 --- a/scripts/faiz.js +++ b/scripts/faiz.js @@ -1,4 +1,4 @@ -module.exports = app => { +module.exports = (app) => { app.message(/555/, ({ say }) => { say( [ @@ -6,7 +6,7 @@ module.exports = app => { "キュィーン…キュィーン…キュィーン… > :nya-n:", "Complete > :nya-n:", "変身! > :nya-n:", - ":555: ノシ" + ":555: ノシ", ].join("\n") ); }); @@ -28,7 +28,7 @@ module.exports = app => { "  | 3 (∪ ̄]", " く、・〟 (∩ ̄]", " ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄", - "```" + "```", ].join("\n") ); }); diff --git a/scripts/goku.js b/scripts/goku.js index 027c34f..b9b6aaf 100644 --- a/scripts/goku.js +++ b/scripts/goku.js @@ -2,5 +2,5 @@ module.exports = [ /([\s\S]*(ぱい|パイ)[\s\S]*)/, ({ context, say }) => { say(`:goku: < ${context.matches[0].replace(/ぱい|パイ/g, "ぺぇ")}`); - } + }, ]; diff --git a/scripts/ipinfo.js b/scripts/ipinfo.js index 9bdb021..70ddfb5 100644 --- a/scripts/ipinfo.js +++ b/scripts/ipinfo.js @@ -7,7 +7,7 @@ module.exports = [ const url = `https://ipinfo.io/${ip}`; const options = { timeout: 2000, - headers: { Accept: "application/json" } + headers: { Accept: "application/json" }, }; const response = await fetch(url, options); say( @@ -15,5 +15,5 @@ module.exports = [ ? `:nya-n: < ${await response.text()}` : `:nya-n: < がんばったけど ${ip} よくわからんかったにゃん` ); - } + }, ]; diff --git a/scripts/json.js b/scripts/json.js index 6c2aca8..62bed20 100644 --- a/scripts/json.js +++ b/scripts/json.js @@ -18,5 +18,5 @@ module.exports = [ } catch (e) { console.error(e); } - } + }, ]; diff --git a/scripts/morpheme.js b/scripts/morpheme.js index 0ba815a..fb4dd9a 100644 --- a/scripts/morpheme.js +++ b/scripts/morpheme.js @@ -20,5 +20,5 @@ module.exports = [ } catch (e) { console.error(e); } - } + }, ]; diff --git a/scripts/nurupo.js b/scripts/nurupo.js index e52a2ab..19f9d80 100644 --- a/scripts/nurupo.js +++ b/scripts/nurupo.js @@ -11,35 +11,35 @@ const patterns = [ `${nyanco()} < ${ context.matches[2] ? "にゃーん" : "さんを付けろよデコスケ野郎っ!" }` - ) + ), ], [/こたつ/, ({ say }) => say(`${nyanco()} < しまえ`)], [/(しお|塩)/, ({ say }) => say(`${nyanco()} < しお`)], [ /(らーめん|ラーメン|拉麺|らうめん)/, - ({ say }) => say(`${nyanco()} < :ramen:`) + ({ say }) => say(`${nyanco()} < :ramen:`), ], [/しりとり/, ({ say }) => say(`${nyanco()} < うどん。`)], [ /(糞|くそ|クソ)(すれ|スレ)/, - ({ say }) => say(`${nyanco()} < クソスレで悪かったな!!`) + ({ say }) => say(`${nyanco()} < クソスレで悪かったな!!`), ], [ /(カレー|かれー|華麗)/, - ({ say }) => say("https://pbs.twimg.com/media/C-RVt9pUAAARRVe.jpg") + ({ say }) => say("https://pbs.twimg.com/media/C-RVt9pUAAARRVe.jpg"), ], [ /(すし|鮨|寿司|スシ|まぐろ|マグロ|sushi)/i, - ({ say }) => say(`${nyanco()} < あいよ っ :sushi:`) + ({ say }) => say(`${nyanco()} < あいよ っ :sushi:`), ], [/ちゃ|茶/, ({ say }) => say(`お茶どぞー < ${nyanco()}っ :tea:`)], [ /風邪|かぜ|カゼ|体調|つらい|くるしい|痛い|ひぎぃ|うぐぅ/, - ({ say }) => say(`おくすりどぞー < ${nyanco()}っ :pill:`) + ({ say }) => say(`おくすりどぞー < ${nyanco()}っ :pill:`), ], [ /(ちらし|チラシ|広告)/, - ({ say }) => say(`${nyanco()} < スタンプラリーやめれ`) + ({ say }) => say(`${nyanco()} < スタンプラリーやめれ`), ], [ /進捗どうですか/, @@ -49,10 +49,10 @@ const patterns = [ [ `${nyanco()} < そう言うと ${from} は永い眠りについた。`, `メールとチケットが山のように積もった部屋の片隅で・・・。`, - `主を失ったモニタのあかりだけが、動かなくなった ${from} を優しく照らし続けた。` + `主を失ったモニタのあかりだけが、動かなくなった ${from} を優しく照らし続けた。`, ].join("") ); - } + }, ], [ /(のむら|さちよ|野村|沙知代|さっちー|サッチー|のむさん|ノムサン)/, @@ -61,9 +61,9 @@ const patterns = [ [ ":nomura-exodia-1::nomura-exodia-2::nomura-exodia-3:", ":nomura-exodia-4::nomura-exodia-5::nomura-exodia-6: :exclamation::question:", - ":nomura-exodia-7::nomura-exodia-8::nomura-exodia-9:" + ":nomura-exodia-7::nomura-exodia-8::nomura-exodia-9:", ].join("\n") - ) + ), ], [ /(肉|にく|ニク)/, @@ -74,10 +74,10 @@ const patterns = [ ":spark-exodia-00::spark-exodia-01::spark-exodia-02::spark-exodia-03::spark-exodia-04::spark-exodia-05:", ":spark-exodia-06::spark-exodia-07::spark-exodia-08::spark-exodia-09::spark-exodia-10::spark-exodia-11:", ":spark-exodia-12::spark-exodia-13::spark-exodia-14::spark-exodia-15::spark-exodia-16::spark-exodia-17:", - ":spark-exodia-18::spark-exodia-19::spark-exodia-20::spark-exodia-21::spark-exodia-22::spark-exodia-23:" + ":spark-exodia-18::spark-exodia-19::spark-exodia-20::spark-exodia-21::spark-exodia-22::spark-exodia-23:", ].join("\n") ); - } + }, ], [ /(野球|やきゅう|やきう)/, @@ -87,10 +87,10 @@ const patterns = [ [ ":nomura-exodia-1::nomura-exodia-2::nomura-exodia-3:", ":nomura-exodia-4::nomura-exodia-5::nomura-exodia-6: :exclamation::question:", - ":nomura-exodia-7::nomura-exodia-8::nomura-exodia-9:" + ":nomura-exodia-7::nomura-exodia-8::nomura-exodia-9:", ].join("\n") ); - } + }, ], [ /.*(ね|ネ).+(ハム|はむ)(たろう|たろー|タロウ|タロー|太郎)/, @@ -103,12 +103,13 @@ const patterns = [ } else { say(":hamster: < まったくなのだ!!!"); } - } + }, ], [ /^(?=.*[eE]macs)(?=.*[vV]i)/, - ({ say }) => say(`${nyanco()} < Emacs vs. Vi ファイ!`) - ] + ({ say }) => say(`${nyanco()} < Emacs vs. Vi ファイ!`), + ], ]; -module.exports = app => patterns.forEach(pattern => app.message(...pattern)); +module.exports = (app) => + patterns.forEach((pattern) => app.message(...pattern)); diff --git a/scripts/nyanchu.js b/scripts/nyanchu.js index bd5ffd9..466b3ee 100644 --- a/scripts/nyanchu.js +++ b/scripts/nyanchu.js @@ -4,7 +4,7 @@ module.exports = [ directMention(), /(ニャンちゅう) +(.*)/, ({ context, say }) => { - const oon = context.matches[2].split("").map(c => `${c}゛`); + const oon = context.matches[2].split("").map((c) => `${c}゛`); say(`お゛ぉ゛ん!${oon.join("")}た゛に゛ゃあ゛ん! > :nyanchu:`); - } + }, ]; diff --git a/scripts/random.js b/scripts/random.js index 3bdd4e8..c9dd355 100644 --- a/scripts/random.js +++ b/scripts/random.js @@ -16,8 +16,8 @@ module.exports = [ ({ context, say }) => { const words = [ ...context.matches[2].split(/(?:,|\s)+/), - "人に決められるだけの人生でいいのか?自分で決めようず" + "人に決められるだけの人生でいいのか?自分で決めようず", ]; say(`:nya-n: < ${random(words)}`); - } + }, ]; diff --git a/scripts/tellme.js b/scripts/tellme.js index aa5e39c..239bbda 100644 --- a/scripts/tellme.js +++ b/scripts/tellme.js @@ -14,5 +14,5 @@ module.exports = [ async ({ context, say }) => { const ans = await tellme(context.matches[2]); if (ans != null) say(`${nyanco()} < ${ans}`); - } + }, ]; diff --git a/scripts/unchiku.js b/scripts/unchiku.js index b4d0d58..5274a75 100644 --- a/scripts/unchiku.js +++ b/scripts/unchiku.js @@ -13,10 +13,10 @@ module.exports = [ const words = tokenize(context.matches[0]) .filter(({ pos }) => pos === "名詞") .map(({ surface_form }) => surface_form) - .filter(t => !/^[\u3040-\u309F]$/.test(t)) //ひらがな1文字 http://www.unicode.org/charts/PDF/U3040.pdf - .filter(t => !/^[\u30A0-\u30FF]$/.test(t)) //かたかな1文字 http://www.unicode.org/charts/PDF/U30A0.pdf - .filter(t => !/^[\uFF65-\uFF9F]$/.test(t)) //半角カナ1文字 http://www.unicode.org/charts/PDF/UFF00.pdf - .filter(t => !/[、・…]/.test(t)); + .filter((t) => !/^[\u3040-\u309F]$/.test(t)) //ひらがな1文字 http://www.unicode.org/charts/PDF/U3040.pdf + .filter((t) => !/^[\u30A0-\u30FF]$/.test(t)) //かたかな1文字 http://www.unicode.org/charts/PDF/U30A0.pdf + .filter((t) => !/^[\uFF65-\uFF9F]$/.test(t)) //半角カナ1文字 http://www.unicode.org/charts/PDF/UFF00.pdf + .filter((t) => !/[、・…]/.test(t)); const word = random(words); const ans = await tellme(word); if (/^(|…|しらないにゃーん)$/.test(ans)) { @@ -26,5 +26,5 @@ module.exports = [ } catch (e) { console.error(e); } - } + }, ]; diff --git a/scripts/util/morpheme.js b/scripts/util/morpheme.js index d7d8588..a1ea31c 100644 --- a/scripts/util/morpheme.js +++ b/scripts/util/morpheme.js @@ -24,15 +24,15 @@ const features = new Map([ ["conjugated_form", "活用形"], ["basic_form", "基本形"], ["reading", "読み"], - ["pronunciation", "発音"] + ["pronunciation", "発音"], ]); -const toCSV = tokens => +const toCSV = (tokens) => [ [...features.values()].join(","), - ...tokens.map(token => - [...features.keys()].map(feature => token[feature]).join(",") - ) + ...tokens.map((token) => + [...features.keys()].map((feature) => token[feature]).join(",") + ), ].join("\n"); module.exports = { useTokenize, toCSV }; diff --git a/scripts/util/random.js b/scripts/util/random.js index 08fb9ee..cf5049c 100644 --- a/scripts/util/random.js +++ b/scripts/util/random.js @@ -1 +1 @@ -module.exports = array => array[Math.floor(Math.random() * array.length)]; +module.exports = (array) => array[Math.floor(Math.random() * array.length)]; diff --git a/scripts/util/tellme.js b/scripts/util/tellme.js index e460e97..6ceebdb 100644 --- a/scripts/util/tellme.js +++ b/scripts/util/tellme.js @@ -1,6 +1,6 @@ const fetch = require("node-fetch"); -module.exports = async titles => { +module.exports = async (titles) => { const url = new URL("https://ja.wikipedia.org/w/api.php"); const params = new URLSearchParams({ action: "query", @@ -9,7 +9,7 @@ module.exports = async titles => { titles, redirects: "", exchars: 120, - explaintext: "" + explaintext: "", }); try { const response = await fetch([url, params].join("?")); diff --git a/scripts/weather.js b/scripts/weather.js index d83bbe0..a18ad63 100644 --- a/scripts/weather.js +++ b/scripts/weather.js @@ -7,11 +7,11 @@ const nyanco = require("./util/nyanco"); const timeZone = "Asia/Tokyo"; const prefNumber = 34; const pageURL = `https://www.tenki.jp/radar/7/${prefNumber}/`; -const imgURL = target => +const imgURL = (target) => [ "https://static.tenki.jp/static-images/radar/", format(target, "yyyy/MM/dd/HH/mm/ss", { timeZone }), - `/pref-${prefNumber}-large.jpg` + `/pref-${prefNumber}-large.jpg`, ].join(""); module.exports = [ @@ -19,7 +19,7 @@ module.exports = [ async ({ say }) => { const target = utcToZonedTime( roundToNearestMinutes(subMinutes(new Date(), 5), { - nearestTo: 5 + nearestTo: 5, }), timeZone ); @@ -32,8 +32,8 @@ module.exports = [ timeZone )}`, imgURL(target), - pageURL + pageURL, ].join("\n") ); - } + }, ]; diff --git a/scripts/yakitori.js b/scripts/yakitori.js index 997f5fb..ebfc4dc 100644 --- a/scripts/yakitori.js +++ b/scripts/yakitori.js @@ -10,10 +10,11 @@ const yakitoris = [ "―зεз- 軟骨", "―⊂ZZZ⊃ ソーセージ", "―<コ:彡- イカ丸焼き", - "―>゚)))彡- 魚丸焼き" + "―>゚)))彡- 魚丸焼き", ]; module.exports = [ /焼鳥|焼き鳥|やきとり|ヤキトリ|串|プロキシ|プロクシ|proxy|Proxy|PROXY|ピロシキ/, - ({ say }) => say(`串焼きでも食べるにゃん < ${nyanco()}っ${random(yakitoris)}`) + ({ say }) => + say(`串焼きでも食べるにゃん < ${nyanco()}っ${random(yakitoris)}`), ];