From 7f21f1055bf1bf7c0947f7238f71ae177d1a6080 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 4 Aug 2018 20:37:26 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC=E3=81=8C?= =?UTF-8?q?=E8=97=8D=E3=81=8C=E5=AF=BE=E5=B1=80=E6=83=85=E5=A0=B1=E3=82=92?= =?UTF-8?q?=E6=8A=95=E7=A8=BF=E3=81=99=E3=82=8B=E3=81=AE=E3=82=92=E8=A8=B1?= =?UTF-8?q?=E5=8F=AF=E3=81=99=E3=82=8B=E3=81=8B=E5=90=A6=E3=81=8B=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/back.ts | 71 ++++++++++++++++++++++++++++------------------------ src/front.ts | 5 ++++ 2 files changed, 43 insertions(+), 33 deletions(-) diff --git a/src/back.ts b/src/back.ts index b12cedd..a30dd6e 100644 --- a/src/back.ts +++ b/src/back.ts @@ -37,20 +37,22 @@ process.on('message', async msg => { onGameStarted(msg.body); //#region TLに投稿する - const game = msg.body; - const url = `${config.host}/reversi/${game.id}`; - const user = game.user1Id == config.id ? game.user2 : game.user1; - const isSettai = form[0].value === 0; - const text = isSettai - ? `?[${getUserName(user)}](${config.host}/@${user.username})さんの接待を始めました!` - : `対局を?[${getUserName(user)}](${config.host}/@${user.username})さんと始めました! (強さ${form[0].value})`; + if (form.find(i => i.id == 'publish').value) { + const game = msg.body; + const url = `${config.host}/reversi/${game.id}`; + const user = game.user1Id == config.id ? game.user2 : game.user1; + const isSettai = form[0].value === 0; + const text = isSettai + ? `?[${getUserName(user)}](${config.host}/@${user.username})さんの接待を始めました!` + : `対局を?[${getUserName(user)}](${config.host}/@${user.username})さんと始めました! (強さ${form[0].value})`; - const res = await request.post(`${config.host}/api/notes/create`, { - json: { - i: config.i, - text: `${text}\n→[観戦する](${url})` - } - }); + const res = await request.post(`${config.host}/api/notes/create`, { + json: { + i: config.i, + text: `${text}\n→[観戦する](${url})` + } + }); + } note = res.createdNote; //#endregion @@ -64,28 +66,31 @@ process.on('message', async msg => { }); //#region TLに投稿する - const user = game.user1Id == config.id ? game.user2 : game.user1; - const isSettai = form[0].value === 0; - const text = isSettai - ? msg.body.winnerId === null - ? `?[${getUserName(user)}](${config.host}/@${user.username})さんに接待で引き分けました...` - : msg.body.winnerId == config.id - ? `?[${getUserName(user)}](${config.host}/@${user.username})さんに接待で勝ってしまいました...` - : `?[${getUserName(user)}](${config.host}/@${user.username})さんに接待で負けてあげました♪` - : msg.body.winnerId === null - ? `?[${getUserName(user)}](${config.host}/@${user.username})さんと引き分けました~` - : msg.body.winnerId == config.id - ? `?[${getUserName(user)}](${config.host}/@${user.username})さんに勝ちました♪` - : `?[${getUserName(user)}](${config.host}/@${user.username})さんに負けました...`; + if (form.find(i => i.id == 'publish').value) { + const user = game.user1Id == config.id ? game.user2 : game.user1; + const isSettai = form[0].value === 0; + const text = isSettai + ? msg.body.winnerId === null + ? `?[${getUserName(user)}](${config.host}/@${user.username})さんに接待で引き分けました...` + : msg.body.winnerId == config.id + ? `?[${getUserName(user)}](${config.host}/@${user.username})さんに接待で勝ってしまいました...` + : `?[${getUserName(user)}](${config.host}/@${user.username})さんに接待で負けてあげました♪` + : msg.body.winnerId === null + ? `?[${getUserName(user)}](${config.host}/@${user.username})さんと引き分けました~` + : msg.body.winnerId == config.id + ? `?[${getUserName(user)}](${config.host}/@${user.username})さんに勝ちました♪` + : `?[${getUserName(user)}](${config.host}/@${user.username})さんに負けました...`; - await request.post(`${config.host}/api/notes/create`, { - json: { - i: config.i, - renoteId: note ? note.id : null, - text: text - } - }); + await request.post(`${config.host}/api/notes/create`, { + json: { + i: config.i, + renoteId: note ? note.id : null, + text: text + } + }); + } //#endregion + process.exit(); } diff --git a/src/front.ts b/src/front.ts index 5cc89f1..085bbea 100644 --- a/src/front.ts +++ b/src/front.ts @@ -132,6 +132,11 @@ function gameStart(game) { // フォーム const form = [{ + id: 'publish', + type: 'switch', + label: '藍が対局情報を投稿するのを許可', + value: true + }, { id: 'strength', type: 'radio', label: '強さ',