fig telegram client

also add error handling
This commit is contained in:
jkhsjdhjs 2019-08-19 03:33:03 +02:00
parent ea212a5ad0
commit d8655e4d87
Signed by: jkhsjdhjs
GPG Key ID: BAC6ADBAB7D576CC

View File

@ -70,6 +70,7 @@ export class tg extends EventEmitter {
} }
}) })
.catch(err => { .catch(err => {
this.emit("error", err);
}); });
} }
send(chatid, msg, reply = null) { send(chatid, msg, reply = null) {
@ -88,6 +89,7 @@ export class tg extends EventEmitter {
fetch(`${this.api}/sendMessage`, opts) fetch(`${this.api}/sendMessage`, opts)
.then(res => {}) .then(res => {})
.catch(err => { .catch(err => {
this.emit("error", err);
}); });
} }
sendmsg(mode, recipient, msg) { sendmsg(mode, recipient, msg) {
@ -103,13 +105,7 @@ export class tg extends EventEmitter {
prefix: `${tmp.from.username}!${tmp.from.id}`, prefix: `${tmp.from.username}!${tmp.from.id}`,
nick: tmp.from.first_name, nick: tmp.from.first_name,
username: tmp.from.username, username: tmp.from.username,
account: tmp.from.id.toString(), account: tmp.from.id.toString()
level: getLevel("Telegram", {
prefix: `${tmp.from.username}!${tmp.from.id}`,
nick: tmp.from.first_name,
username: tmp.from.username,
account: tmp.from.id.toString()
})
}, },
self: this.server, self: this.server,
message: tmp.text, message: tmp.text,