-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTelegramMessage.js
37 lines (37 loc) · 1.03 KB
/
TelegramMessage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var TelegramChannel = require("./TelegramChannel");
var TelegramUser = require("./TelegramUser");
var TelegramMessageBuilder = require("./TelegramMessageBuilder");
module.exports = class {
constructor(data, bot) {
this.data = data;
this.bot = bot;
this.channel = new TelegramChannel(this.data.chat, bot);
this.user = this.bot.users.get(this.data.from.id) || new TelegramUser(this.data.from, bot);
this.user.data = this.data.from;
this.bot.users.set(this.user.id, this.user);
}
get id() {
return this.data.message.message_id;
}
get content() {
return this.data.message.text;
}
reply(data) {
if (typeof data !== "object") {
data = {
"content": data
};
}
if (data instanceof TelegramMessageBuilder) {
data.data.replyParameters = {
"message": this
};
return this.channel.send(data);
}
return this.channel.send(Object.assign({
"replyParameters": {
"message": this
}
}, data));
}
};