Git Product home page Git Product logo

chariot's Introduction

Chariot

Chariot is a Java client for the Lichess API. It is compiled for Java 21.
Lichess is a charity and entirely free/libre open source software.

API Listing

Client.basic()
import chariot.Client;

var client = Client.basic()


client.withToken()
client.withPkce()

client.analysis().cloudEval()

client.bot().botsOnline()

client.broadcasts().official()
client.broadcasts().exportPgn()
client.broadcasts().exportOneRoundPgn()
client.broadcasts().streamBroadcast()
client.broadcasts().broadcastById()
client.broadcasts().leaderboardById()
client.broadcasts().roundById()
client.broadcasts().byUserId()
client.broadcasts().topActive()
client.broadcasts().topUpcoming()
client.broadcasts().topPast()

client.challenges().challengeOpenEnded()

client.externalEngine().acquire()
client.externalEngine().answer()
client.externalEngine().analyse()

client.games().byGameId()
client.games().byGameIds()
client.games().byUserId()
client.games().currentByUserId()
client.games().moveInfosByGameId()
client.games().gameInfosByUserIds()
client.games().addGameIdsToStream()
client.games().tvFeed()
client.games().tvChannels()
client.games().byChannel()
client.games().importGame()

client.openingExplorer().masters()
client.openingExplorer().lichess()
client.openingExplorer().player()

client.puzzles().dailyPuzzle()
client.puzzles().byId()
client.puzzles().stormDashboard()

client.simuls().simuls()

client.studies().exportStudiesByUserId()
client.studies().exportChaptersByStudyId()
client.studies().exportChapterByStudyAndChapterId()
client.studies().lastModifiedByStudyId()
client.studies().byPage()
client.studies().listStudies()
client.studies().listStudiesByUser()
client.studies().deleteStudyChapter()

client.tablebase().standard()
client.tablebase().atomic()
client.tablebase().antichess()

client.teams().numberOfTeams()
client.teams().search()
client.teams().searchByPage()
client.teams().popularTeams()
client.teams().byTeamId()
client.teams().byUserId()
client.teams().usersByTeamId()
client.teams().arenaByTeamId()
client.teams().swissByTeamId()

client.tournaments().currentTournaments()
client.tournaments().arenasCreatedByUserId()
client.tournaments().arenaById()
client.tournaments().swissById()
client.tournaments().gamesByArenaId()
client.tournaments().gamesBySwissId()
client.tournaments().resultsByArenaId()
client.tournaments().resultsBySwissId()
client.tournaments().swissTRF()
client.tournaments().teamBattleResultsById()

client.users().byId()
client.users().byIds()
client.users().top10()
client.users().leaderboard()
client.users().liveStreamers()
client.users().activityById()
client.users().statusById()
client.users().statusByIds()
client.users().ratingHistoryById()
client.users().crosstable()
client.users().performanceStatisticsByIdAndType()
client.users().autocompleteNames()
client.users().autocompleteUsers()
Client.auth()
import chariot.Client;

var client = Client.auth()

client.revokeToken()

client.account().profile()
client.account().following()
client.account().emailAddress()
client.account().preferences()
client.account().kidMode()
client.account().timeline()

client.board().connect()
client.board().challenge()
client.board().challengeKeepAlive()
client.board().challengeAI()
client.board().acceptChallenge()
client.board().declineChallenge()
client.board().cancelChallenge()
client.board().seekCorrespondence()
client.board().seekRealTime()
client.board().connectToGame()
client.board().move()
client.board().abort()
client.board().resign()
client.board().handleDrawOffer()
client.board().handleTakebackOffer()
client.board().claimVictory()
client.board().berserk()
client.board().chat()
client.board().chatSpectators()
client.board().fetchChat()

client.bot().upgradeToBotAccount()
client.bot().connect()
client.bot().challenge()
client.bot().challengeKeepAlive()
client.bot().challengeAI()
client.bot().acceptChallenge()
client.bot().declineChallenge()
client.bot().cancelChallenge()
client.bot().connectToGame()
client.bot().move()
client.bot().abort()
client.bot().resign()
client.bot().handleDrawOffer()
client.bot().handleTakebackOffer()
client.bot().chat()
client.bot().chatSpectators()
client.bot().fetchChat()

client.broadcasts().create()
client.broadcasts().update()
client.broadcasts().createRound()
client.broadcasts().updateRound()
client.broadcasts().resetRound()
client.broadcasts().pushPgnByRoundId()
client.broadcasts().myRounds()

client.challenges().connect()
client.challenges().challenges()
client.challenges().challenge()
client.challenges().challengeKeepAlive()
client.challenges().challengeAI()
client.challenges().acceptChallenge()
client.challenges().declineChallenge()
client.challenges().cancelChallenge()
client.challenges().show()
client.challenges().addTimeToGame()
client.challenges().bulk()
client.challenges().bulks()
client.challenges().createBulk()
client.challenges().startBulk()
client.challenges().cancelBulk()
client.challenges().startClocksOfGame()

client.externalEngine().list()
client.externalEngine().get()
client.externalEngine().create()
client.externalEngine().update()
client.externalEngine().delete()

client.games().ongoing()
client.games().imported()
client.games().byBulkId()

client.puzzles().activity()
client.puzzles().createAndJoinRace()
client.puzzles().puzzleDashboard()

client.studies().importPgn()

client.teams().joinTeam()
client.teams().leaveTeam()
client.teams().messageTeam()
client.teams().kickFromTeam()
client.teams().requests()
client.teams().requestsDeclined()
client.teams().requestAccept()
client.teams().requestDecline()

client.tournaments().joinArena()
client.tournaments().joinSwiss()
client.tournaments().withdrawArena()
client.tournaments().withdrawSwiss()
client.tournaments().createArena()
client.tournaments().createSwiss()
client.tournaments().updateArena()
client.tournaments().updateSwiss()
client.tournaments().scheduleNextRoundSwiss()
client.tournaments().terminateArena()
client.tournaments().terminateSwiss()
client.tournaments().generateUserEntryCodes()
client.tournaments().updateTeamBattle()

client.usersAuth().sendMessageToUser()
client.usersAuth().followUser()
client.usersAuth().unfollowUser()
client.usersAuth().blockUser()
client.usersAuth().unblockUser()
client.usersAuth().writeNoteAboutUser()
client.usersAuth().readNotesAboutUser()

Checkout the JavaDoc for details.

Use as Dependency

The coordinates are io.github.tors42:chariot:0.1.5, so in a Maven project the following dependency can be added to the pom.xml:

    <dependency>
      <groupId>io.github.tors42</groupId>
      <artifactId>chariot</artifactId>
      <version>0.1.5</version>
    </dependency>

Here is a link to a simple example Maven project application https://github.com/tors42/chariot-example which can be imported into an IDE in order to get things like code completion support and other good stuff.

Try it out in JShell

JShell is a tool which can be used to interactively execute Java code.
The tool is included in JDK archives, which can be downloaded and unpacked from https://jdk.java.net/

$ jshell
|  Welcome to JShell -- Version 22.0.2
|  For an introduction type: /help intro

jshell>

Tell JShell to download the latest release of chariot and make it available in the JShell environment,

jshell> Files.write(Path.of("chariot-0.1.5.jar"), URI.create("https://repo1.maven.org/maven2/io/github/tors42/chariot/0.1.5/chariot-0.1.5.jar").toURL().openStream().readAllBytes());
$1 ==> chariot-0.1.5.jar

jshell> /env --module-path chariot-0.1.5.jar --add-module chariot
|  Setting new options and restoring state.

jshell>

Copy/paste the following example code,

import chariot.Client;

var client = Client.basic();
System.out.println(client.teams().byTeamId("lichess-swiss")
    .map(team -> "Team %s has %d members!".formatted(team.name(), team.nbMembers()))
    .orElse("Couldn't find team!"));
jshell> import chariot.Client;
   ...> 
   ...> var client = Client.basic();
   ...> System.out.println(client.teams().byTeamId("lichess-swiss")
   ...>     .map(team -> "Team %s has %d members!".formatted(team.name(), team.nbMembers()))
   ...>     .orElse("Couldn't find team!"));
client ==> chariot.Client@45efd90f
Team Lichess Swiss has 490327 members!

jshell>

Tip, it is possible to use the tab key to get code completion to discover the API.
For instance, after writing client.teams(). and pressing the tab key,

jshell> client.teams().<press tab key>
arenaByTeamId(        byTeamId(             byUserId(             equals(
getClass()            hashCode()            notify()              notifyAll()
numberOfTeams()       popularTeams()        popularTeamsByPage(   search(
searchByPage(         swissByTeamId(        toString()            usersByTeamId(
wait(
jshell> client.teams().numberOfTeams();
$4 ==> 360145

jshell> /exit
|  Goodbye

Build Chariot

Build with latest Java. A JDK archive can be downloaded and unpacked from https://jdk.java.net/

$ java -version
openjdk version "22.0.2" 2024-07-16
OpenJDK Runtime Environment (build 22.0.2+9-70)
OpenJDK 64-Bit Server VM (build 22.0.2+9-70, mixed mode, sharing)

$ java build/Build.java
61 successful basic tests
0 failed tests

The resulting artifact, out/modules/chariot-0.0.1-SNAPSHOT.jar, will be compatible with Java release 21

Examples (non-project, single files)

1. Example.java

An example which uses a token to authenticate in order to be able to create a Swiss tournament

package build;

import chariot.Client;
import java.time.*;

class Example {

    public static void main(String[] args) {

        var client = Client.auth("my-token");

        var tomorrow = ZonedDateTime.now().plusDays(1).with(
            LocalTime.parse("17:00"));

        String teamId = "my-team-id";

        var result = client.tournaments().createSwiss(teamId, params -> params
            .clockBlitz5m3s()
            .name("My 5+3 Swiss")
            .rated(false)
            .description("Created via API")
            .startsAt(tomorrow));

        System.out.println(result);
    }
}
$ java -p out/modules --add-modules chariot build/Example.java
Entry[entry=Swiss[id=vLx22Ff1, name=My 5+3 Swiss, createdBy=test, startsAt=2022-03-29T17:00:00.000+02:00, status=created, nbOngoing=0, nbPlayers=0, nbRounds=9, round=0, rated=false, variant=standard, clock=Clock[limit=300, increment=3], greatPlayer=null, nextRound=NextRound[at=2022-03-29T17:00:00.000+02:00, in=62693], quote=null]]

2. FEN.java

An example which feeds moves to a Board in order to track FEN updates, and "draws" the board with text.

package build;

import java.util.List;

import chariot.util.Board;

class FEN {
    public static void main(String[] args) {

        Board initialBoard = Board.fromStandardPosition();

        List<String> validMovesUCI = initialBoard.validMoves().stream()
            .map(Board.Move::uci)
            .sorted()
            .toList();

        List<String> validMovesSAN = validMovesUCI.stream()
            .map(initialBoard::toSAN)
            .toList();

        String movesToPlay = "e4 e5 Nf3 Nc6"; // (UCI also ok, "e2e4 e7e5 g1f3 b8c6")

        Board resultingBoard = initialBoard.play(movesToPlay);

        System.out.println(String.join("\n",
                "Initial FEN: "         + initialBoard.toFEN(),
                "Initial Board:\n"      + initialBoard,
                "Valid moves (UCI): "   + validMovesUCI,
                "Valid moves (SAN): "   + validMovesSAN.stream().map("%4s"::formatted).toList(),
                "Playing: "             + movesToPlay,
                "Resulting FEN: "       + resultingBoard.toFEN(),
                "Resulting Board:\n"    + resultingBoard,
                "Board (letter, frame, coordinates):\n" +
                resultingBoard.toString(c -> c.letter().frame().coordinates())
                ));
    }

   public static long costOfThisProgramBecomingSkyNet() {
        return Long.MAX_VALUE; // https://xkcd.com/534/
   }
}
$ java -p out/modules --add-modules chariot build/FEN.java
Initial FEN: rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
Initial Board:
♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
               
               
               
               
♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙
♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖
Valid moves (UCI): [a2a3, a2a4, b1a3, b1c3, b2b3, b2b4, c2c3, c2c4, d2d3, d2d4, e2e3, e2e4, f2f3, f2f4, g1f3, g1h3, g2g3, g2g4, h2h3, h2h4]
Valid moves (SAN): [  a3,   a4,  Na3,  Nc3,   b3,   b4,   c3,   c4,   d3,   d4,   e3,   e4,   f3,   f4,  Nf3,  Nh3,   g3,   g4,   h3,   h4]
Playing: e4 e5 Nf3 Nc6
Resulting FEN: r1bqkbnr/pppp1ppp/2n5/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 2 3
Resulting Board:
♜   ♝ ♛ ♚ ♝ ♞ ♜
♟ ♟ ♟ ♟   ♟ ♟ ♟
    ♞          
        ♟      
        ♙      
          ♘    
♙ ♙ ♙ ♙   ♙ ♙ ♙
♖ ♘ ♗ ♕ ♔ ♗   ♖
Board (letter, frame, coordinates):
  ┌───┬───┬───┬───┬───┬───┬───┬───┐
8 │ r │   │ b │ q │ k │ b │ n │ r │
  ├───┼───┼───┼───┼───┼───┼───┼───┤
7 │ p │ p │ p │ p │   │ p │ p │ p │
  ├───┼───┼───┼───┼───┼───┼───┼───┤
6 │   │   │ n │   │   │   │   │   │
  ├───┼───┼───┼───┼───┼───┼───┼───┤
5 │   │   │   │   │ p │   │   │   │
  ├───┼───┼───┼───┼───┼───┼───┼───┤
4 │   │   │   │   │ P │   │   │   │
  ├───┼───┼───┼───┼───┼───┼───┼───┤
3 │   │   │   │   │   │ N │   │   │
  ├───┼───┼───┼───┼───┼───┼───┼───┤
2 │ P │ P │ P │ P │   │ P │ P │ P │
  ├───┼───┼───┼───┼───┼───┼───┼───┤
1 │ R │ N │ B │ Q │ K │ B │   │ R │
  └───┴───┴───┴───┴───┴───┴───┴───┘
    a   b   c   d   e   f   g   h

Applications

A list of applications using Chariot,

Bobby Chess Engine with Lichess Bot integration (Java)
Lichess Rating Graph Visualize rating (JavaFX)
Chesslise Discord Bot which allows users to play, learn, and watch chess (Discord)
Team Check Visualize team members (Swing)
charibot Application to control a Lichess BOT account (makes random moves) (Java) @charibot
jc Watch the featured LichessTV game in terminal or Play a casual Rapid game with the Board API (Swing/Text)
ee External Engine - Use local desktop chess engine in Lichess Analysis web browser (Swing)

JBang Examples Various example scripts (JBang)
Challenge AI Example OAuth2 PKCE example (Web Application)
Playground GitHub Codespaces repo to write code in browser
Open in GitHub Codespaces

Contact

For any questions and/or feedback, feel free to open an issue in this project. Or use the Discussions feature of GitHub. Another means of contact could be through the Lichess Discord server, look for the #lichess-api-support channel.

chariot's People

Contributors

fitztrev avatar tors42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

chariot's Issues

No enum constant chariot.model.StatsPerfType.standard

Hi,

I've been using this library for a couple of months, but recently I haven't been able to retrieve my bot rating.

Even after updating to the most recent library version: 0.0.84

Whenever I execute:

Map<StatsPerfType, StatsPerf> rating = client.account() .profile() .get() .ratings();

I get the following exception

java.lang.IllegalArgumentException: No enum constant chariot.model.StatsPerfType.standard at java.base/java.lang.Enum.valueOf(Enum.java:273) at [email protected]/chariot.model.StatsPerfType.valueOf(StatsPerfType.java:3) at [email protected]/chariot.internal.ModelMapper.lambda$static$22(ModelMapper.java:393) at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:179) at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169) at java.base/java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1850) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) at [email protected]/chariot.internal.ModelMapper.lambda$static$26(ModelMapper.java:392) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) at java.base/java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1850) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575) at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:622) at java.base/java.util.stream.ReferencePipeline.toList(ReferencePipeline.java:627) at [email protected]/chariot.internal.ModelMapper.lambda$static$29(ModelMapper.java:447) at [email protected]/chariot.internal.ModelMapper.lambda$static$30(ModelMapper.java:469) at java.base/java.util.function.Function.lambda$andThen$1(Function.java:88) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) at java.base/java.util.stream.ReferencePipeline$15$1.accept(ReferencePipeline.java:541) at java.base/java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1856) at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129) at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647) at [email protected]/chariot.internal.Endpoint$Builder.lambda$elementMapper$0(Endpoint.java:655) at [email protected]/chariot.internal.Endpoint$EPOne.lambda$newRequest$0(Endpoint.java:28) at [email protected]/chariot.internal.RequestParameters$ReqOne.process(RequestParameters.java:35) at [email protected]/chariot.internal.impl.AccountHandler.profile(AccountHandler.java:22)

I would appreciate your help.

Thanks,
Mauricio

Missing clock information in StreamGameEvent.Full

Hello,

I was playing around with your client a bit (huge thanks btw) as I stumbled about the following bug:

ClientAuth client = Client.auth(token);
Stream<StreamEvent> events = client.bot().streamEvents().stream();
events.forEach(event ->
{
    switch(event.type())
    {
        case challenge:
            client.bot().acceptChallenge(event.id());
            break;
        case gameStart:
            Stream<StreamGameEvent> gameEvents = client.bot().streamGameState(event.id()).stream();
            gameEvents.forEach(gameEvent ->
            {
                switch (gameEvent.type())
                {
                    case gameFull:
                        StreamGameEvent.Full fullGame = (StreamGameEvent.Full) gameEvent;
                        System.out.println(fullGame.clock());
                    default:
                        break;
                }
            });
            
            break;
        default:
            break;
    }
});

This piece of code should accept any challenges and print out the clock information, but the output for a 1.5+3 standard match is Clock[limit=null, increment=3000]. Furthermore it seems that the limit value of the clock is always null, regardless of the chosen time in the challenge.

Missing validation logic

Hi,
I've noticed that there is a lack of range and value validation on certain method arguments whithin the SDK. This absence of validation can lead to field validation errors during runtime when we unintentionally send incorrect requests (that aren't regarded as bad requests until reaching lichess API). Here are some examples:

  • The ArenaBuilder::conditionMinRating method should only accept values within the range of 1000 to 2600 ELO, with a step of 100.
  • The ArenaBuilder::name method should only accept strings with a length between 2 and 30 characters.
  • The ArenaBuilder::conditionMinRatedGames should only accept one of the following values: {0, 5, 10, 15, 20, 30, 40, 50, 75, 100, 150, 200}.
  • ...
    In some cases, the method's documentation provides information about the expected value range or specific values, while in others, there is no indication. It can be counterproductive to have to meticulously refer to both the documentation and the SDK to ensure we're using the API correctly.

I have a few questions regarding this:

  • Was this lack of validation intentionally left as-is, and if so, would you like me to help ensure consistency by submitting a pull request?
  • If this lack of validation was not intentional, would you like me to submit a pull request that simply adds range validations and enums to these methods? This way, any deviation from the specified ranges or values would result in an early compile-time error.

(PS: I'm a fan of your work ! As a Junior Backend Developer, I find it really interesting to see the new java features used in actual projects. 💯 )

AccessDeniedException when running local integration tests

Getting this error after 4c18452

$ ./build/integration/local 

Running integration tests
5e2b68b4332027e1a9a090e58087e20729f82ce4a77236b0573e52710cf31aab
99113b5c60972a29262e6221247f56968e5a5f6fb15a496604f0a412422a5320
Exception in thread "main" java.nio.file.AccessDeniedException: /app/out
        at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:90)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
        at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
        at java.base/sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:438)
        at java.base/java.nio.file.Files.createDirectory(Files.java:699)
        at java.base/java.nio.file.Files.createAndCheckIsDirectory(Files.java:807)
        at java.base/java.nio.file.Files.createDirectories(Files.java:793)
        at build.Build.build(Build.java:39)
        at build.Build.main(Build.java:18)
⌛ Waiting for lila to start...
⌛ Waiting for lila to start...
⌛ Waiting for lila to start...
⌛ Waiting for lila to start...
⌛ Waiting for lila to start...
Error occurred during initialization of boot layer
java.lang.module.FindException: Module testchariot not found

Android support

Hello!

I was considering creating a Lichess-based toy project in Android and your library would be super useful and pretty much ready to use for interfacing to Lichess APIs 🚀

There's a small issue preventing me from doing that though, the compiled jar available via maven uses bytecode for Java 17, while android supports only libraries compiled for Java 11 and below, at the moment.
Would you consider distributing the jar compiled for Java 11? Or in case providing an alternate artifact for Android, in case 🤔

Thanks for your work!

How do you handle nd-json streams? e.g. gamesByIds

Hi,

my plan is to create a game stream and add games to it as I create them via the challenge() call.

I am having difficulties with understanding on how I should proceed with this. The stream creation call gameInfosByGameIds returns a Many<T> object which I can only really transfer to a Java Stream.

Now my understanding is that JavaStreams are 'lazy', so only executed when 'closed'.

How can I then handle new objects immediately after they are added to the stream via a seperate Thread and how do I handle the GameInfo updates of an already added game?

I expected something where I can pass a callback function that always executes as soon as the ndjson stream updates on lichess but I am open to any solution that gives me GameInfo updates.

Looking for a method to get my ongoing games

Hello again,

as the title says I am looking for a method to get my ongoing games. The Lichess API has the endpoint https://lichess.org/api/account/playing which gives you a list of your current games and I am looking for exactly that in the Java Client. I have found the method client.games().ongoingGames(), but this seems not to work.

ClientAuth client = Client.auth(token);
client.games().ongoingGames().stream().forEach(System.out::println);

The code above outputs just NowPlaying[fullId=null, gameId=null, fen=null, color=null, lastMove=null, speed=null, perf=null, rated=false, isMyTurn=false, variant=null, opponent=null] every single time, wether I am playing a game or not. If this is indeed the method I am looking for, I would appreciate a fix. Else I would be very grateful for a hint to the right direction!

Thanks in advance.

enum constant chariot.model.Enums.VariantName.fromPosition missing

Hello,

the enum is missing a value for the fromPosition gamemode. The following code throws an error while trying to challenge a fromPosition match:

ClientAuth client = Client.auth(token);
Stream<StreamEvent> events = client.bot().streamEvents().stream();
events.forEach(event ->
{
    switch(event.type())
    {
        case challenge:
            ChallengeEvent challenge = (ChallengeEvent) event;
            System.out.println(challenge.challenge().variant());
            break;
        default:
            break;
    }
});

No option for unlimited time control

Just wondering if an unlimited time control when creating challenges is going to be implemented in the future? Unless it already has been and I've missed something.

How a bot can gracefully stop listening for challenges?

Hi,
I'm trying to develop a program that runs a Bot, but can stop it for a while (so that the bot can appear offline during, for instance, maintenance period), then restart it (the program should not stop during these periods).
The only way I found to do this is to interrupt the thread that listens to the challenges stream with a code like this

import chariot.Client;
import chariot.ClientAuth;
import chariot.model.Event;
import chariot.model.Many;

public class Bot {
	private final ClientAuth client;
	private final Thread backThread;
	
	public Bot(String token) {
		client = Client.auth(token);
		this.backThread = new Thread(this::run);
	}

	public void start() {
		backThread.start();
	}
	
	private void run() {
		final Many<Event> events = client.bot().connect();
			events.stream().forEach(System.out::println);
	}
	
	public void stop() {
		backThread.interrupt();
	}
}

Unfortunately, calling stop() results in a severe error reported in the log (reported by chariot.internal.InternalClient class).

Is there any way to prevent this behavior.

Best regards (and thanks for this impressive library),

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.