I'm rate limited on Copilot and Google Gemini
Everything I try to do never works I hate big companies that want money
This commit is contained in:
7
pom.xml
7
pom.xml
@@ -18,6 +18,13 @@
|
|||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.32</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- WebSocket server (Java-WebSocket) -->
|
<!-- WebSocket server (Java-WebSocket) -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.java-websocket</groupId>
|
<groupId>org.java-websocket</groupId>
|
||||||
|
|||||||
@@ -82,11 +82,18 @@ public class Main {
|
|||||||
username = username.substring(1);
|
username = username.substring(1);
|
||||||
}
|
}
|
||||||
try { // Add this try block
|
try { // Add this try block
|
||||||
TikTokLiveClient client = new TikTokLiveClientBuilder(username)
|
LiveClient client = new TikTokLiveClientBuilder(username)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
client.connect();
|
client.connect();
|
||||||
|
|
||||||
|
// Register event handlers
|
||||||
|
client.on(io.github.jwdeveloper.tiktok.data.events.TikTokFollowEvent.class, tiktokListener::handleFollowEvent);
|
||||||
|
client.on(io.github.jwdeveloper.tiktok.data.events.TikTokLikeEvent.class, tiktokListener::handleLikeEvent);
|
||||||
|
client.on(io.github.jwdeveloper.tiktok.data.events.TikTokShareEvent.class, tiktokListener::handleShareEvent);
|
||||||
|
client.on(io.github.jwdeveloper.tiktok.data.events.TikTokGiftEvent.class, tiktokListener::handleGiftEvent);
|
||||||
|
client.on(io.github.jwdeveloper.tiktok.data.events.TikTokChatMessageEvent.class, tiktokListener::handleChatEvent);
|
||||||
|
|
||||||
// Optionally, wait for connection state
|
// Optionally, wait for connection state
|
||||||
// while (client.getConnectionState() != ConnectionState.CONNECTED) {
|
// while (client.getConnectionState() != ConnectionState.CONNECTED) {
|
||||||
// Thread.sleep(500);
|
// Thread.sleep(500);
|
||||||
|
|||||||
@@ -2,7 +2,16 @@
|
|||||||
// The actual implementation will require the TikTok-Live-Connector JAR in the lib folder.
|
// The actual implementation will require the TikTok-Live-Connector JAR in the lib folder.
|
||||||
// At test time, you will be provided with the download link and instructions.
|
// At test time, you will be provided with the download link and instructions.
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.TikTokLikeEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.TikTokGiftEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.TikTokFollowEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.TikTokShareEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.data.events.TikTokChatMessageEvent;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class TikTokEventListener {
|
public class TikTokEventListener {
|
||||||
@@ -53,41 +62,41 @@ public class TikTokEventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onFollow(String userInfo) {
|
public void handleFollowEvent(LiveClient liveClient, TikTokFollowEvent event) {
|
||||||
Map<String, String> vars = new java.util.HashMap<>();
|
Map<String, String> vars = new HashMap<>();
|
||||||
vars.put("userinfo", userInfo);
|
vars.put("userinfo", event.getUser().getUniqueId());
|
||||||
String filePath = getOutputPath("follow");
|
String filePath = getOutputPath("follow");
|
||||||
output("follow", vars, filePath);
|
output("follow", vars, filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLike(String userInfo, int amount) {
|
public void handleLikeEvent(LiveClient liveClient, TikTokLikeEvent event) {
|
||||||
Map<String, String> vars = new java.util.HashMap<>();
|
Map<String, String> vars = new HashMap<>();
|
||||||
vars.put("userinfo", userInfo);
|
vars.put("userinfo", event.getUser().getUniqueId());
|
||||||
vars.put("amount", String.valueOf(amount));
|
vars.put("amount", String.valueOf(event.getLikes())); // Assuming getLikes() for TikTokLikeEvent
|
||||||
String filePath = getOutputPath("likes");
|
String filePath = getOutputPath("likes");
|
||||||
output("likes", vars, filePath);
|
output("likes", vars, filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onShare(String userInfo) {
|
public void handleShareEvent(LiveClient liveClient, TikTokShareEvent event) {
|
||||||
Map<String, String> vars = new java.util.HashMap<>();
|
Map<String, String> vars = new HashMap<>();
|
||||||
vars.put("userinfo", userInfo);
|
vars.put("userinfo", event.getUser().getUniqueId());
|
||||||
String filePath = getOutputPath("shares");
|
String filePath = getOutputPath("shares");
|
||||||
output("shares", vars, filePath);
|
output("shares", vars, filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onGift(String userInfo, String giftName, int amount) {
|
public void handleGiftEvent(LiveClient liveClient, TikTokGiftEvent event) {
|
||||||
Map<String, String> vars = new java.util.HashMap<>();
|
Map<String, String> vars = new HashMap<>();
|
||||||
vars.put("userinfo", userInfo);
|
vars.put("userinfo", event.getUser().getUniqueId());
|
||||||
vars.put("gift_name", giftName);
|
vars.put("gift_name", event.getGift().getName()); // Assuming getGift().getName() for gift name
|
||||||
vars.put("amount", String.valueOf(amount));
|
vars.put("amount", String.valueOf(event.getGift().getCount())); // Assuming getGift().getCount() for amount
|
||||||
String filePath = getOutputPath("gifts");
|
String filePath = getOutputPath("gifts");
|
||||||
output("gifts", vars, filePath);
|
output("gifts", vars, filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onChat(String userInfo, String message) {
|
public void handleChatEvent(LiveClient liveClient, TikTokChatMessageEvent event) {
|
||||||
Map<String, String> vars = new java.util.HashMap<>();
|
Map<String, String> vars = new HashMap<>();
|
||||||
vars.put("userinfo", userInfo);
|
vars.put("userinfo", event.getUser().getUniqueId());
|
||||||
vars.put("msg", message);
|
vars.put("msg", event.getMessage());
|
||||||
String filePath = getOutputPath("chat");
|
String filePath = getOutputPath("chat");
|
||||||
output("chat", vars, filePath);
|
output("chat", vars, filePath);
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user