upload
This commit is contained in:
81
config.yml.example
Normal file
81
config.yml.example
Normal file
@@ -0,0 +1,81 @@
|
||||
# tiktok username to follow
|
||||
TIKTOK_USERNAME: '@tiktok'
|
||||
|
||||
websocket_port: 3000 # Requires program restart to take effect
|
||||
|
||||
events: true
|
||||
follow: true
|
||||
ws_enable: true
|
||||
profile_img: true
|
||||
userinfo: true
|
||||
user_style: username
|
||||
file_enable: true
|
||||
profile_img: true
|
||||
userinfo: true
|
||||
user_style: username
|
||||
output_path: 'C:\Users\Darrin DeYoung\Desktop\Tiktok\Follows'
|
||||
cli_enable: true
|
||||
userinfo: true
|
||||
user_style: username
|
||||
likes: true
|
||||
ws_enable: true
|
||||
profile_img: true
|
||||
userinfo: true
|
||||
user_style: username
|
||||
amount: true
|
||||
file_enable: true
|
||||
profile_img: true
|
||||
userinfo: true
|
||||
user_style: username
|
||||
amount: true
|
||||
output_path: 'C:\Users\Darrin DeYoung\Desktop\Tiktok\Likes'
|
||||
cli_enable: true
|
||||
userinfo: true
|
||||
user_style: username
|
||||
amount: true
|
||||
shares: true
|
||||
ws_enable: true
|
||||
profile_img: true
|
||||
userinfo: true
|
||||
user_style: username
|
||||
file_enable: true
|
||||
profile_img: true
|
||||
userinfo: true
|
||||
user_style: username
|
||||
output_path: 'C:\Users\Darrin DeYoung\Desktop\Tiktok\Shares'
|
||||
cli_enable: true
|
||||
userinfo: true
|
||||
user_style: username
|
||||
follower_only_share: true
|
||||
gifts: true
|
||||
ws_enable: true
|
||||
profile_img: true
|
||||
userinfo: true
|
||||
user_style: username
|
||||
gift_name: true
|
||||
amount: true
|
||||
file_enable: true
|
||||
profile_img: true
|
||||
userinfo: true
|
||||
user_style: username
|
||||
gift_name: true
|
||||
amount: true
|
||||
output_path: 'C:\Users\Darrin DeYoung\Desktop\Tiktok\Gifts'
|
||||
cli_enable: true
|
||||
userinfo: true
|
||||
user_style: username
|
||||
gift_name: true
|
||||
amount: true
|
||||
chat: true
|
||||
ws_enable: true
|
||||
profile_img: true
|
||||
userinfo: true
|
||||
user_style: username
|
||||
file_enable: false
|
||||
profile_img: false
|
||||
userinfo: false
|
||||
user_style: username
|
||||
output_path: 'C:\Users\Darrin DeYoung\Desktop\Tiktok\Chat'
|
||||
cli_enable: true
|
||||
userinfo: true
|
||||
user_style: username
|
||||
26
format.yml.example
Normal file
26
format.yml.example
Normal file
@@ -0,0 +1,26 @@
|
||||
events:
|
||||
follow:
|
||||
file_format:
|
||||
text: $userinfo followed
|
||||
cli_format:
|
||||
text: $date | $time | $userinfo | Follow
|
||||
likes:
|
||||
file_format:
|
||||
text: $userinfo liked $amount
|
||||
cli_format:
|
||||
text: $date | $time | $userinfo | Likes x$amount
|
||||
shares:
|
||||
file_format:
|
||||
text: $userinfo Shared
|
||||
cli_format:
|
||||
text: $date | $time | $userinfo | Shared
|
||||
gifts:
|
||||
file_format:
|
||||
text: $userinfo sent x$amount $gift_name
|
||||
cli_format:
|
||||
text: $date | $time | $userinfo | x$amount $gift_name
|
||||
chat:
|
||||
file_format:
|
||||
text: $userinfo > $msg
|
||||
cli_format:
|
||||
text: $date | $time | $userinfo | Message > $msg
|
||||
39
info.txt
Normal file
39
info.txt
Normal file
@@ -0,0 +1,39 @@
|
||||
This is a Java maven application you will design It shall work with Java 17 and higher There will be no interface it will run strictly in console
|
||||
|
||||
|
||||
|
||||
1. https://github.com/zerodytrash/TikTok-Live-Connector
|
||||
|
||||
2. https://github.com/vortisrd/chatrd
|
||||
|
||||
3. https://streamer.bot/
|
||||
|
||||
4. needs a "config.yml" For all its configuration
|
||||
|
||||
5. It needs to have the ability to run a websocket server to allow the two things from numbers 2 and 3 to be able to connect to it
|
||||
a. It will also output every event to a file for each type of event listed in step 6
|
||||
|
||||
6. It will have features like But be completely free it does not need GUI Everything will be in the config It will default to everything being enabled Events that it will listen for are as follows
|
||||
a. Follows
|
||||
b. Likes
|
||||
c. shares
|
||||
d. gifts
|
||||
e. comments or messages (what TicTok calls them I call it live chat)
|
||||
|
||||
7. when first ran it will ask for oh the Tic tac user is to be followed or watched the user must include the Symbol "@" And their username in order to follow them
|
||||
|
||||
8. Also when it is first run it will ask what websocket port would it like to use (ie ipaddress:3000)
|
||||
a. The default port if there is no config file will be 3000
|
||||
|
||||
9. It will listen on all interfaces not just localhost
|
||||
|
||||
10. If a "config.yml" They exist in the same folder as the jar file It will use the information from that file or what it is doing
|
||||
|
||||
11. If there are any dependencies that are required you will prompt me with a URL to download the dependency If I cannot find the one you are requesting and I find one that is newer I will download that and place it in a folder labeled "lib"
|
||||
a. If what you wrote does not match and work or what I downloaded you will tweak it to work for it as such
|
||||
|
||||
12. YOU WILL NOT RUN ANY TESTS WITHOUT USER AUTHORIZATION
|
||||
|
||||
13. All events that are running at the application monitors will show up in the console
|
||||
|
||||
14. You will have an example config.yml.example file to understand how I want it to look and a format.yml.example file Which will show you how I want it to look you will not deviate from that example
|
||||
53
pom.xml
Normal file
53
pom.xml
Normal file
@@ -0,0 +1,53 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.smartcraftmedia</groupId>
|
||||
<artifactId>tiktok-live-event-stream-data</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- WebSocket server (Java-WebSocket) -->
|
||||
<dependency>
|
||||
<groupId>org.java-websocket</groupId>
|
||||
<artifactId>Java-WebSocket</artifactId>
|
||||
<version>1.5.4</version>
|
||||
</dependency>
|
||||
<!-- SnakeYAML for YAML config -->
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
<!-- Logging -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>2.0.12</version>
|
||||
</dependency>
|
||||
<!-- TikTok-Live-Connector: User must provide/download the JAR and place in lib/ -->
|
||||
<!-- <dependency>
|
||||
<groupId>com.github.zerodytrash</groupId>
|
||||
<artifactId>TikTok-Live-Connector</artifactId>
|
||||
<version>latest</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/TikTok-Live-Connector.jar</systemPath>
|
||||
</dependency> -->
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
13
src/main/java/ConfigLoader.java
Normal file
13
src/main/java/ConfigLoader.java
Normal file
@@ -0,0 +1,13 @@
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public class ConfigLoader {
|
||||
public static Map<String, Object> loadConfig(String path) throws IOException {
|
||||
Yaml yaml = new Yaml();
|
||||
try (FileInputStream fis = new FileInputStream(path)) {
|
||||
return yaml.load(fis);
|
||||
}
|
||||
}
|
||||
}
|
||||
18
src/main/java/EventLogger.java
Normal file
18
src/main/java/EventLogger.java
Normal file
@@ -0,0 +1,18 @@
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class EventLogger {
|
||||
public static void logToFile(String path, String message) {
|
||||
try (FileWriter fw = new FileWriter(path, true)) {
|
||||
fw.write(message + System.lineSeparator());
|
||||
} catch (IOException e) {
|
||||
System.err.println("Failed to write event to file: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static String getTimestamp() {
|
||||
return LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
}
|
||||
7
src/main/java/EventType.java
Normal file
7
src/main/java/EventType.java
Normal file
@@ -0,0 +1,7 @@
|
||||
public enum EventType {
|
||||
FOLLOW,
|
||||
LIKE,
|
||||
SHARE,
|
||||
GIFT,
|
||||
CHAT
|
||||
}
|
||||
13
src/main/java/FormatLoader.java
Normal file
13
src/main/java/FormatLoader.java
Normal file
@@ -0,0 +1,13 @@
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public class FormatLoader {
|
||||
public static Map<String, Object> loadFormat(String path) throws IOException {
|
||||
Yaml yaml = new Yaml();
|
||||
try (FileInputStream fis = new FileInputStream(path)) {
|
||||
return yaml.load(fis);
|
||||
}
|
||||
}
|
||||
}
|
||||
66
src/main/java/Main.java
Normal file
66
src/main/java/Main.java
Normal file
@@ -0,0 +1,66 @@
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
// Check for config.yml
|
||||
File configFile = new File("config.yml");
|
||||
if (!configFile.exists()) {
|
||||
System.out.println("No config.yml found. Starting first-time setup...");
|
||||
firstTimeSetup();
|
||||
}
|
||||
|
||||
// Load config and format
|
||||
try {
|
||||
var config = ConfigLoader.loadConfig("config.yml");
|
||||
var format = FormatLoader.loadFormat("format.yml");
|
||||
|
||||
int port = (int) config.getOrDefault("websocket_port", 3000);
|
||||
WebSocketServerApp wsServer = new WebSocketServerApp(port);
|
||||
wsServer.start();
|
||||
System.out.println("WebSocket server running on port " + port);
|
||||
|
||||
// Initialize TikTok event listener (placeholder)
|
||||
TikTokEventListener tiktokListener = new TikTokEventListener();
|
||||
// TODO: Connect TikTok-Live-Connector and wire up event callbacks
|
||||
|
||||
// Placeholder: Simulate event
|
||||
tiktokListener.onFollow("@exampleuser");
|
||||
|
||||
} catch (Exception e) {
|
||||
System.err.println("Failed to load config or start server: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private static void firstTimeSetup() {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
String username;
|
||||
do {
|
||||
System.out.print("Enter the TikTok username to follow (include @): ");
|
||||
username = scanner.nextLine();
|
||||
} while (!username.startsWith("@"));
|
||||
|
||||
System.out.print("Enter websocket port (default 3000): ");
|
||||
String portInput = scanner.nextLine();
|
||||
int port = 3000;
|
||||
if (!portInput.isBlank()) {
|
||||
try {
|
||||
port = Integer.parseInt(portInput);
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("Invalid port. Using default 3000.");
|
||||
}
|
||||
}
|
||||
|
||||
// Write config.yml
|
||||
String config = "TIKTOK_USERNAME: '" + username + "'\nwebsocket_port: " + port + "\n";
|
||||
try {
|
||||
Files.writeString(Paths.get("config.yml"), config);
|
||||
System.out.println("config.yml created. Please edit it for more options as needed.");
|
||||
} catch (IOException e) {
|
||||
System.err.println("Failed to write config.yml: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
23
src/main/java/TikTokEventListener.java
Normal file
23
src/main/java/TikTokEventListener.java
Normal file
@@ -0,0 +1,23 @@
|
||||
// This is a placeholder for TikTok-Live-Connector integration.
|
||||
// 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.
|
||||
|
||||
public class TikTokEventListener {
|
||||
// TODO: Integrate with TikTok-Live-Connector and handle events
|
||||
// Example methods for event callbacks:
|
||||
public void onFollow(String userInfo) {
|
||||
// Handle follow event
|
||||
}
|
||||
public void onLike(String userInfo, int amount) {
|
||||
// Handle like event
|
||||
}
|
||||
public void onShare(String userInfo) {
|
||||
// Handle share event
|
||||
}
|
||||
public void onGift(String userInfo, String giftName, int amount) {
|
||||
// Handle gift event
|
||||
}
|
||||
public void onChat(String userInfo, String message) {
|
||||
// Handle chat event
|
||||
}
|
||||
}
|
||||
48
src/main/java/WebSocketServerApp.java
Normal file
48
src/main/java/WebSocketServerApp.java
Normal file
@@ -0,0 +1,48 @@
|
||||
import org.java_websocket.server.WebSocketServer;
|
||||
import org.java_websocket.WebSocket;
|
||||
import org.java_websocket.handshake.ClientHandshake;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class WebSocketServerApp extends WebSocketServer {
|
||||
private final Set<WebSocket> connections = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
public WebSocketServerApp(int port) {
|
||||
super(new InetSocketAddress(port));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpen(WebSocket conn, ClientHandshake handshake) {
|
||||
connections.add(conn);
|
||||
System.out.println("WebSocket client connected: " + conn.getRemoteSocketAddress());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
|
||||
connections.remove(conn);
|
||||
System.out.println("WebSocket client disconnected: " + conn.getRemoteSocketAddress());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(WebSocket conn, String message) {
|
||||
System.out.println("Received from client: " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(WebSocket conn, Exception ex) {
|
||||
System.err.println("WebSocket error: " + ex.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
System.out.println("WebSocket server started on " + getAddress());
|
||||
}
|
||||
|
||||
public void broadcastEvent(String event) {
|
||||
for (WebSocket conn : connections) {
|
||||
conn.send(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
10
src/main/resources/logback.xml
Normal file
10
src/main/resources/logback.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
BIN
target/classes/ConfigLoader.class
Normal file
BIN
target/classes/ConfigLoader.class
Normal file
Binary file not shown.
BIN
target/classes/EventLogger.class
Normal file
BIN
target/classes/EventLogger.class
Normal file
Binary file not shown.
BIN
target/classes/EventType.class
Normal file
BIN
target/classes/EventType.class
Normal file
Binary file not shown.
BIN
target/classes/FormatLoader.class
Normal file
BIN
target/classes/FormatLoader.class
Normal file
Binary file not shown.
BIN
target/classes/Main.class
Normal file
BIN
target/classes/Main.class
Normal file
Binary file not shown.
BIN
target/classes/TikTokEventListener.class
Normal file
BIN
target/classes/TikTokEventListener.class
Normal file
Binary file not shown.
BIN
target/classes/WebSocketServerApp.class
Normal file
BIN
target/classes/WebSocketServerApp.class
Normal file
Binary file not shown.
10
target/classes/logback.xml
Normal file
10
target/classes/logback.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user