* fix(process): 何か失敗してもクラッシュしないように
* fix(upload): ファイルのアップロードができない問題を修正
* fix(docker): ビルドできるように
This commit is contained in:
まっちゃとーにゅ 2024-01-25 05:22:43 +09:00 committed by GitHub
parent 54f10b3321
commit 465b4312dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 28 additions and 22 deletions

View file

@ -1,6 +1,6 @@
FROM node:lts-bullseye
FROM node:lts
RUN apt-get update && apt-get install -y tini
RUN apt-get update && apt-get install tini --no-install-recommends -y && apt-get clean && rm -rf /var/lib/apt-get/lists/*
ARG enable_mecab=1
@ -19,7 +19,7 @@ RUN if [ $enable_mecab -ne 0 ]; then apt-get update \
COPY . /ai
WORKDIR /ai
RUN npm install && npm run build
RUN npm install && npm run build || test -f ./built/index.js
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD npm start

View file

@ -20,6 +20,7 @@
"@types/ws": "8.5.10",
"canvas": "2.11.2",
"chalk": "5.3.0",
"formdata-node": "6.0.3",
"got": "14.0.0",
"lokijs": "1.5.12",
"memory-streams": "0.1.3",
@ -28,7 +29,6 @@
"promise-retry": "2.0.1",
"random-seed": "0.3.0",
"reconnecting-websocket": "4.4.0",
"request": "2.88.2",
"seedrandom": "3.0.5",
"ts-patch": "3.1.2",
"twemoji-parser": "14.0.0",

View file

@ -4,6 +4,7 @@ import * as fs from 'fs';
import { bindThis } from '@/decorators.js';
import loki from 'lokijs';
import got from 'got';
import { FormData, File } from 'formdata-node';
import chalk from 'chalk';
import { v4 as uuid } from 'uuid';
@ -11,7 +12,7 @@ import config from '@/config.js';
import Module from '@/module.js';
import Message from '@/message.js';
import Friend, { FriendDoc } from '@/friend.js';
import { User } from '@/misskey/user.js';
import type { User } from '@/misskey/user.js';
import Stream from '@/stream.js';
import log from '@/utils/log.js';
import { sleep } from './utils/sleep.js';
@ -343,17 +344,14 @@ export default class 藍 {
*
*/
@bindThis
public async upload(file: Buffer | fs.ReadStream, meta: any) {
public async upload(file: Buffer | fs.ReadStream, meta: { filename: string, contentType: string }) {
const form = new FormData();
form.set('i', config.i);
form.set('file', new File([file], meta.filename, { type: meta.contentType }));
const res = await got.post({
url: `${config.apiUrl}/drive/files/create`,
formData: {
i: config.i,
file: {
value: file,
options: meta
}
},
json: true
body: form
}).json();
return res;
}

View file

@ -2,7 +2,7 @@ import { bindThis } from '@/decorators.js';
import from '@/ai.js';
import IModule from '@/module.js';
import getDate from '@/utils/get-date.js';
import { User } from '@/misskey/user.js';
import type { User } from '@/misskey/user.js';
import { genItem } from '@/vocabulary.js';
export type FriendDoc = {

View file

@ -1,5 +1,6 @@
// AiOS bootstrapper
import process from 'node:process';
import chalk from 'chalk';
import got from 'got';
import promiseRetry from 'promise-retry';
@ -45,6 +46,13 @@ function log(msg: string): void {
log(chalk.bold(`Ai v${pkg._v}`));
process.on('uncaughtException', err => {
try {
console.error(`Uncaught exception: ${err.message}`);
console.dir(err, { colors: true, depth: 2 });
} catch { }
});
promiseRetry(retry => {
log(`Account fetching... ${chalk.gray(config.host)}`);

View file

@ -3,7 +3,7 @@ import chalk from 'chalk';
import from '@/ai.js';
import Friend from '@/friend.js';
import { User } from '@/misskey/user.js';
import type { User } from '@/misskey/user.js';
import includes from '@/utils/includes.js';
import or from '@/utils/or.js';
import config from '@/config.js';

View file

@ -1,11 +1,11 @@
import { bindThis } from '@/decorators.js';
import { parse } from 'twemoji-parser';
import { Note } from '@/misskey/note.js';
import type { Note } from '@/misskey/note.js';
import Module from '@/module.js';
import Stream from '@/stream.js';
import includes from '@/utils/includes.js';
import { sleep } from '../../utils/sleep.js';
import { sleep } from '@/utils/sleep.js';
export default class extends Module {
public readonly name = 'emoji-react';

View file

@ -3,7 +3,7 @@ import loki from 'lokijs';
import Module from '@/module.js';
import Message from '@/message.js';
import serifs from '@/serifs.js';
import { User } from '@/misskey/user.js';
import type { User } from '@/misskey/user.js';
import { acct } from '@/utils/acct.js';
type Game = {

View file

@ -4,7 +4,7 @@ import Module from '@/module.js';
import serifs from '@/serifs.js';
import { genItem } from '@/vocabulary.js';
import config from '@/config.js';
import { Note } from '@/misskey/note.js';
import type { Note } from '@/misskey/note.js';
export default class extends Module {
public readonly name = 'poll';

View file

@ -10,7 +10,7 @@ import got from 'got';
import * as Reversi from './engine.js';
import config from '@/config.js';
import serifs from '@/serifs.js';
import { User } from '@/misskey/user.js';
import type { User } from '@/misskey/user.js';
function getUserName(user) {
return user.name || user.username;