mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-28 09:19:40 -05:00
Changes:
- Implementation on all features in `clientSettings` - Code optimization - More detail exceptions - Downloading gifts
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package io.github.jwdeveloper.tiktok;
|
||||
|
||||
import io.github.jwdeveloper.tiktok.events.messages.*;
|
||||
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static String TEST_TIKTOK_USER = "mr_cios";
|
||||
public static String TEST_TIKTOK_USER = "vadimpyrography";
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
var client = TikTokLive.newClient(TEST_TIKTOK_USER)
|
||||
@@ -21,59 +22,59 @@ public class Main {
|
||||
.onLike(Main::onLike)
|
||||
.onGiftMessage(Main::onGiftMessage)
|
||||
.onEmote(Main::onEmote)
|
||||
.onError(tikTokErrorEvent ->
|
||||
.onError((_client, error) ->
|
||||
{
|
||||
// tikTokErrorEvent.getException().printStackTrace();
|
||||
error.getException().printStackTrace();
|
||||
})
|
||||
.buildAndRun();
|
||||
|
||||
|
||||
var viewers = client.getRoomInfo().getViewersCount();
|
||||
System.in.read();
|
||||
}
|
||||
|
||||
private static void onConnected(TikTokConnectedEvent e) {
|
||||
private static void onConnected(LiveClient tikTokLive, TikTokConnectedEvent e) {
|
||||
print("Connected");
|
||||
}
|
||||
|
||||
private static void onDisconnected(TikTokDisconnectedEvent e) {
|
||||
private static void onDisconnected(LiveClient tikTokLive, TikTokDisconnectedEvent e) {
|
||||
print("Disconnected");
|
||||
}
|
||||
|
||||
private static void onViewerData(TikTokRoomViewerDataEvent e) {
|
||||
private static void onViewerData(LiveClient tikTokLive, TikTokRoomViewerDataEvent e) {
|
||||
print("Viewer count is:", e.getViewerCount());
|
||||
}
|
||||
|
||||
private static void onJoin(TikTokJoinEvent e) {
|
||||
private static void onJoin(LiveClient tikTokLive, TikTokJoinEvent e) {
|
||||
print(e.getUser().getUniqueId(), "joined!");
|
||||
}
|
||||
|
||||
private static void onComment(TikTokCommentEvent e) {
|
||||
private static void onComment(LiveClient tikTokLive, TikTokCommentEvent e) {
|
||||
print(e.getUser().getUniqueId(), e.getText());
|
||||
}
|
||||
|
||||
private static void onFollow(TikTokFollowEvent e) {
|
||||
private static void onFollow(LiveClient tikTokLive, TikTokFollowEvent e) {
|
||||
print(e.getNewFollower().getUniqueId(), "followed!");
|
||||
}
|
||||
|
||||
private static void onShare(TikTokShareEvent e) {
|
||||
private static void onShare(LiveClient tikTokLive, TikTokShareEvent e) {
|
||||
print(e.getUser().getUniqueId(), "shared!");
|
||||
}
|
||||
|
||||
private static void onSubscribe(TikTokSubscribeEvent e) {
|
||||
private static void onSubscribe(LiveClient tikTokLive, TikTokSubscribeEvent e) {
|
||||
print(e.getNewSubscriber().getUniqueId(), "subscribed!");
|
||||
}
|
||||
|
||||
private static void onLike(TikTokLikeEvent e) {
|
||||
private static void onLike(LiveClient tikTokLive, TikTokLikeEvent e) {
|
||||
|
||||
print(e.getSender().getUniqueId(), "liked!");
|
||||
}
|
||||
|
||||
private static void onGiftMessage(TikTokGiftMessageEvent e) {
|
||||
private static void onGiftMessage(LiveClient tikTokLive, TikTokGiftMessageEvent e)
|
||||
{
|
||||
print(e.getSender().getUniqueId(), "sent", e.getAmount(), "x", e.getGift().getName());
|
||||
}
|
||||
|
||||
private static void onEmote(TikTokEmoteEvent e) {
|
||||
private static void onEmote(LiveClient tikTokLive, TikTokEmoteEvent e) {
|
||||
print(e.getUser().getUniqueId(), "sent", e.getEmoteId());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user