1
0
Fork 0
mirror of https://github.com/kou029w/daraz-san.git synced 2025-01-18 16:08:06 +00:00
This commit is contained in:
Nebel 2020-04-09 00:16:46 +09:00
parent 41149d0b1b
commit 96bd347199
20 changed files with 67 additions and 67 deletions

2
app.js
View file

@ -4,7 +4,7 @@ const daraz = require("./");
const app = daraz( const app = daraz(
new App({ new App({
token: process.env.SLACK_BOT_TOKEN, token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET signingSecret: process.env.SLACK_SIGNING_SECRET,
}) })
); );

View file

@ -1,9 +1,7 @@
const scripts = require("glob") const scripts = require("glob").sync("./scripts/*.js").map(require);
.sync("./scripts/*.js")
.map(require);
module.exports = app => { module.exports = (app) => {
scripts.forEach(script => { scripts.forEach((script) => {
if (Array.isArray(script)) return app.message(...script); if (Array.isArray(script)) return app.message(...script);
if (script instanceof Function) return script(app); if (script instanceof Function) return script(app);
}); });

View file

@ -15,14 +15,14 @@
"start": "node app.js" "start": "node app.js"
}, },
"dependencies": { "dependencies": {
"@slack/bolt": "~2.0.0", "@slack/bolt": "2.x",
"date-fns": "~2", "date-fns": "2.x",
"date-fns-tz": "~1", "date-fns-tz": "1.x",
"get-video-id": "~3", "get-video-id": "3.x",
"glob": "~7", "glob": "7.x",
"kuromoji": "0.1.x", "kuromoji": "0.1.x",
"node-fetch": "~2", "node-fetch": "2.x",
"tldjs": "~2" "tldjs": "2.x"
}, },
"engines": { "engines": {
"yarn": "1.x" "yarn": "1.x"

View file

@ -19,5 +19,5 @@ module.exports = [
? `https://www.youtube.com/watch?v=${get_video_id(dict.url)}` ? `https://www.youtube.com/watch?v=${get_video_id(dict.url)}`
: dict.url; : dict.url;
say(`宇宙って良いにゃーん\n${dict.title}\n${url}`); say(`宇宙って良いにゃーん\n${dict.title}\n${url}`);
} },
]; ];

View file

@ -18,5 +18,5 @@ module.exports = [
} catch { } catch {
say(`:nya-n: < ${domain} はわかんなかったにゃん`); say(`:nya-n: < ${domain} はわかんなかったにゃん`);
} }
} },
]; ];

View file

@ -1,4 +1,4 @@
module.exports = app => { module.exports = (app) => {
app.message(/555/, ({ say }) => { app.message(/555/, ({ say }) => {
say( say(
[ [
@ -6,7 +6,7 @@ module.exports = app => {
"キュィーン…キュィーン…キュィーン… > :nya-n:", "キュィーン…キュィーン…キュィーン… > :nya-n:",
"Complete > :nya-n:", "Complete > :nya-n:",
"変身! > :nya-n:", "変身! > :nya-n:",
":555: ノシ" ":555: ノシ",
].join("\n") ].join("\n")
); );
}); });
@ -28,7 +28,7 @@ module.exports = app => {
"  | 3 (∪ ̄]", "  | 3 (∪ ̄]",
" く、・〟 (∩ ̄]", " く、・〟 (∩ ̄]",
" ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄", " ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄",
"```" "```",
].join("\n") ].join("\n")
); );
}); });

View file

@ -2,5 +2,5 @@ module.exports = [
/([\s\S]*(ぱい|パイ)[\s\S]*)/, /([\s\S]*(ぱい|パイ)[\s\S]*)/,
({ context, say }) => { ({ context, say }) => {
say(`:goku: < ${context.matches[0].replace(/ぱい|パイ/g, "ぺぇ")}`); say(`:goku: < ${context.matches[0].replace(/ぱい|パイ/g, "ぺぇ")}`);
} },
]; ];

View file

@ -7,7 +7,7 @@ module.exports = [
const url = `https://ipinfo.io/${ip}`; const url = `https://ipinfo.io/${ip}`;
const options = { const options = {
timeout: 2000, timeout: 2000,
headers: { Accept: "application/json" } headers: { Accept: "application/json" },
}; };
const response = await fetch(url, options); const response = await fetch(url, options);
say( say(
@ -15,5 +15,5 @@ module.exports = [
? `:nya-n: < ${await response.text()}` ? `:nya-n: < ${await response.text()}`
: `:nya-n: < がんばったけど ${ip} よくわからんかったにゃん` : `:nya-n: < がんばったけど ${ip} よくわからんかったにゃん`
); );
} },
]; ];

View file

@ -18,5 +18,5 @@ module.exports = [
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
} },
]; ];

View file

@ -20,5 +20,5 @@ module.exports = [
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
} },
]; ];

View file

