make config.shellgeiUrl optional

This commit is contained in:
SyoBoN 2023-01-30 18:47:13 +09:00
parent 598eb74ec1
commit 3767abc87b
No known key found for this signature in database
GPG Key ID: 58A36D43051CBC5B
3 changed files with 11 additions and 8 deletions

View File

@ -34,11 +34,11 @@ Misskey用の[Aiベース](https://github.com/syuilo/ai)のBotです。
"master": "管理者のユーザー名(オプション)", "master": "管理者のユーザー名(オプション)",
"notingEnabled": "ランダムにートを投稿する機能。true(on) or false(off)", "notingEnabled": "ランダムにートを投稿する機能。true(on) or false(off)",
"keywordEnabled": "キーワードを覚える機能 (MeCab が必要) true or false", "keywordEnabled": "キーワードを覚える機能 (MeCab が必要) true or false",
"serverMonitoring": "サーバー監視の機能(重かったりすると教えてくれるよ。)true or false", "serverMonitoring": "サーバー監視の機能(重かったりすると教えてくれるよ。)true or false",
"mecab": "MeCab のインストールパス (ソースからインストールした場合、大体は /usr/local/bin/mecab) ", "mecab": "MeCab のインストールパス (ソースからインストールした場合、大体は /usr/local/bin/mecab) ",
"mecabDic": "MeCab の辞書ファイルパス", "mecabDic": "MeCab の辞書ファイルパス(オプション)",
"memoryDir": "memory.jsonの保存先(オプション、デフォルトは'.'(レポジトリのルートです))", "memoryDir": "memory.jsonの保存先(オプション、デフォルトは'.'(レポジトリのルートです))",
"shellgeiUrl": "シェル芸BotのAPIのURLですデフォルトではhttps://websh.jiro4989.com/api/shellgei" "shellgeiUrl": "シェル芸BotのAPIのURLです(オプション、デフォルトはhttps://websh.jiro4989.com/api/shellgei)"
} }
``` ```
`npm install` して `npm run build` して `npm start` すれば起動できます。 `npm install` して `npm run build` して `npm start` すれば起動できます。
@ -57,7 +57,7 @@ Misskey用の[Aiベース](https://github.com/syuilo/ai)のBotです。
"mecab": "/usr/bin/mecab", "mecab": "/usr/bin/mecab",
"mecabDic": "/usr/lib/x86_64-linux-gnu/mecab/dic/mecab-ipadic-neologd/", "mecabDic": "/usr/lib/x86_64-linux-gnu/mecab/dic/mecab-ipadic-neologd/",
"memoryDir": "data", "memoryDir": "data",
"shellgeiUrl": "シェル芸BotのAPIのURLですデフォルトではhttps://websh.jiro4989.com/api/shellgei" "shellgeiUrl": "シェル芸BotのAPIのURLです(オプション、デフォルトではhttps://websh.jiro4989.com/api/shellgei)"
} }
``` ```
`npm install` して `npm run docker` すれば起動できます。<br> `npm install` して `npm run docker` すれば起動できます。<br>

View File

@ -10,7 +10,7 @@ type Config = {
mecab?: string; mecab?: string;
mecabDic?: string; mecabDic?: string;
memoryDir?: string; memoryDir?: string;
shellgeiUrl: string; shellgeiUrl?: string;
}; };
const config = require('../config.json'); const config = require('../config.json');

View File

@ -32,11 +32,14 @@ export default class extends Module {
this.log(shellText); this.log(shellText);
const shellgeiBody = { code: shellText, images: [] }; const shellgeiBody = { code: shellText, images: [] };
const shellgeiOptions = { method: 'POST', body: JSON.stringify(shellgeiBody), headers: { 'Content-Type': 'application/json' } }; const shellgeiOptions = { method: 'POST', body: JSON.stringify(shellgeiBody), headers: { 'Content-Type': 'application/json' } };
const shellgeiURL = config.shellgeiUrl; let shellgeiUrl = 'https://websh.jiro4989.com/api/shellgei';
if (config.shellgeiUrl) {
shellgeiUrl = config.shellgeiUrl;
}
await (async () => { await (async () => {
try { try {
const shellgeiResult = await fetch(shellgeiURL, shellgeiOptions); const shellgeiResult = await fetch(shellgeiUrl, shellgeiOptions);
const shellgeiResultJson: any = await shellgeiResult.json(); const shellgeiResultJson: any = await shellgeiResult.json();
const shellgeiResultStdOut = shellgeiResultJson.stdout; const shellgeiResultStdOut = shellgeiResultJson.stdout;
const shellgeiResultStdErr = shellgeiResultJson.stderr; const shellgeiResultStdErr = shellgeiResultJson.stderr;