diff --git a/modules/oeis/oeis.js b/modules/oeis/oeis.js index 7a23fdf..8debcc7 100644 --- a/modules/oeis/oeis.js +++ b/modules/oeis/oeis.js @@ -74,6 +74,28 @@ var OEIS = function(dbot) { if(!body.results) throw 'no-results'; return this.internalAPI.parseResult(body.results[0]); + }, + + 'getRandomSequenceA': async set => { + // This feature uses OEIS's 'webcam' which serves up random entries + // each time the page is refreshed. It appears to be the only way to get + // valid random entries from the database. The alternative is to just generate + // random A-numbers from the set of all A-numbers, but that seems dirty to me. + var body = await rp({ + url: this.webRoot + '/webcam', + qs: { + fromjavascript: 1, + q: 'keyword:' + set + } + }); + + // Find where the A-number is located + var i = body.indexOf('