Skip to content

Commit 4bb2539

Browse files
committed
LICENSE
1 parent 3dfb5e8 commit 4bb2539

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 smartchessguiapp
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"homepage": "https://github.com/hyperchessbot/hyperbot#readme",
2020
"dependencies": {
2121
"@easychessanimations/fetchutils": "^1.0.2",
22-
"@easychessanimations/lichessutils": "^1.0.10",
22+
"@easychessanimations/lichessutils": "^1.0.11",
2323
"@easychessanimations/sse": "^1.0.6",
2424
"express": "^4.17.1",
2525
"node-fetch": "^2.6.1",

server.js

+5-13
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ const engineThreads = process.env.ENGINE_THREADS || "1"
33
const engineMoveOverhead = process.env.ENGINE_MOVE_OVERHEAD || "500"
44
const generalTimeout = parseInt(process.env.GENERAL_TIMEOUT || "15")
55
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")
88

99
const path = require('path')
1010
const express = require('express')
@@ -276,19 +276,11 @@ function streamEvents(){
276276
}})
277277
}
278278

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-
287279
function challengeBot(bot){
288280
return new Promise(resolve=>{
289281
lichessUtils.postApi({
290282
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`,
292284
contentType: "application/x-www-form-urlencoded",
293285
callback: content => {
294286
logPage(`challenge response: ${content}`)
@@ -300,9 +292,9 @@ function challengeBot(bot){
300292

301293
function challengeRandomBot(){
302294
return new Promise(resolve=>{
303-
getOnlineBots().then(bots=>{
295+
lichessUtils.getOnlineBots().then(bots=>{
304296
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)]
306298

307299
logPage(`challenging ${bot}`)
308300

0 commit comments

Comments
 (0)