ai/src/message-like.ts
syuilo 6160d0f825 ✌️
2018-08-11 15:26:25 +09:00

43 lines
789 B
TypeScript

import from './ai';
export default class MessageLike {
private ai: ;
private messageOrNote: any;
public isMessage: boolean;
public get id() {
return this.messageOrNote.id;
}
public get userId() {
return this.messageOrNote.userId;
}
public get text() {
return this.messageOrNote.text;
}
constructor(ai: , messageOrNote: any, isMessage: boolean) {
this.ai = ai;
this.messageOrNote = messageOrNote;
this.isMessage = isMessage;
}
public reply = (text: string) => {
console.log(`sending reply of ${this.id} ...`);
setTimeout(() => {
if (this.isMessage) {
this.ai.sendMessage(this.messageOrNote.userId, {
text: text
});
} else {
this.ai.post({
replyId: this.messageOrNote.id,
text: text
});
}
}, 2000);
}
}