This commit is contained in:
syuilo 2017-10-07 07:23:00 +09:00
parent fe98dd927d
commit 91251916ce
2 changed files with 10 additions and 3 deletions

View File

@ -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' +

View File

@ -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);
}