From f79a905a1dd2ace3ca758c38e3961299155dc0c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Sun, 5 Aug 2018 18:48:44 +0900 Subject: [PATCH 1/2] Update back.ts --- src/back.ts | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/back.ts b/src/back.ts index f1dead6..c134e01 100644 --- a/src/back.ts +++ b/src/back.ts @@ -20,6 +20,13 @@ function getUserName(user) { return user.name || user.username; } +const titles = [ + 'さん', 'サン', 'サン', '㌠', + 'ちゃん', 'チャン', 'チャン', + '君', 'くん', 'クン', 'クン', + '先生', 'せんせい', 'センセイ', 'センセイ' +]; + process.on('message', async msg => { // 親プロセスからデータをもらう if (msg.type == '_init_') { @@ -71,18 +78,7 @@ process.on('message', async msg => { const user = game.user1Id == config.id ? game.user2 : game.user1; const strength = form.find(i => i.id == 'strength').value; const isSettai = strength === 0; - const text = msg.body.game.surrendered ? `?[${getUserName(user)}](${config.host}/@${user.username})さんが投了しちゃいました` : 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})さんに負けました...`; - + const text = `?[${getUserName(user)}](${config.host}/@${user.username})${titles.some(x => user.username.endsWith(x)) ? '' : 'さん'}${msg.body.game.surrendered ? 'が投了しちゃいました' : msg.body.winnerId ? msg.body.winnerId == config.id ? (isSettai ? 'に接待で勝ってしまいました...' : 'に勝ちました♪') : (isSettai ? 'に接待で負けてあげました♪' : 'に負けました...') : (isSettai ? 'に接待で引き分けました...' : 'と引き分けました~')}`; await request.post(`${config.host}/api/notes/create`, { json: { i: config.i, From bb42422313b019d29c1a40ac9e382acbc290d3f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Sun, 5 Aug 2018 18:49:54 +0900 Subject: [PATCH 2/2] Update back.ts --- src/back.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/back.ts b/src/back.ts index c134e01..e26f733 100644 --- a/src/back.ts +++ b/src/back.ts @@ -51,8 +51,8 @@ process.on('message', async msg => { const strength = form.find(i => i.id == 'strength').value; const isSettai = strength === 0; const text = isSettai - ? `?[${getUserName(user)}](${config.host}/@${user.username})さんの接待を始めました!` - : `対局を?[${getUserName(user)}](${config.host}/@${user.username})さんと始めました! (強さ${strength})`; + ? `?[${getUserName(user)}](${config.host}/@${user.username})${titles.some(x => user.username.endsWith(x)) ? '' : 'さん'}の接待を始めました!` + : `対局を?[${getUserName(user)}](${config.host}/@${user.username})${titles.some(x => user.username.endsWith(x)) ? '' : 'さん'}と始めました! (強さ${strength})`; const res = await request.post(`${config.host}/api/notes/create`, { json: {