From 65489087cd1a1f04955d7ee5272093569ba6f887 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 25 Sep 2020 14:30:25 +0900 Subject: [PATCH] a --- package.json | 2 +- src/modules/poll/index.ts | 16 ++++++++++++---- src/vocabulary.ts | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 4304e7a..d50e6ea 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "_v": "1.2.8", + "_v": "1.2.9", "main": "./built/index.js", "scripts": { "start": "node ./built", diff --git a/src/modules/poll/index.ts b/src/modules/poll/index.ts index c59bffc..e6a2295 100644 --- a/src/modules/poll/index.ts +++ b/src/modules/poll/index.ts @@ -25,7 +25,7 @@ export default class extends Module { @autobind private async post() { - const duration = 1000 * 60 * 10; + const duration = 1000 * 60 * 15; const polls = [ // TODO: Extract serif ['珍しそうなもの', 'みなさんは、どれがいちばん珍しいと思いますか?'], @@ -124,21 +124,29 @@ export default class extends Module { continue; } - // TODO: 同数一位のハンドリング if (choice.votes > mostVotedChoice.votes) { mostVotedChoice = choice; } } + const mostVotedChoices = choices.filter(choice => choice.votes === mostVotedChoice.votes); + if (mostVotedChoice.votes === 0) { this.ai.post({ // TODO: Extract serif text: '投票はありませんでした', renoteId: noteId, }); - } else { + } else if (mostVotedChoices.length === 1) { this.ai.post({ // TODO: Extract serif cw: `${title}アンケートの結果発表です!`, - text: `結果は${mostVotedChoice.votes}票を獲得した「${mostVotedChoice.text}」でした!`, + text: `結果は${mostVotedChoice.votes}票の「${mostVotedChoice.text}」でした!`, + renoteId: noteId, + }); + } else { + const choices = mostVotedChoices.map(choice => `「${choice.text}」`).join('と'); + this.ai.post({ // TODO: Extract serif + cw: `${title}アンケートの結果発表です!`, + text: `結果は${mostVotedChoice.votes}票の${choices}でした!`, renoteId: noteId, }); } diff --git a/src/vocabulary.ts b/src/vocabulary.ts index b74194f..ce12aae 100644 --- a/src/vocabulary.ts +++ b/src/vocabulary.ts @@ -91,6 +91,7 @@ export const itemPrefixes = [ '分散型', '卵かけ', '次世代', + '帯電', ]; export const items = [