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