@@ -3,8 +3,8 @@ const engineThreads = process.env.ENGINE_THREADS || "1"
3
3
const engineMoveOverhead = process . env . ENGINE_MOVE_OVERHEAD || "500"
4
4
const generalTimeout = parseInt ( process . env . GENERAL_TIMEOUT || "15" )
5
5
const queryPlayingInterval = parseInt ( process . env . QUERY_PLAYING_INTERVAL || "60" )
6
- const challengeInterval = parseInt ( process . env . CHALLENGE_INTERVAL || "10 " )
7
- const challengeTimeout = parseInt ( process . env . CHALLENGE_TIMEOUT || "20 " )
6
+ const challengeInterval = parseInt ( process . env . CHALLENGE_INTERVAL || "30 " )
7
+ const challengeTimeout = parseInt ( process . env . CHALLENGE_TIMEOUT || "60 " )
8
8
9
9
const path = require ( 'path' )
10
10
const express = require ( 'express' )
@@ -276,19 +276,11 @@ function streamEvents(){
276
276
} } )
277
277
}
278
278
279
- function getOnlineBots ( ) {
280
- return new Promise ( resolve => {
281
- fetch ( `https://lichess.org/player/bots` ) . then ( response => response . text ( ) . then ( content => {
282
- resolve ( content . match ( / \/ @ \/ [ ^ " ] + / g) . map ( m => m . split ( "/" ) [ 2 ] ) . filter ( bot => bot != lichessBotName ) )
283
- } ) )
284
- } )
285
- }
286
-
287
279
function challengeBot ( bot ) {
288
280
return new Promise ( resolve => {
289
281
lichessUtils . postApi ( {
290
282
url : `https://lichess.org/api/challenge/${ bot } ` , log : true , token : process . env . TOKEN ,
291
- body : `rated=true&clock.limit=${ 60 * ( Math . floor ( Math . random ( ) * 5 ) + 1 ) } &clock.increment=0` ,
283
+ body : `rated=${ Math . random ( ) > 0.5 ? " true" : "false" } &clock.limit=${ 60 * ( Math . floor ( Math . random ( ) * 5 ) + 1 ) } &clock.increment=0` ,
292
284
contentType : "application/x-www-form-urlencoded" ,
293
285
callback : content => {
294
286
logPage ( `challenge response: ${ content } ` )
@@ -300,9 +292,9 @@ function challengeBot(bot){
300
292
301
293
function challengeRandomBot ( ) {
302
294
return new Promise ( resolve => {
303
- getOnlineBots ( ) . then ( bots => {
295
+ lichessUtils . getOnlineBots ( ) . then ( bots => {
304
296
if ( bots . length > 0 ) {
305
- let bot = bots [ Math . floor ( Math . random ( ) * bots . length ) ]
297
+ let bot = bots . filter ( bot => bot != lichessBotName ) [ Math . floor ( Math . random ( ) * bots . length ) ]
306
298
307
299
logPage ( `challenging ${ bot } ` )
308
300
0 commit comments