diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-03-16 22:38:28 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-03-16 22:38:28 +0900 |
| commit | 62abf32195dd1d354e2b546b14fddac5bd2cd778 (patch) | |
| tree | da6208c8a770995786f9cfac581dc24d7d666c9e /src/common | |
| parent | Destroy background process when game ended (diff) | |
| download | sharkey-62abf32195dd1d354e2b546b14fddac5bd2cd778.tar.gz sharkey-62abf32195dd1d354e2b546b14fddac5bd2cd778.tar.bz2 sharkey-62abf32195dd1d354e2b546b14fddac5bd2cd778.zip | |
:v:
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/othello/ai/back.ts | 25 | ||||
| -rw-r--r-- | src/common/othello/ai/front.ts | 16 |
2 files changed, 22 insertions, 19 deletions
diff --git a/src/common/othello/ai/back.ts b/src/common/othello/ai/back.ts index c3a74a8348..047ecaf4e9 100644 --- a/src/common/othello/ai/back.ts +++ b/src/common/othello/ai/back.ts @@ -45,17 +45,19 @@ process.on('message', async msg => { //#region TLに投稿する const game = msg.body; - const url = `https://${conf.host}/othello/${game.id}`; + const url = `${conf.url}/othello/${game.id}`; const user = game.user1_id == id ? game.user2 : game.user1; const isSettai = form[0].value === 0; const text = isSettai - ? `?[${user.name}](https://${conf.host}/${user.username})さんの接待を始めました!` - : `対局を?[${user.name}](https://${conf.host}/${user.username})さんと始めました! (強さ${form[0].value})`; - const res = await request.post(`https://api.${conf.host}/posts/create`, { + ? `?[${user.name}](${conf.url}/${user.username})さんの接待を始めました!` + : `対局を?[${user.name}](${conf.url}/${user.username})さんと始めました! (強さ${form[0].value})`; + + const res = await request.post(`${conf.api_url}/posts/create`, { json: { i, text: `${text}\n→[観戦する](${url})` } }); + post = res.created_post; //#endregion } @@ -72,16 +74,17 @@ process.on('message', async msg => { const isSettai = form[0].value === 0; const text = isSettai ? msg.body.winner_id === null - ? `?[${user.name}](https://${conf.host}/${user.username})さんに接待で引き分けました...` + ? `?[${user.name}](${conf.url}/${user.username})さんに接待で引き分けました...` : msg.body.winner_id == id - ? `?[${user.name}](https://${conf.host}/${user.username})さんに接待で勝ってしまいました...` - : `?[${user.name}](https://${conf.host}/${user.username})さんに接待で負けてあげました♪` + ? `?[${user.name}](${conf.url}/${user.username})さんに接待で勝ってしまいました...` + : `?[${user.name}](${conf.url}/${user.username})さんに接待で負けてあげました♪` : msg.body.winner_id === null - ? `?[${user.name}](https://${conf.host}/${user.username})さんと引き分けました~ (強さ${form[0].value})` + ? `?[${user.name}](${conf.url}/${user.username})さんと引き分けました~ (強さ${form[0].value})` : msg.body.winner_id == id - ? `?[${user.name}](https://${conf.host}/${user.username})さんに勝ちました♪ (強さ${form[0].value})` - : `?[${user.name}](https://${conf.host}/${user.username})さんに負けました... (強さ${form[0].value})`; - request.post(`https://api.${conf.host}/posts/create`, { + ? `?[${user.name}](${conf.url}/${user.username})さんに勝ちました♪ (強さ${form[0].value})` + : `?[${user.name}](${conf.url}/${user.username})さんに負けました... (強さ${form[0].value})`; + + request.post(`${conf.api_url}/posts/create`, { json: { i, reply_id: post.id, text: text diff --git a/src/common/othello/ai/front.ts b/src/common/othello/ai/front.ts index 4d5f6e53eb..d892afbeda 100644 --- a/src/common/othello/ai/front.ts +++ b/src/common/othello/ai/front.ts @@ -29,7 +29,7 @@ const id = conf.othello_ai.id; /** * ホームストリーム */ -const homeStream = new ReconnectingWebSocket(`wss://api.${conf.host}/?i=${i}`, undefined, { +const homeStream = new ReconnectingWebSocket(`${conf.ws_url}/?i=${i}`, undefined, { constructor: WebSocket }); @@ -51,7 +51,7 @@ homeStream.on('message', message => { if (post.user_id == id) return; // リアクションする - request.post('https://api.misskey.xyz/posts/reactions/create', { + request.post(`${conf.api_url}/posts/reactions/create`, { json: { i, post_id: post.id, reaction: 'love' @@ -60,7 +60,7 @@ homeStream.on('message', message => { if (post.text) { if (post.text.indexOf('オセロ') > -1) { - request.post('https://api.misskey.xyz/posts/create', { + request.post(`${conf.api_url}/posts/create`, { json: { i, reply_id: post.id, text: '良いですよ~' @@ -77,7 +77,7 @@ homeStream.on('message', message => { const message = msg.body; if (message.text) { if (message.text.indexOf('オセロ') > -1) { - request.post(`https://api.${conf.host}/messaging/messages/create`, { + request.post(`${conf.api_url}/messaging/messages/create`, { json: { i, user_id: message.user_id, text: '良いですよ~' @@ -92,7 +92,7 @@ homeStream.on('message', message => { // ユーザーを対局に誘う function invite(userId) { - request.post(`https://api.${conf.host}/othello/match`, { + request.post(`${conf.api_url}/othello/match`, { json: { i, user_id: userId } @@ -102,7 +102,7 @@ function invite(userId) { /** * オセロストリーム */ -const othelloStream = new ReconnectingWebSocket(`wss://api.${conf.host}/othello?i=${i}`, undefined, { +const othelloStream = new ReconnectingWebSocket(`${conf.ws_url}/othello?i=${i}`, undefined, { constructor: WebSocket }); @@ -134,7 +134,7 @@ othelloStream.on('message', message => { */ function gameStart(game) { // ゲームストリームに接続 - const gw = new ReconnectingWebSocket(`wss://api.${conf.host}/othello-game?i=${i}&game=${game.id}`, undefined, { + const gw = new ReconnectingWebSocket(`${conf.ws_url}/othello-game?i=${i}&game=${game.id}`, undefined, { constructor: WebSocket }); @@ -222,7 +222,7 @@ async function onInviteMe(inviter) { console.log(`Someone invited me: @${inviter.username}`); // 承認 - const game = await request.post(`https://api.${conf.host}/othello/match`, { + const game = await request.post(`${conf.api_url}/othello/match`, { json: { i, user_id: inviter.id |