@ -11,35 +11,35 @@ const patterns = [
`${nyanco()} < ${ `${nyanco()} < ${
context.matches[2] ? "にゃーん" : "さんを付けろよデコスケ野郎っ!" context.matches[2] ? "にゃーん" : "さんを付けろよデコスケ野郎っ!"
}` }`
) ),
], ],
[/こたつ/, ({ say }) => say(`${nyanco()} < しまえ`)], [/こたつ/, ({ say }) => say(`${nyanco()} < しまえ`)],
[/(しお|塩)/, ({ 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(`${nyanco()} < クソスレで悪かったな!!`),
], ],
[ [
/(カレー|かれー|華麗)/, /(カレー|かれー|華麗)/,
({ say }) => say("https://pbs.twimg.com/media/C-RVt9pUAAARRVe.jpg") ({ say }) => say("https://pbs.twimg.com/media/C-RVt9pUAAARRVe.jpg"),
], ],
[ [
/(すし|鮨|寿司|スシ|まぐろ|マグロ|sushi)/i, /(すし|鮨|寿司|スシ|まぐろ|マグロ|sushi)/i,
({ say }) => say(`${nyanco()} < あいよ っ :sushi:`) ({ say }) => say(`${nyanco()} < あいよ っ :sushi:`),
], ],
[/ちゃ|茶/, ({ say }) => say(`お茶どぞー < ${nyanco()}っ :tea:`)], [/ちゃ|茶/, ({ 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} は永い眠りについた。`, `${nyanco()} < そう言うと ${from} は永い眠りについた。`,
`メールとチケットが山のように積もった部屋の片隅で・・・。`, `メールとチケットが山のように積もった部屋の片隅で・・・。`,
`主を失ったモニタのあかりだけが、動かなくなった ${from} を優しく照らし続けた。` `主を失ったモニタのあかりだけが、動かなくなった ${from} を優しく照らし続けた。`,
].join("") ].join("")
); );
} },
], ],
[ [
/(のむら|さちよ|野村|沙知代|さっちー|サッチー|のむさん|ノムサン)/, /(のむら|さちよ|野村|沙知代|さっちー|サッチー|のむさん|ノムサン)/,
@ -61,9 +61,9 @@ const patterns = [
[ [
":nomura-exodia-1::nomura-exodia-2::nomura-exodia-3:", ":nomura-exodia-1::nomura-exodia-2::nomura-exodia-3:",
":nomura-exodia-4::nomura-exodia-5::nomura-exodia-6: :exclamation::question:", ":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") ].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-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-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-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") ].join("\n")
); );
} },
], ],
[ [
/(野球|やきゅう|やきう)/, /(野球|やきゅう|やきう)/,
@ -87,10 +87,10 @@ const patterns = [
[ [
":nomura-exodia-1::nomura-exodia-2::nomura-exodia-3:", ":nomura-exodia-1::nomura-exodia-2::nomura-exodia-3:",
":nomura-exodia-4::nomura-exodia-5::nomura-exodia-6: :exclamation::question:", ":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") ].join("\n")
); );
} },
], ],
[ [
/.*(ね|ネ).+(ハム|はむ)(たろう|たろー|タロウ|タロー|太郎)/, /.*(ね|ネ).+(ハム|はむ)(たろう|たろー|タロウ|タロー|太郎)/,
@ -103,12 +103,13 @@ const patterns = [
} else { } else {
say(":hamster: < まったくなのだ!!!"); say(":hamster: < まったくなのだ!!!");
} }
} },
], ],
[ [
/^(?=.*[eE]macs)(?=.*[vV]i)/, /^(?=.*[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));

View file

@ -4,7 +4,7 @@ module.exports = [
directMention(), directMention(),
/(ニャンちゅう) +(.*)/, /(ニャンちゅう) +(.*)/,
({ context, say }) => { ({ context, say }) => {
const oon = context.matches[2].split("").map(c => `${c}`); const oon = context.matches[2].split("").map((c) => `${c}`);
say(`お゛ぉ゛ん!${oon.join("")}た゛に゛ゃあ゛ん! > :nyanchu:`); say(`お゛ぉ゛ん!${oon.join("")}た゛に゛ゃあ゛ん! > :nyanchu:`);
} },
]; ];

View file

@ -16,8 +16,8 @@ module.exports = [
({ context, say }) => { ({ context, say }) => {
const words = [ const words = [
...context.matches[2].split(/(?:,|\s)+/), ...context.matches[2].split(/(?:,|\s)+/),
"人に決められるだけの人生でいいのか?自分で決めようず" "人に決められるだけの人生でいいのか?自分で決めようず",
]; ];
say(`:nya-n: < ${random(words)}`); say(`:nya-n: < ${random(words)}`);
} },
]; ];

View file

@ -14,5 +14,5 @@ module.exports = [
async ({ context, say }) => { async ({ context, say }) => {
const ans = await tellme(context.matches[2]); const ans = await tellme(context.matches[2]);
if (ans != null) say(`${nyanco()} ${ans}`); if (ans != null) say(`${nyanco()} ${ans}`);
} },
]; ];

View file

@ -13,10 +13,10 @@ module.exports = [
const words = tokenize(context.matches[0]) const words = tokenize(context.matches[0])
.filter(({ pos }) => pos === "名詞") .filter(({ pos }) => pos === "名詞")
.map(({ surface_form }) => surface_form) .map(({ surface_form }) => surface_form)
.filter(t => !/^[\u3040-\u309F]$/.test(t)) //ひらがな1文字 http://www.unicode.org/charts/PDF/U3040.pdf .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) => !/^[\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) => !/^[\uFF65-\uFF9F]$/.test(t)) //半角カナ1文字 http://www.unicode.org/charts/PDF/UFF00.pdf
.filter(t => !/[、・…]/.test(t)); .filter((t) => !/[、・…]/.test(t));
const word = random(words); const word = random(words);
const ans = await tellme(word); const ans = await tellme(word);
if (/^(|…|しらないにゃーん)$/.test(ans)) { if (/^(|…|しらないにゃーん)$/.test(ans)) {
@ -26,5 +26,5 @@ module.exports = [
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
} },
]; ];

View file

@ -24,15 +24,15 @@ const features = new Map([
["conjugated_form", "活用形"], ["conjugated_form", "活用形"],
["basic_form", "基本形"], ["basic_form", "基本形"],
["reading", "読み"], ["reading", "読み"],
["pronunciation", "発音"] ["pronunciation", "発音"],
]); ]);
const toCSV = tokens => const toCSV = (tokens) =>
[ [
[...features.values()].join(","), [...features.values()].join(","),
...tokens.map(token => ...tokens.map((token) =>
[...features.keys()].map(feature => token[feature]).join(",") [...features.keys()].map((feature) => token[feature]).join(",")
) ),
].join("\n"); ].join("\n");
module.exports = { useTokenize, toCSV }; module.exports = { useTokenize, toCSV };

View file

@ -1 +1 @@
module.exports = array => array[Math.floor(Math.random() * array.length)]; module.exports = (array) => array[Math.floor(Math.random() * array.length)];

View file

@ -1,6 +1,6 @@
const fetch = require("node-fetch"); 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 url = new URL("https://ja.wikipedia.org/w/api.php");
const params = new URLSearchParams({ const params = new URLSearchParams({
action: "query", action: "query",
@ -9,7 +9,7 @@ module.exports = async titles => {
titles, titles,
redirects: "", redirects: "",
exchars: 120, exchars: 120,
explaintext: "" explaintext: "",
}); });
try { try {
const response = await fetch([url, params].join("?")); const response = await fetch([url, params].join("?"));

View file

@ -7,11 +7,11 @@ const nyanco = require("./util/nyanco");
const timeZone = "Asia/Tokyo"; const timeZone = "Asia/Tokyo";
const prefNumber = 34; const prefNumber = 34;
const pageURL = `https://www.tenki.jp/radar/7/${prefNumber}/`; const pageURL = `https://www.tenki.jp/radar/7/${prefNumber}/`;
const imgURL = target => const imgURL = (target) =>
[ [
"https://static.tenki.jp/static-images/radar/", "https://static.tenki.jp/static-images/radar/",
format(target, "yyyy/MM/dd/HH/mm/ss", { timeZone }), format(target, "yyyy/MM/dd/HH/mm/ss", { timeZone }),
`/pref-${prefNumber}-large.jpg` `/pref-${prefNumber}-large.jpg`,
].join(""); ].join("");
module.exports = [ module.exports = [
@ -19,7 +19,7 @@ module.exports = [
async ({ say }) => { async ({ say }) => {
const target = utcToZonedTime( const target = utcToZonedTime(
roundToNearestMinutes(subMinutes(new Date(), 5), { roundToNearestMinutes(subMinutes(new Date(), 5), {
nearestTo: 5 nearestTo: 5,
}), }),
timeZone timeZone
); );
@ -32,8 +32,8 @@ module.exports = [
timeZone timeZone
)}`, )}`,
imgURL(target), imgURL(target),
pageURL pageURL,
].join("\n") ].join("\n")
); );
} },
]; ];

View file

@ -10,10 +10,11 @@ const yakitoris = [
"―зεз- 軟骨", "―зεз- 軟骨",
"―⊂ZZZ⊃ ソーセージ", "―⊂ZZZ⊃ ソーセージ",
"―<コ:彡- イカ丸焼き", "―<コ:彡- イカ丸焼き",
"―>゚)))彡- 魚丸焼き" "―>゚)))彡- 魚丸焼き",
]; ];
module.exports = [ module.exports = [
/焼鳥|焼き鳥|やきとり|ヤキトリ|串|プロキシ|プロクシ|proxy|Proxy|PROXY|ピロシキ/, /焼鳥|焼き鳥|やきとり|ヤキトリ|串|プロキシ|プロクシ|proxy|Proxy|PROXY|ピロシキ/,
({ say }) => say(`串焼きでも食べるにゃん < ${nyanco()}${random(yakitoris)}`) ({ say }) =>
say(`串焼きでも食べるにゃん < ${nyanco()}${random(yakitoris)}`),
]; ];