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