From 91251916ce750c8c361668fd7969e4a9dec91ee3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 7 Oct 2017 07:23:00 +0900 Subject: [PATCH] :v: --- src/api/bot/core.ts | 6 +++--- src/api/models/user.ts | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/api/bot/core.ts b/src/api/bot/core.ts index 57330e67eb..25190b6d65 100644 --- a/src/api/bot/core.ts +++ b/src/api/bot/core.ts @@ -1,7 +1,7 @@ import * as EventEmitter from 'events'; import * as bcrypt from 'bcryptjs'; -import User, { IUser } from '../models/user'; +import User, { IUser, init as initUser } from '../models/user'; import getPostSummary from '../../common/get-post-summary'; @@ -36,7 +36,7 @@ export default class BotCore extends EventEmitter { public static import(data) { const core = new BotCore(); - core.user = data.user ? data.user : null; + core.user = data.user ? initUser(data.user) : null; core.setContext(data.context ? Context.import(core, data.context) : null); return core; } @@ -52,7 +52,7 @@ export default class BotCore extends EventEmitter { case 'help': case 'ヘルプ': - return 'コマンド一覧です:' + + return 'コマンド一覧です:\n' + 'help: これです\n' + 'me: アカウント情報を見ます\n' + 'login, signin: サインインします\n' + diff --git a/src/api/models/user.ts b/src/api/models/user.ts index 4f8086d42b..08ffe4a109 100644 --- a/src/api/models/user.ts +++ b/src/api/models/user.ts @@ -73,3 +73,10 @@ export type IUser = { is_suspended: boolean; keywords: string[]; }; + +export function init(user): IUser { + user._id = new mongo.ObjectID(user._id); + user.avatar_id = new mongo.ObjectID(user.avatar_id); + user.banner_id = new mongo.ObjectID(user.banner_id); + user.pinned_post_id = new mongo.ObjectID(user.pinned_post_id); +}