ai/src/message-like.ts

48 lines
874 B
TypeScript
Raw Normal View History

2018-08-11 06:26:25 +00:00
import from './ai';
2018-08-11 01:42:06 +00:00
export default class MessageLike {
private ai: ;
private messageOrNote: any;
public isMessage: boolean;
public get id() {
return this.messageOrNote.id;
}
public get user() {
return this.messageOrNote.user;
}
2018-08-11 01:42:06 +00:00
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;
}
2018-08-11 09:43:50 +00:00
public reply = (text: string, cw?: string) => {
2018-08-11 03:34:24 +00:00
console.log(`sending reply of ${this.id} ...`);
2018-08-11 01:42:06 +00:00
setTimeout(() => {
if (this.isMessage) {
this.ai.sendMessage(this.messageOrNote.userId, {
text: text
});
} else {
this.ai.post({
replyId: this.messageOrNote.id,
2018-08-11 09:43:50 +00:00
text: text,
cw: cw
2018-08-11 01:42:06 +00:00
});
}
}, 2000);
}
}