[HQ] Auto WS logger
This commit is contained in:
@@ -16,7 +16,7 @@ Wilder Emu Bot + Trivia Emulator
|
|||||||
- [ ] Confetti Support
|
- [ ] Confetti Support
|
||||||
- [ ] Working UI
|
- [ ] Working UI
|
||||||
- [ ] Add Auto Update (CircleCI)
|
- [ ] Add Auto Update (CircleCI)
|
||||||
- [ ] Auto WS Logger
|
- [X] Auto WS Logger
|
||||||
- [ ] WS Reconnecting
|
- [ ] WS Reconnecting
|
||||||
- [X] Checkpoint Support (HQ)
|
- [X] Checkpoint Support (HQ)
|
||||||
- [X] Auto Checkpoint Claiming
|
- [X] Auto Checkpoint Claiming
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
/* eslint-disable no-useless-escape */
|
/* eslint-disable no-useless-escape */
|
||||||
import { MessageEmbed, MessageAttachment } from 'discord.js';
|
import { MessageEmbed, MessageAttachment } from 'discord.js';
|
||||||
|
import { promisify } from 'util';
|
||||||
|
import request from 'request';
|
||||||
import Client from '../classes/Client';
|
import Client from '../classes/Client';
|
||||||
import {
|
import { discord, emuOnly, hq } from '../../config';
|
||||||
discord,
|
|
||||||
emuOnly,
|
|
||||||
hq,
|
|
||||||
} from '../../config';
|
|
||||||
import { getTokens } from '../utils/tokens';
|
import { getTokens } from '../utils/tokens';
|
||||||
import search from '../utils/google';
|
import search from '../utils/google';
|
||||||
import genResults from '../utils/img';
|
import genResults from '../utils/img';
|
||||||
|
|
||||||
|
request.promise = promisify(request);
|
||||||
|
|
||||||
export default async (client, prize) => {
|
export default async (client, prize) => {
|
||||||
const tokens = getTokens(discord.defaultTokenSet);
|
const tokens = getTokens(discord.defaultTokenSet);
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
@@ -31,8 +31,10 @@ export default async (client, prize) => {
|
|||||||
let questionNumber;
|
let questionNumber;
|
||||||
let winners;
|
let winners;
|
||||||
let winnings;
|
let winnings;
|
||||||
|
const wsLog = [];
|
||||||
master.ws.on('message', async (data) => {
|
master.ws.on('message', async (data) => {
|
||||||
const json = JSON.parse(data);
|
const json = JSON.parse(data);
|
||||||
|
wsLog.push(data);
|
||||||
if (json.type === 'question') {
|
if (json.type === 'question') {
|
||||||
client.weights.hq = [0, 0, 0];
|
client.weights.hq = [0, 0, 0];
|
||||||
client.userAnswers.hq = [];
|
client.userAnswers.hq = [];
|
||||||
@@ -172,12 +174,21 @@ export default async (client, prize) => {
|
|||||||
});
|
});
|
||||||
master.ws.on('close', async () => {
|
master.ws.on('close', async () => {
|
||||||
if (!emuOnly) channels.forEach(c => c.send('**GAME OVER!**'));
|
if (!emuOnly) channels.forEach(c => c.send('**GAME OVER!**'));
|
||||||
const image = genResults('HQ Trivia', winners, winnings, `${correctCount}/${questionCount}`);
|
const image = genResults('HQ Trivia', winners || 0, winnings || 0, `${correctCount}/${questionCount || 0}`);
|
||||||
const attachment = new MessageAttachment(image);
|
const attachment = new MessageAttachment(image);
|
||||||
if (!emuOnly) channels.forEach(c => c.send(attachment));
|
if (!emuOnly) channels.forEach(c => c.send(attachment));
|
||||||
if (discord.logs) client.channels.get(discord.logChannel).send(attachment);
|
if (discord.logs) client.channels.get(discord.logChannel).send(attachment);
|
||||||
client.activeGames.splice(client.activeGames.indexOf('hq-trivia'), 1);
|
client.activeGames.splice(client.activeGames.indexOf('hq-trivia'), 1);
|
||||||
client.hqClients = [];
|
client.hqClients = [];
|
||||||
|
const { body } = await request.promise('https://pastebin.com/api/api_post.php?', {
|
||||||
|
method: 'POST',
|
||||||
|
form: {
|
||||||
|
api_option: 'paste',
|
||||||
|
api_dev_key: 'b7ac578d7d735606fde6339131885f38',
|
||||||
|
api_paste_code: wsLog.join('\n'),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!emuOnly) channels.forEach(c => c.send(`WebSocket Log: ${body}`));
|
||||||
});
|
});
|
||||||
tokens.forEach(async (t, i) => {
|
tokens.forEach(async (t, i) => {
|
||||||
const hq = new Client(t, i + 1);
|
const hq = new Client(t, i + 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user