bye request
This commit is contained in:
parent
7b5ae1ecbf
commit
4bf76135be
@ -14,8 +14,6 @@
|
||||
"jsdom": "^11.12.0",
|
||||
"long-timeout": "^0.1.1",
|
||||
"pg-promise": "^7.3.2",
|
||||
"request": "^2.87.0",
|
||||
"request-promise-native": "^1.0.5",
|
||||
"stringify-object": "^3.2.1",
|
||||
"winston": "^2.4.0",
|
||||
"ytdl-core": "^0.18.2"
|
||||
|
@ -3,7 +3,7 @@ import { getLevel } from "../inc/admin";
|
||||
import { spurdo } from "../inc/spurdo";
|
||||
import { schmuser } from "../inc/schmuser";
|
||||
|
||||
import rp from "request-promise";
|
||||
import fetch from "../inc/fetch";
|
||||
import EventEmitter from "events";
|
||||
|
||||
export class tg extends EventEmitter {
|
||||
@ -31,7 +31,8 @@ export class tg extends EventEmitter {
|
||||
}
|
||||
connect() {
|
||||
return new Promise((resolve, reject) => {
|
||||
rp(`${this.api}/getMe`, { json: true })
|
||||
fetch(`${this.api}/getMe`)
|
||||
.then(res => res.json())
|
||||
.then(res => {
|
||||
if(res.ok) {
|
||||
this.me = res.result;
|
||||
@ -56,7 +57,8 @@ export class tg extends EventEmitter {
|
||||
});
|
||||
}
|
||||
poll() {
|
||||
rp(`${this.api}/getUpdates?offset=${this.lastUpdate}&allowed_updates=message`, { json:true })
|
||||
fetch(`${this.api}/getUpdates?offset=${this.lastUpdate}&allowed_updates=message`)
|
||||
.then(res => res.json())
|
||||
.then(res => {
|
||||
if(res.ok && res.result.length > 0) {
|
||||
res = res.result[res.result.length-1];
|
||||
@ -85,18 +87,16 @@ export class tg extends EventEmitter {
|
||||
if(msg.length === 0 || msg.length > 2048)
|
||||
return false;
|
||||
const opts = {
|
||||
method: 'POST',
|
||||
uri: `${this.api}/sendMessage`,
|
||||
method: "POST",
|
||||
body: {
|
||||
chat_id: chatid,
|
||||
text: msg,
|
||||
parse_mode: "HTML"
|
||||
},
|
||||
json: true
|
||||
}
|
||||
};
|
||||
if(reply)
|
||||
opts.body.reply_to_message_id = reply;
|
||||
rp(opts)
|
||||
fetch(`${this.api}/sendMessage`, opts)
|
||||
.then(res => {})
|
||||
.catch(err => {
|
||||
logger.error(`(${this.network}) ${err.message}`);
|
||||
|
Loading…
Reference in New Issue
Block a user