Browse Source

finally fixes #27 (#32)

* Update train.js

* Update train.js

* Update train.js

* Update train.js

* Update train.js

* testing

* testing

* deleted useless files

* Update train.js

* Update train.js

* Update train.js

* Update train.js

* Update train.js

* Update train.js

* Remove package-lock.json

* Fix yarn.lock conflicts

Co-authored-by: Abheek Dhawan <abheekd@protonmail.com>
pull/33/head
Eric Yang 3 years ago
committed by GitHub
parent
commit
36947490bc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      commands/train.js
  2. 385
      yarn.lock

15
commands/train.js

@ -97,6 +97,11 @@ module.exports = {
const data = res.data.question; const data = res.data.question;
const tossupQuestion = data.tossup_question; const tossupQuestion = data.tossup_question;
const tossupAnswer = data.tossup_answer; const tossupAnswer = data.tossup_answer;
let answers = tossupAnswer.split(' (ACCEPT: ');
if (answers.length > 1) {
answers[1] = answers[1].slice(0, answers[1].length - 1); // If there are multiple elements, it means there was an 'accept' and therefore a trailing ')' which should be removed
answers = [answers[0], ...answers[1].split(new RegExp(' OR ', 'i'))]; // Use the first element plus the last element split by 'OR' case insensitive
}
interaction.followUp({ content: decode(tossupQuestion) + `\n\n||Source: ${data.uri}||` }) interaction.followUp({ content: decode(tossupQuestion) + `\n\n||Source: ${data.uri}||` })
.then(() => { .then(() => {
const messageFilter = m => m.author.id === interaction.user.id || m.author.id === interaction.client.user.id; const messageFilter = m => m.author.id === interaction.user.id || m.author.id === interaction.client.user.id;
@ -111,20 +116,14 @@ module.exports = {
let predicted = null; let predicted = null;
if (data.tossup_format === 'Multiple Choice') { if (data.tossup_format === 'Multiple Choice') {
if ( if (answerMsg.content.charAt(0).toLowerCase() === tossupAnswer.charAt(0).toLowerCase()) {
answerMsg.content.charAt(0).toLowerCase() ===
tossupAnswer.charAt(0).toLowerCase()
) {
predicted = 'correct'; predicted = 'correct';
} }
else { else {
predicted = 'incorrect'; predicted = 'incorrect';
} }
} }
else if ( else if (answerMsg.content.toLowerCase() === tossupAnswer.toLowerCase() || answers.includes(answerMsg.content.toUpperCase())) {
answerMsg.content.toLowerCase() ===
tossupAnswer.toLowerCase()
) {
predicted = 'correct'; predicted = 'correct';
} }
else { else {

385
yarn.lock

File diff suppressed because it is too large
Loading…
Cancel
Save