Update reaper to use v3 of Riot's API
Diff
README.md | 6 +++---
common.js | 41 +++++++++++++----------------------------
reaper.js | 120 ++++++++++++++++++++++++++++++++++++++++----------------------------------------
3 files changed, 50 insertions(+), 117 deletions(-)
@@ -1,17 +1,17 @@
# reaper
[](http://github.com/jordandoyle/reaper)
[League of Legends](http://leagueoflegends.com) mass summoner name checker. Supply a region and a list and the script will check the list for available summoner names. Common uses are finding quick variations of your name or finding rare (or "OG") names for selling. An API Key is required to do use this script, they are available for free from [Riot Games](https://developer.riotgames.com/), the API key is set in **reaper.js**.
This script includes a built-in rate limiter and a very basic web server for checking the status of the script remotely available on port **8090**.
You can find a list of the servers you can query from on [Riot's website](https://developer.riotgames.com/regional-endpoints.html).
The syntax of reaper is very simple:
node reaper.js [server (na/euw/lan/etc)] [username file] (output file)
node reaper.js [server (na1/euw1/la1/etc)] [username file] (output file)
For example:
node reaper.js euw username_list.txt output.txt
node reaper.js euw1 username_list.txt output.txt
Will check the list username_list.txt for available summoner names on Europe West and output what it finds to output.txt
@@ -1,31 +1,12 @@
console.error = function(msg)
{
console.log("[".white + "!".red + "] ".white + msg.white);
const colors = require('colors');
console.error = (msg) => console.log("[".white + "!".red + "] ".white + msg.white);
console.info = (msg) => console.log("[".white + "-".green + "] ".white + msg.white);
console.warn = (msg) => console.log("[".white + "~".blue + "] ".white + msg.white);
exports.shuffle = (array) => {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
};
console.info = function(msg)
{
console.log("[".white + "-".green + "] ".white + msg.white);
};
console.warn = function(msg)
{
console.log("[".white + "~".blue + "] ".white + msg.white);
};
exports.shuffle = function(array)
{
var currentIndex = array.length;
var temporaryValue;
var randomIndex;
while(currentIndex !== 0)
{
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
}
@@ -1,94 +1,46 @@
var common = require('./common');
var colors = require('colors');
var chunk = require('chunk');
var args = process.argv.slice(2);
var fs = require('fs');
var http = require('http');
var https = require("https");
if(args.length < 2 || args.length > 3)
{
console.error("Invalid syntax. Valid syntax: " + process.argv[0] + " " + process.argv[1] + " [server] [username input] (username output)");
}
"use strict";
var apiKey = "<api key here>";
const common = require('./common');
const chunk = require('chunk');
const fs = require('fs');
const https = require('https');
const RateLimiter = require('limiter').RateLimiter;
var server = args[0];
var input = args[1];
var output = args[2];
const args = process.argv.slice(2);
if(args.length < 2 || args.length > 3) {
console.error("Invalid syntax. Valid syntax: " + process.argv[0] + " " + process.argv[1] + " [server] [username input] (username output)");
}
var RateLimiter = require('limiter').RateLimiter;
var limiter = new RateLimiter(1, 'second');
const apiKey = "<api key here>";
var namesChecked = 0;
var namesFound = 0;
const server = args[0];
const input = args[1];
const output = args[2];
http.createServer(function(req, res)
{
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Names Checked: ' + namesChecked + '\nNames Found: ' + namesFound);
}).listen(8090);
const limiter = new RateLimiter(1, 'second');
var names = fs.readFileSync(input).toString().split('\n');
const names = fs.readFileSync(input).toString().split('\n');
common.shuffle(names);
chunk(names, 40).forEach(function(chunked)
{
limiter.removeTokens(1, function(err, remainingRequests)
{
namesChecked += 40;
var users = chunked.join(',').replace(/[-]/g, ' ').replace(/[\r\n'.]/g, '');
https.get('https://' + server + '.api.pvp.net/api/lol/' + server + '/v1.4/summoner/by-name/' + users + '?api_key=' + apiKey, function(res)
{
if(res.statusCode === 404) {
chunked.forEach(function(name)
{
namesFound++;
console.info(name.replace(/[-]/g, ' ').replace(/[\r\n'.]/g, '') + " is available!");
if(output != undefined)
fs.appendFile(output, name + '\n');
});
} else if(res.statusCode === 200) {
var body = '';
res.setEncoding('utf8');
res.on('data', function(d) {
body += d;
});
res.on('end', function()
{
var obj = JSON.parse(body);
chunked.forEach(function(name)
{
name = name.replace(/[-]/g, ' ').replace(/[\r\n'.]/g, '').trim();
if(name.length < 3)
return;
if(obj[name] == undefined)
{
if(output != undefined)
fs.appendFile(output, name + '\r\n');
console.info(name + " is available!");
namesFound++;
}
});
});
}
});
});
});
for (let name of names) {
name = name.replace(/[-]/g, ' ').replace(/[\r\n'.]/g, '').trim();
if(name.length < 3)
continue;
limiter.removeTokens(1, () => {
https.get(`https://${server}.api.riotgames.com/lol/summoner/v3/summoners/by-name/${name}?api_key=${apiKey}`, (res) => {
if(res.statusCode === 404) {
console.info(name.replace(/[-]/g, ' ').replace(/[\r\n'.]/g, '') + " is available!");
if(output !== undefined)
fs.appendFile(output, name + '\n', () => null);
}
});
});
}