- slack: bugfix
- update flumm-fetch-cookies - version bump to 1.0.5
This commit is contained in:
parent
f18d318334
commit
a221ef715a
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "cuffeo",
|
"name": "cuffeo",
|
||||||
"version": "1.0.4",
|
"version": "1.0.5",
|
||||||
"description": "A multi-protocol chatbot library with nearly zero dependencies.",
|
"description": "A multi-protocol chatbot library with nearly zero dependencies.",
|
||||||
"main": "src/index.mjs",
|
"main": "src/index.mjs",
|
||||||
"scripts": {},
|
"scripts": {},
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
"author": "Flummi & jkhsjdhjs",
|
"author": "Flummi & jkhsjdhjs",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"flumm-fetch-cookies": "^1.1.1"
|
"flumm-fetch-cookies": "^1.3.4"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/kein-Bot/cuffeo/issues"
|
"url": "https://github.com/kein-Bot/cuffeo/issues"
|
||||||
|
|
|
@ -31,15 +31,15 @@ export default class slack extends EventEmitter {
|
||||||
async connect() {
|
async connect() {
|
||||||
const res = await (await fetch(`${this.api}/rtm.start?token=${this.token}`)).json();
|
const res = await (await fetch(`${this.api}/rtm.start?token=${this.token}`)).json();
|
||||||
|
|
||||||
|
if (!res.ok)
|
||||||
|
return this.emit("data", [ "error", res.description ]); // more infos
|
||||||
|
|
||||||
res.channels.forEach(channel => this.server.channel.set(channel.id, channel.name));
|
res.channels.forEach(channel => this.server.channel.set(channel.id, channel.name));
|
||||||
res.users.forEach(user => this.server.user.set(user.id, {
|
res.users.forEach(user => this.server.user.set(user.id, {
|
||||||
account: user.name,
|
account: user.name,
|
||||||
nickname: user.real_name
|
nickname: user.real_name
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (!res.ok)
|
|
||||||
return this.emit("data", [ "error", res.description ]); // more infos
|
|
||||||
|
|
||||||
this.server.wss.url = url.parse(res.url);
|
this.server.wss.url = url.parse(res.url);
|
||||||
|
|
||||||
https.get({
|
https.get({
|
||||||
|
@ -90,21 +90,21 @@ export default class slack extends EventEmitter {
|
||||||
this.emit("data", [ "error", err ]);
|
this.emit("data", [ "error", err ]);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on("end", () => {
|
.on("end", async () => {
|
||||||
this.emit("data", [ "debug", "stream ended" ]);
|
this.emit("data", [ "debug", "stream ended" ]);
|
||||||
this.reconnect();
|
await this.reconnect();
|
||||||
})
|
})
|
||||||
.on("error", err => {
|
.on("error", async err => {
|
||||||
this.emit("data", [ "error", err ]);
|
this.emit("data", [ "error", err ]);
|
||||||
this.reconnect();
|
await this.reconnect();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
reconnect() {
|
async reconnect() {
|
||||||
this.server.wss.url = null;
|
this.server.wss.url = null;
|
||||||
this.server.wss.socket = null;
|
this.server.wss.socket = null;
|
||||||
this.connect();
|
await this.connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getChannel(channelId) {
|
async getChannel(channelId) {
|
||||||
|
@ -167,6 +167,9 @@ export default class slack extends EventEmitter {
|
||||||
if(frame_length > 6)
|
if(frame_length > 6)
|
||||||
frame.writeUInt16BE(payload.length, 2);
|
frame.writeUInt16BE(payload.length, 2);
|
||||||
|
|
||||||
|
if (!this.server.wss.socket)
|
||||||
|
await this.reconnect();
|
||||||
|
|
||||||
this.server.wss.socket.cork();
|
this.server.wss.socket.cork();
|
||||||
this.server.wss.socket.write(frame);
|
this.server.wss.socket.write(frame);
|
||||||
this.server.wss.socket.write(Buffer.from(msg));
|
this.server.wss.socket.write(Buffer.from(msg));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user