maxenxe / HQ-Trivia-Bot-NOT-MAINTAINED-

Small NodeJS bot for HQ Trivia
24 stars 13 forks source link

Coordinates Help #6

Closed Helpme0822 closed 6 years ago

Helpme0822 commented 6 years ago

I entered the right coordinates like it was told in the description but i only get 1/4 of the question on the screenshot why?

maxenxe commented 6 years ago

Peut être en refactorisant le code, il y a des sites pour faire ça il me semble

Helpme0822 commented 6 years ago

peux-tu le faire stp? ou sinon explique moi comment il faut le faire stp

maxenxe commented 6 years ago

var screenshot=require("desktop-screenshot"),gm=require("gm"),nodecr=require("nodecr"),google=require("google"),request=require("request"),cheerio=require("cheerio"),question,answers,pointsAnswer0,pointsAnswer1,pointsAnswer2;screenshot("screenshot.jpg",{width:1600},function(e){e?console.log("Screenshot failed",e):console.log("Screenshot done"),gm("screenshot.jpg").crop("351","233","606","334").write("answers.jpg",function(e){e?console.log(e):(console.log("Answers resized"),nodecr.process("answers.jpg",function(e,o){if(e)console.error(e);else{answers=o.replace(/^\s*$[\n\r]{1,}/gm,""),answers=answers.split(/\n/g),answers=answers.filter(function(e){return 0===e||e});for(var s=0;s<answers.length;s++)console.log(answers[s]);gm("screenshot.jpg").crop("389","200","587","198").write("question.jpg",function(e){e?console.log(e):(console.log("Question resized"),nodecr.process("question.jpg",function(e,o){if(e)console.error(e);else{question=o.replace(/\n/g," "),console.log('The question is "'+question+'"'),google.resultsPerPage=25;var s=0;google(question,function(e,o){e&&console.error(e);for(var n=0;n<o.links.length;++n){var r=o.links[n];null!=r.link&&-1!=r.link.indexOf("wikipedia")&&(console.log("Wikipedia link found: "+r.link),request(r.link,function(e,o,s){if(e)console.log("Error: "+e);else{var n=cheerio.load(s);-1!=n("body").text().toLowerCase().indexOf(answers[0].toLowerCase())&&(console.log(answers[0]+" found in Wikipedia page!"),pointsAnswer0++),-1!=n("body").text().toLowerCase().indexOf(answers[1].toLowerCase())&&(console.log(answers[1]+" found in Wikipedia page!"),pointsAnswer1++),-1!=n("body").text().toLowerCase().indexOf(answers[2].toLowerCase())&&(console.log(answers[2]+" found in Wikipedia page!"),pointsAnswer2++)}})),-1!=r.title.indexOf(answers[0])&&(pointsAnswer0++,console.log(answers[0]+" found!")),-1!=r.title.indexOf(answers[1])&&(pointsAnswer1++,console.log(answers[1]+" found!")),-1!=r.title.indexOf(answers[2])&&(pointsAnswer2++,console.log(answers[2]+" found!")),-1!=r.description.indexOf(answers[0])&&(pointsAnswer0++,console.log(answers[0]+" found!")),-1!=r.description.indexOf(answers[1])&&(pointsAnswer1++,console.log(answers[1]+" found!")),-1!=r.description.indexOf(answers[2])&&(pointsAnswer2++,console.log(answers[2]+" found!"))}4>s&&(s+=1,o.next&&o.next())})}}))})}}))})});

maxenxe commented 6 years ago

remplace le code de bot.js par ça

maxenxe commented 6 years ago

en changeant les coordonnées

Helpme0822 commented 6 years ago

chaque ligne dans une differente ligne ou tout dans une ligne?

maxenxe commented 6 years ago

Tu peux tout mettre dans une même ligne mais si ça le fait pas de base c'est pas grave c'est pas une grosse perte de performances

Helpme0822 commented 6 years ago

pour moi il y a pas d'ameliorations dans la duree

maxenxe commented 6 years ago

Je peux rien faire alors désolé

Helpme0822 commented 6 years ago

oke merci quand meme