Skip to content

motoki317/traq4j

Repository files navigation

traq4j

GitHub release

traQ API client for Java

Requires Java 8+

Example usage

pom.xml

Make sure to use the latest version shown below.

GitHub release

<project>
    <repositories>
        <repository>
            <id>GitHub traq4j</id>
            <url>https://raw.github.com/motoki317/traq4j/mvn-repo/</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>com.github.motoki317</groupId>
            <artifactId>traq4j</artifactId>
            <version>${traq4j.version}</version>
        </dependency>
    </dependencies>
</project>

Code

public class Main {
    public static void main(String[] args){
        // Create API client
        String accessToken = System.getenv("ACCESS_TOKEN");
        ApiClient client = new ApiClient();
        client.addDefaultHeader("Authorization", "Bearer " + accessToken);

        // Message API client
        MessageApi messageApi = new MessageApi(client);

        // Post message
        String channelId = "00000000-0000-0000-0000-000000000000";
        String content = "oisu~";
        Message message = messageApi.postMessage(
                UUID.fromString(channelId),
                new PostMessageRequest().content(content).embed(false)
        );
        assert message != null;
    }
}

Development

  1. $ ./generate.sh
  2. Reformat code (takes some time)

About

traQ API client for Java

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages