mirror of
https://github.com/syuilo/ai.git
synced 2024-11-22 05:08:00 +00:00
Fix bug
This commit is contained in:
parent
9ef87837fc
commit
f27dd1c673
22
src/back.ts
22
src/back.ts
|
@ -142,7 +142,7 @@ class Session {
|
|||
/**
|
||||
* 対局が終わったとき
|
||||
*/
|
||||
private onEnded = (msg: any) => {
|
||||
private onEnded = async (msg: any) => {
|
||||
// ストリームから切断
|
||||
process.send({
|
||||
type: 'close'
|
||||
|
@ -178,7 +178,7 @@ class Session {
|
|||
}
|
||||
}
|
||||
|
||||
this.post(text, this.startedNote ? this.startedNote.id : null);
|
||||
await this.post(text, this.startedNote);
|
||||
|
||||
process.exit();
|
||||
}
|
||||
|
@ -363,15 +363,25 @@ class Session {
|
|||
*/
|
||||
private post = async (text: string, renote?: any) => {
|
||||
if (this.allowPost) {
|
||||
const res = await request.post(`${config.host}/api/notes/create`, {
|
||||
json: {
|
||||
const body = {
|
||||
i: config.i,
|
||||
text: text,
|
||||
renoteId: renote ? renote.id : undefined
|
||||
text: text
|
||||
} as any;
|
||||
|
||||
if (renote) {
|
||||
body.renoteId = renote.id;
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await request.post(`${config.host}/api/notes/create`, {
|
||||
json: body
|
||||
});
|
||||
|
||||
return res.createdNote;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue