Skip to content

synyx/java-matrix-bot-lib

Repository files navigation

Java Matrix Bot Lib

A java library for communicating with a Matrix server, meant to aid in creating a chatbot.

Usage

Currently requires at least JDK 21. If you are using Maven, add the following repository to your pom.xml:

<repositories>
    <repository>
        <id>synyx-public</id>
        <url>https://nexus.synyx.de/repository/public-releases/</url>
    </repository>
</repositories>

then you can add java-matrix-bot-lib as a dependency:

<dependency>
    <groupId>org.synyx</groupId>
    <artifactId>java-matrix-bot-lib</artifactId>
    <version>VERSIONHERE</version>
</dependency>

Example

public class MyMatrixBot implements MatrixEventConsumer {

    private MatrixClient matrixClient;

    public MyMatrixBot() {

        MatrixClient matrixClient = new MatrixClient("https://matrix.example.com", "username", "password");
        matrixClient.setPersistedState(matrixStatePersistence);
    }

    public void startBot() {
        // Blocks the thread
        matrixClient.syncContinuous();
    }

    public void stopBot() {

        matrixClient.requestStopOfSync();
    }

    @Override
    public void onMessage(MatrixState state, MatrixRoom room, MatrixMessage message) {
        // ...
    }
}

About

A small Java library to aid in creating a matrix chat bot

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages