Skip to content

R2turnTrue/chzzk4j

Repository files navigation

chzzk4j

/ Example Minecraft Plugin / Discord Server

Unofficial Java API library of CHZZK (치지직, the video streaming service of Naver)

  • This library is not completed. Please contribute a lot through Pull-Request!
  • Please feel free to create an issue if you have any problems!

installation

Warning

0.1.1 이하의 경우, Group ID로 io.github.R2turnTrue를 사용해야 합니다! 대소문자를 구별하니 조심해주세요!

repositories {
    mavenCentral()
}

dependencies {
    implementation("io.github.r2turntrue:chzzk4j:0.1.3")
}

usage

Check at our docs!

examples

minimal legacy chat example

ChzzkClient client = new ChzzkClientBuilder() // 레거시 챗은 비공개 API이기 때문에, API 키가 필요하지 않습니다.
        .build();
ChzzkChat chat = new ChzzkChatBuilder(client,
        "CHANNEL_ID")
        .build();

chat.on(ConnectEvent.class, (evt) -> {
    System.out.println("connected to chat :)");
});

chat.on(ChatMessageEvent.class, (evt) -> {
    ChatMessage msg = evt.getMessage();
    
    if (msg.getProfile() == null) {
        System.out.println(String.format("익명: %s", msg.getContent()));
        return;
    }

    System.out.println(
            String.format("[Chat] %s: %s",
                msg.getProfile().getNickname(),
                msg.getContent()));
});

chat.connectBlocking();

session api example

var adapter = new ChzzkOauthLoginAdapter(5000);
var client = new ChzzkClientBuilder(apiClientId, apiSecret)
        .withDebugMode()
        .withLoginAdapter(adapter)
        .build();

System.out.println(adapter.getAccountInterlockUrl(apiClientId, false)); // Show Login URL

client.loginAsync().join(); // Wait for the user to login by the interlock URL

var session = new ChzzkSessionBuilder(client)
        .buildUserSession();

session.subscribeAsync(ChzzkSessionSubscriptionType.CHAT).join();

session.on(SessionConnectedEvent.class, (event) -> {
    System.out.println("Connected!");
});

session.on(SessionDisconnectedEvent.class, (event) -> {
    System.out.println("Disconnected :(");
});

session.on(SessionChatMessageEvent.class, (event) -> {
    var msg = event.getMessage();
    System.out.printf("[CHAT] %s: %s [at %s]%n", msg.getProfile().getNickname(), msg.getContent(), msg.getMessageTime());
});

session.on(SessionRecreateEvent.class, (event) -> {
    System.out.println("Recreating the session...");
});

session.on(SessionSubscribedEvent.class, (event) -> {
    System.out.println("Yeah I subscribed to: " + event.getEventType());
});

session.on(SessionUnsubscribedEvent.class, (event) -> {
    System.out.println("Yeah I unsubscribed to: " + event.getEventType());
});

session.createAndConnectAsync().join();

modify chat settings example

ChzzkChatSettings settings = client.fetchChatSettings().join();

// 본인인증 여부 설정 조건을 변경합니다.
settings.setChatAvailableCondition(ChzzkChatSettings.ChatAvailableCondition.REAL_NAME);

// 채팅 참여 범위 설정 조건을 변경합니다.
settings.setChatAvailableGroup(ChzzkChatSettings.ChatAvailableGroup.FOLLOWER);
// (위 ChatAvailableGroup이 FOLLOWER일 경우) 최소 팔로잉 기간을 설정합니다.
settings.setMinFollowerMinute(ChzzkChatSettings.MinFollowerMinute.M_60);
// (위 ChatAvailableGroup이 FOLLOWER일 경우) 구독자는 최소 팔로잉 기간 조건 대상에서 제외/허용 할지 여부를 설정합니다.
settings.setAllowSubscriberInFollowerMode(false);

// 변경된 방송 설정을 서버에 전송합니다.
client.modifyChatSettings(settings).join();

features

  • get channel information & rules
  • get current user's information
  • get channel followed status
  • async chat integration (read/send)
  • get recommendation channels
  • fix invalid json (chat)
  • load emoji pack
  • get live status
  • get live detail

need to implement

  • write javadocs of all methods/classes/etc..
  • parse emoji from chat message
  • get following channels of user that logged in
  • get video information
  • get cheese ranking

references

About

Unofficial Java API library of CHZZK (치지직, the video streaming service of Naver)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 7

Languages