mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-26 20:07:33 -07:00
✌️
This commit is contained in:
parent
3d81dab6d8
commit
7cebf76283
2 changed files with 11 additions and 14 deletions
|
@ -34,7 +34,7 @@ export default class BotCore extends EventEmitter {
|
||||||
|
|
||||||
public static import(data) {
|
public static import(data) {
|
||||||
const core = new BotCore();
|
const core = new BotCore();
|
||||||
core.user = data.user;
|
core.user = data.user ? data.user : null;
|
||||||
core.setContect(data.context ? Context.import(core, data.context) : null);
|
core.setContect(data.context ? Context.import(core, data.context) : null);
|
||||||
return core;
|
return core;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ abstract class Context extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
class SigninContext extends Context {
|
class SigninContext extends Context {
|
||||||
private temporaryUser: IUser;
|
private temporaryUser: IUser = null;
|
||||||
|
|
||||||
public async greet(): Promise<string> {
|
public async greet(): Promise<string> {
|
||||||
return 'まずユーザー名を教えてください:';
|
return 'まずユーザー名を教えてください:';
|
||||||
|
@ -124,6 +124,7 @@ class SigninContext extends Context {
|
||||||
|
|
||||||
public export() {
|
public export() {
|
||||||
return {
|
return {
|
||||||
|
type: 'signin',
|
||||||
temporaryUser: this.temporaryUser
|
temporaryUser: this.temporaryUser
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,7 @@ module.exports = async (app: express.Application) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (user) {
|
|
||||||
session = new BotCore(user);
|
session = new BotCore(user);
|
||||||
} else {
|
|
||||||
session = new BotCore();
|
|
||||||
session.on('set-user', user => {
|
session.on('set-user', user => {
|
||||||
User.update(user._id, {
|
User.update(user._id, {
|
||||||
$set: {
|
$set: {
|
||||||
|
@ -45,7 +42,6 @@ module.exports = async (app: express.Application) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
redis.set(sessionId, JSON.stringify(session.export()));
|
redis.set(sessionId, JSON.stringify(session.export()));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue