diff --git a/README.md b/README.md index 61cd6e4..6c16c69 100644 --- a/README.md +++ b/README.md @@ -52,44 +52,7 @@ Do you prefer other programming languages? ```java -package io.github.jwdeveloper.tiktok; - -import io.github.jwdeveloper.tiktok.utils.ConsoleColors; - -import java.io.IOException; -import java.time.Duration; -import java.util.logging.Level; - -public class SimpleExample -{ - public static String TIKTOK_HOSTNAME = "szwagierkaqueen"; - public static void main(String[] args) throws IOException { - - showLogo(); - // set tiktok username - TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME) - .configure(clientSettings -> - { - clientSettings.setHostName(SimpleExample.TIKTOK_HOSTNAME); // This method is useful in case you want change hostname later - clientSettings.setClientLanguage("en"); // Language - clientSettings.setTimeout(Duration.ofSeconds(2)); // Connection timeout - clientSettings.setLogLevel(Level.ALL); // Log level - clientSettings.setPrintToConsole(true); // Printing all logs to console even if log level is Level.OFF - clientSettings.setHandleExistingEvents(true); // Invokes all TikTok events that had occurred before connection - clientSettings.setRetryOnConnectionFailure(true); // Reconnecting if TikTok user is offline - clientSettings.setRetryConnectionTimeout(Duration.ofSeconds(1)); // Timeout before next reconnection - - //Optional: Sometimes not every message from chat are send to TikTokLiveJava to fix this issue you can set sessionId - // documentation how to obtain sessionId https://github.com/isaackogan/TikTok-Live-Connector#send-chat-messages - - // clientSettings.setSessionId("86c3c8bf4b17ebb2d74bb7fa66fd0000"); - - //Optional: - //RoomId can be used as an override if you're having issues with HostId. - //You can find it in the HTML for the livestream-page - - //clientSettings.setRoomId("XXXXXXXXXXXXXXXXX"); - }) + TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME) .onGift((liveClient, event) -> { switch (event.getGift()) { @@ -99,22 +62,10 @@ public class SimpleExample default -> print(ConsoleColors.GREEN, "[Thanks for gift] ", ConsoleColors.YELLOW, event.getGift().getName(), "x", event.getCombo()); } }) - .onGiftCombo((liveClient, event) -> - { - print(ConsoleColors.RED,"GIFT COMBO",event.getGift().getName(),event.getCombo()); - }) .onConnected((client, event) -> { print(ConsoleColors.GREEN, "[Connected]"); }) - .onDisconnected((liveClient, event) -> - { - print(ConsoleColors.RED,"[Disconnected]"); - }) - .onFollow((liveClient, event) -> - { - print(ConsoleColors.BLUE, "Follow:", ConsoleColors.WHITE_BRIGHT, event.getUser().getName()); - }) .onJoin((client, event) -> { print(ConsoleColors.WHITE, "Join:", ConsoleColors.WHITE_BRIGHT, event.getUser().getName()); @@ -123,39 +74,11 @@ public class SimpleExample { print(ConsoleColors.GREEN, event.getUser().getName(), ":", ConsoleColors.WHITE_BRIGHT, event.getText()); }) - .onEvent((client, event) -> - { - //System.out.println("Event: " +event.getClass().getSimpleName()); - }) .onError((client, event) -> { event.getException().printStackTrace(); }) .buildAndConnectAsync(); - System.in.read(); - } - - private static void print(Object... messages) { - var sb = new StringBuilder(); - for (var message : messages) { - sb.append(message).append(" "); - } - System.out.println(sb); - } - - private static void showLogo() - { - System.out.println(ConsoleColors.GREEN+""" - - _____ _ _ _____ _ _ _ s - |_ _(_) | _|_ _|__ | | _| | (_)_ _____s - | | | | |/ / | |/ _ \| |/ / | | \ \ / / _ \ - | | | | < | | (_) | <| |___| |\ V / __/ - |_| |_|_|\_\ |_|\___/|_|\_\_____|_| \_/ \___| - """); - - } -} ``` ## Events