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>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.32</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- WebSocket server (Java-WebSocket) -->
|
||||
<dependency>
|
||||
<groupId>org.java-websocket</groupId>
|
||||
|
||||
@@ -82,11 +82,18 @@ public class Main {
|
||||
username = username.substring(1);
|
||||
}
|
||||
try { // Add this try block
|
||||
TikTokLiveClient client = new TikTokLiveClientBuilder(username)
|
||||
LiveClient client = new TikTokLiveClientBuilder(username)
|
||||
.build();
|
||||
|
||||
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
|
||||
// while (client.getConnectionState() != ConnectionState.CONNECTED) {
|
||||
// Thread.sleep(500);
|
||||
|
||||
@@ -2,7 +2,16 @@
|
||||
// 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.
|
||||
|
||||
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.HashMap;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class TikTokEventListener {
|
||||
@@ -53,41 +62,41 @@ public class TikTokEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
public void onFollow(String userInfo) {
|
||||
Map<String, String> vars = new java.util.HashMap<>();
|
||||
vars.put("userinfo", userInfo);
|
||||
public void handleFollowEvent(LiveClient liveClient, TikTokFollowEvent event) {
|
||||
Map<String, String> vars = new HashMap<>();
|
||||
vars.put("userinfo", event.getUser().getUniqueId());
|
||||
String filePath = getOutputPath("follow");
|
||||
output("follow", vars, filePath);
|
||||
}
|
||||
|
||||
public void onLike(String userInfo, int amount) {
|
||||
Map<String, String> vars = new java.util.HashMap<>();
|
||||
vars.put("userinfo", userInfo);
|
||||
vars.put("amount", String.valueOf(amount));
|
||||
public void handleLikeEvent(LiveClient liveClient, TikTokLikeEvent event) {
|
||||
Map<String, String> vars = new HashMap<>();
|
||||
vars.put("userinfo", event.getUser().getUniqueId());
|
||||
vars.put("amount", String.valueOf(event.getLikes())); // Assuming getLikes() for TikTokLikeEvent
|
||||
String filePath = getOutputPath("likes");
|
||||
output("likes", vars, filePath);
|
||||
}
|
||||
|
||||
public void onShare(String userInfo) {
|
||||
Map<String, String> vars = new java.util.HashMap<>();
|
||||
vars.put("userinfo", userInfo);
|
||||
public void handleShareEvent(LiveClient liveClient, TikTokShareEvent event) {
|
||||
Map<String, String> vars = new HashMap<>();
|
||||
vars.put("userinfo", event.getUser().getUniqueId());
|
||||
String filePath = getOutputPath("shares");
|
||||
output("shares", vars, filePath);
|
||||
}
|
||||
|
||||
public void onGift(String userInfo, String giftName, int amount) {
|
||||
Map<String, String> vars = new java.util.HashMap<>();
|
||||
vars.put("userinfo", userInfo);
|
||||
vars.put("gift_name", giftName);
|
||||
vars.put("amount", String.valueOf(amount));
|
||||
public void handleGiftEvent(LiveClient liveClient, TikTokGiftEvent event) {
|
||||
Map<String, String> vars = new HashMap<>();
|
||||
vars.put("userinfo", event.getUser().getUniqueId());
|
||||
vars.put("gift_name", event.getGift().getName()); // Assuming getGift().getName() for gift name
|
||||
vars.put("amount", String.valueOf(event.getGift().getCount())); // Assuming getGift().getCount() for amount
|
||||
String filePath = getOutputPath("gifts");
|
||||
output("gifts", vars, filePath);
|
||||
}
|
||||
|
||||
public void onChat(String userInfo, String message) {
|
||||
Map<String, String> vars = new java.util.HashMap<>();
|
||||
vars.put("userinfo", userInfo);
|
||||
vars.put("msg", message);
|
||||
public void handleChatEvent(LiveClient liveClient, TikTokChatMessageEvent event) {
|
||||
Map<String, String> vars = new HashMap<>();
|
||||
vars.put("userinfo", event.getUser().getUniqueId());
|
||||
vars.put("msg", event.getMessage());
|
||||
String filePath = getOutputPath("chat");
|
||||
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