mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 08:49:40 -05:00
Breaking changes:
'Gift': changed from class to enum, so now you can handle
incoming gifts in switch
`Events`
- new:
onGiftComboFinished
- Removed:
onGiftBrodcast
- Rename:
onGiftMessage -> onGift
onRoomPinMessage -> onRoomPin
onRoomMessage -> onRoom
onLinkMessage -> onLink
onBarrageMessage -> onBarrage
onPollMessage -> onPoll
onShopMessage -> onShop
onDetectMessage -> onDetect
`GiftManager`
added:
registerGift
findById
findByName
getGifts
removed:
getActiveGifts
This commit is contained in:
@@ -1,3 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.data.events.common;
|
package io.github.jwdeveloper.tiktok.data.events.common;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,11 +35,11 @@ import lombok.Getter;
|
|||||||
*
|
*
|
||||||
* @see GiftSendType it has 3 states
|
* @see GiftSendType it has 3 states
|
||||||
*
|
*
|
||||||
* Example when user sends gift with combo
|
* <p>Example when user sends gift with combo</p>
|
||||||
* Combo: 1 -> comboState = GiftSendType.Begin
|
* <p>>Combo: 1 -> comboState = GiftSendType.Begin</p>
|
||||||
* Combo: 4 -> comboState = GiftSendType.Active
|
* <p>Combo: 4 -> comboState = GiftSendType.Active</p>
|
||||||
* Combo: 8 -> comboState = GiftSendType.Active
|
* <p>Combo: 8 -> comboState = GiftSendType.Active</p>
|
||||||
* Combo: 12 -> comboState = GiftSendType.Finsihed
|
* <p>Combo: 12 -> comboState = GiftSendType.Finsihed</p>
|
||||||
*
|
*
|
||||||
* Remember if comboState is Finsihed both TikTokGiftComboEvent and TikTokGiftEvent event gets triggered
|
* Remember if comboState is Finsihed both TikTokGiftComboEvent and TikTokGiftEvent event gets triggered
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public class Text {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getText() {
|
public String getText() {
|
||||||
return user.getDisplayName();
|
return user.getProfileName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.data.models.gifts;
|
package io.github.jwdeveloper.tiktok.data.models.gifts;
|
||||||
|
|
||||||
public enum GiftSendType
|
public enum GiftSendType
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import io.github.jwdeveloper.tiktok.data.models.Picture;
|
|||||||
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastEnvelopeMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastEnvelopeMessage;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -38,7 +37,7 @@ import java.util.Set;
|
|||||||
public class User {
|
public class User {
|
||||||
private final Long id;
|
private final Long id;
|
||||||
private final String name;
|
private final String name;
|
||||||
private String displayName;
|
private String profileName;
|
||||||
private Picture picture;
|
private Picture picture;
|
||||||
private long following;
|
private long following;
|
||||||
private long followers;
|
private long followers;
|
||||||
@@ -124,7 +123,7 @@ public class User {
|
|||||||
|
|
||||||
public User(io.github.jwdeveloper.tiktok.messages.data.User user) {
|
public User(io.github.jwdeveloper.tiktok.messages.data.User user) {
|
||||||
this(user.getId(), user.getDisplayId(), Picture.map(user.getAvatarThumb()));
|
this(user.getId(), user.getDisplayId(), Picture.map(user.getAvatarThumb()));
|
||||||
displayName = user.getNickname();
|
profileName = user.getNickname();
|
||||||
following = user.getFollowInfo().getFollowingCount();
|
following = user.getFollowInfo().getFollowingCount();
|
||||||
followers = user.getFollowInfo().getFollowerCount();
|
followers = user.getFollowInfo().getFollowerCount();
|
||||||
badges = user.getBadgeListList().stream().map(Badge::map).toList();
|
badges = user.getBadgeListList().stream().map(Badge::map).toList();
|
||||||
|
|||||||
@@ -1,3 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.utils;
|
package io.github.jwdeveloper.tiktok.utils;
|
||||||
|
|
||||||
public class Stopwatch {
|
public class Stopwatch {
|
||||||
|
|||||||
@@ -24,11 +24,7 @@
|
|||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.modelmapper</groupId>
|
|
||||||
<artifactId>modelmapper</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.protobuf</groupId>
|
<groupId>com.google.protobuf</groupId>
|
||||||
<artifactId>protobuf-java</artifactId>
|
<artifactId>protobuf-java</artifactId>
|
||||||
@@ -45,12 +41,7 @@
|
|||||||
<artifactId>Java-WebSocket</artifactId>
|
<artifactId>Java-WebSocket</artifactId>
|
||||||
<version>1.5.4</version>
|
<version>1.5.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-simple</artifactId>
|
|
||||||
<version>2.0.7</version>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.handlers.events;
|
package io.github.jwdeveloper.tiktok.handlers.events;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
|
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
|
||||||
|
|||||||
@@ -87,7 +87,9 @@ public class TikTokApiService {
|
|||||||
String html;
|
String html;
|
||||||
try {
|
try {
|
||||||
html = tiktokHttpClient.getLivestreamPage(userName);
|
html = tiktokHttpClient.getLivestreamPage(userName);
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
throw new TikTokLiveRequestException("Failed to fetch room id from WebCast, see stacktrace for more info.", e);
|
throw new TikTokLiveRequestException("Failed to fetch room id from WebCast, see stacktrace for more info.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.mappers;
|
package io.github.jwdeveloper.tiktok.mappers;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
|
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ import io.github.jwdeveloper.tiktok.utils.ConsoleColors;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class ListenerExample {
|
public class ListenerExample
|
||||||
|
{
|
||||||
|
// <code>
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Listeners are an alternative way of handling events.
|
* Listeners are an alternative way of handling events.
|
||||||
@@ -84,7 +86,7 @@ public class ListenerExample {
|
|||||||
public void onGift(LiveClient liveClient, TikTokGiftEvent event) {
|
public void onGift(LiveClient liveClient, TikTokGiftEvent event) {
|
||||||
var message = switch (event.getGift()) {
|
var message = switch (event.getGift()) {
|
||||||
case ROSE -> "Thanks :)";
|
case ROSE -> "Thanks :)";
|
||||||
case APPETIZERS -> ":$";
|
case APPETIZERS -> ":OO";
|
||||||
case APRIL -> ":D";
|
case APRIL -> ":D";
|
||||||
case TIKTOK -> ":P";
|
case TIKTOK -> ":P";
|
||||||
case CAP -> ":F";
|
case CAP -> ":F";
|
||||||
@@ -100,6 +102,7 @@ public class ListenerExample {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// </code>
|
||||||
private static void showLogo()
|
private static void showLogo()
|
||||||
{
|
{
|
||||||
System.out.println(ConsoleColors.GREEN+"""
|
System.out.println(ConsoleColors.GREEN+"""
|
||||||
|
|||||||
Binary file not shown.
@@ -48,7 +48,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<artifactId>Tools</artifactId>
|
<artifactId>Tools</artifactId>
|
||||||
<version>0.0.25-Release</version>
|
<version>${project.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class RunCollector {
|
|||||||
liveClientBuilder.onGift((liveClient, event) ->
|
liveClientBuilder.onGift((liveClient, event) ->
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
sb.append("GIFT User: " + event.getUser().getDisplayName()+" ");
|
sb.append("GIFT User: " + event.getUser().getProfileName()+" ");
|
||||||
sb.append("Name: " + event.getGift().name() + " ");
|
sb.append("Name: " + event.getGift().name() + " ");
|
||||||
sb.append("Combo: " + event.getCombo() + " ");
|
sb.append("Combo: " + event.getCombo() + " ");
|
||||||
System.out.println(sb.toString());
|
System.out.println(sb.toString());
|
||||||
@@ -67,7 +67,7 @@ public class RunCollector {
|
|||||||
liveClientBuilder.onGiftCombo((liveClient, event) ->
|
liveClientBuilder.onGiftCombo((liveClient, event) ->
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
sb.append("COMBO User: " + event.getUser().getDisplayName()+" ");
|
sb.append("COMBO User: " + event.getUser().getProfileName()+" ");
|
||||||
sb.append("Name: " + event.getGift().name() + " ");
|
sb.append("Name: " + event.getGift().name() + " ");
|
||||||
sb.append("Combo: " + event.getCombo() + " ");
|
sb.append("Combo: " + event.getCombo() + " ");
|
||||||
sb.append("Type: " + event.getComboState().name());
|
sb.append("Type: " + event.getComboState().name());
|
||||||
|
|||||||
Binary file not shown.
@@ -9,8 +9,6 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>Tools-EventsWebViewer</artifactId>
|
<artifactId>Tools-EventsWebViewer</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
<description>Demo project for Spring Boot</description>
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.javalin</groupId>
|
<groupId>io.javalin</groupId>
|
||||||
@@ -25,7 +23,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
<groupId>io.github.jwdeveloper.tiktok</groupId>
|
||||||
<artifactId>Tools-EventsCollector</artifactId>
|
<artifactId>Tools-EventsCollector</artifactId>
|
||||||
<version>0.0.25-Release</version>
|
<version>${project.version}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
@@ -22,15 +22,11 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok;
|
package io.github.jwdeveloper.tiktok;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.data.models.gifts.Gift;
|
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class CodeExample
|
public class CodeExample {
|
||||||
{
|
public static void main(String[] args) {
|
||||||
public static void main(String[] args)
|
|
||||||
{
|
|
||||||
TikTokLive.newClient("mrBeast")
|
TikTokLive.newClient("mrBeast")
|
||||||
.onGift((liveClient, event) ->
|
.onGift((liveClient, event) ->
|
||||||
{
|
{
|
||||||
@@ -40,36 +36,42 @@ public class CodeExample
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void codeExample() {
|
||||||
public static void codeExample()
|
// <code>
|
||||||
{
|
|
||||||
TikTokLive.newClient("bangbetmenygy")
|
TikTokLive.newClient("bangbetmenygy")
|
||||||
.onGift((liveClient, event) ->
|
.onGift((liveClient, event) ->
|
||||||
{
|
{
|
||||||
if(event.getGift() == Gift.ROSE)
|
String message = switch (event.getGift()) {
|
||||||
|
case ROSE -> "ROSE!";
|
||||||
|
case GG -> "GOOD GAME";
|
||||||
|
case TIKTOK -> "Ye";
|
||||||
|
case CORGI -> "Nice gift";
|
||||||
|
default -> "Thank you for " + event.getGift().getName();
|
||||||
|
};
|
||||||
|
System.out.println(event.getUser().getProfileName() + " sends " + message);
|
||||||
|
})
|
||||||
|
.onGiftCombo((liveClient, event) ->
|
||||||
{
|
{
|
||||||
liveClient.getLogger().info("Rose from "+event.getUser().getDisplayName());
|
System.out.println(event.getComboState()+ " " + event.getCombo() + " " + event.getGift().getName());
|
||||||
return;
|
|
||||||
}
|
|
||||||
liveClient.getLogger().info("Thank you for "+event.getGift().getName());
|
|
||||||
})
|
})
|
||||||
.onJoin((liveClient, event) ->
|
.onJoin((liveClient, event) ->
|
||||||
{
|
{
|
||||||
liveClient.getLogger().info("Hello "+event.getUser().getDisplayName());
|
System.out.println(event.getUser().getProfileName() + "Hello on my stream! ");
|
||||||
})
|
})
|
||||||
.onConnected((liveClient, event) ->
|
.onConnected((liveClient, event) ->
|
||||||
{
|
{
|
||||||
liveClient.getLogger().info("Connected to live ");
|
System.out.println("Connected to live ");
|
||||||
})
|
})
|
||||||
.onError((liveClient, event) ->
|
.onError((liveClient, event) ->
|
||||||
{
|
{
|
||||||
liveClient.getLogger().info("ERROR! "+event.getException().getMessage());
|
System.out.println("Error! " + event.getException().getMessage());
|
||||||
})
|
})
|
||||||
.buildAndConnect();
|
.buildAndConnect();
|
||||||
|
// </code>
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void configExample()
|
public static void configExample() {
|
||||||
{
|
// <code>
|
||||||
TikTokLive.newClient("bangbetmenygy")
|
TikTokLive.newClient("bangbetmenygy")
|
||||||
.configure((settings) ->
|
.configure((settings) ->
|
||||||
{
|
{
|
||||||
@@ -92,6 +94,7 @@ public class CodeExample
|
|||||||
settings.setRoomId("XXXXXXXXXXXXXXXXX");
|
settings.setRoomId("XXXXXXXXXXXXXXXXX");
|
||||||
})
|
})
|
||||||
.buildAndConnect();
|
.buildAndConnect();
|
||||||
|
// </code>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.utils.FilesUtility;
|
||||||
|
import io.github.jwdeveloper.tiktok.utils.TemplateUtility;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class CodeExamplesGenerator {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
var result = new CodeExamplesGenerator().run();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String run() {
|
||||||
|
|
||||||
|
var content = FilesUtility.loadFileContent("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\Tools-ReadmeGenerator\\src\\main\\java\\io\\github\\jwdeveloper\\tiktok\\CodeExample.java");
|
||||||
|
var p = "<code>(.*?)</code>";
|
||||||
|
var r = Pattern.compile(p, Pattern.DOTALL);
|
||||||
|
var m = r.matcher(content);
|
||||||
|
|
||||||
|
|
||||||
|
var pattern = """
|
||||||
|
```java
|
||||||
|
{{code}}
|
||||||
|
```
|
||||||
|
3. Configure (optional)
|
||||||
|
|
||||||
|
```java
|
||||||
|
{{config}}
|
||||||
|
```
|
||||||
|
""";
|
||||||
|
|
||||||
|
|
||||||
|
var values = new HashMap<String, Object>();
|
||||||
|
m.find();
|
||||||
|
var code = m.group(0)
|
||||||
|
.replace("<code>", "")
|
||||||
|
.replace("// </code>", "")
|
||||||
|
.replaceAll("(?m)^ {8}", "");
|
||||||
|
values.put("code", code);
|
||||||
|
|
||||||
|
m.find();
|
||||||
|
values.put("config", m.group(1));
|
||||||
|
var result = TemplateUtility.generateTemplate(pattern, values);
|
||||||
|
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -82,11 +82,15 @@ public class EventsInfoGenerator {
|
|||||||
variables.put("method-name", dto.getMethodName());
|
variables.put("method-name", dto.getMethodName());
|
||||||
variables.put("content", doc);
|
variables.put("content", doc);
|
||||||
variables.put("event-name", dto.getEventClazz().getSimpleName());
|
variables.put("event-name", dto.getEventClazz().getSimpleName());
|
||||||
|
|
||||||
|
var baseUrl = "https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/";
|
||||||
|
baseUrl += dto.getEventClazz().getPackageName().replace(".","/");
|
||||||
|
baseUrl += "/"+dto.getEventClazz().getSimpleName()+".java";
|
||||||
|
variables.put("event-file-url",baseUrl);
|
||||||
var temp = """
|
var temp = """
|
||||||
|
|
||||||
|
|
||||||
|
## {{method-name}} [{{event-name}}]({{event-file-url}})
|
||||||
## {{method-name}} [{{event-name}}](https://github.com/jwdeveloper/TikTok-Live-Java/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/events/messages.java)
|
|
||||||
|
|
||||||
{{content}}
|
{{content}}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
* a copy of this software and associated documentation files (the
|
||||||
|
* "Software"), to deal in the Software without restriction, including
|
||||||
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
* permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
* the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package io.github.jwdeveloper.tiktok;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.utils.FilesUtility;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class ListenerExampleGenerator
|
||||||
|
{
|
||||||
|
public static void main(String[] arg)
|
||||||
|
{
|
||||||
|
var result = new ListenerExampleGenerator();
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String run()
|
||||||
|
{
|
||||||
|
var content = FilesUtility.loadFileContent("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\Examples\\src\\main\\java\\io\\github\\jwdeveloper\\tiktok\\ListenerExample.java");
|
||||||
|
var p = "<code>(.*?)</code>";
|
||||||
|
var r = Pattern.compile(p, Pattern.DOTALL);
|
||||||
|
var m = r.matcher(content);
|
||||||
|
m.find();
|
||||||
|
return m.group(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,48 +26,38 @@ import io.github.jwdeveloper.tiktok.utils.FilesUtility;
|
|||||||
import io.github.jwdeveloper.tiktok.utils.TemplateUtility;
|
import io.github.jwdeveloper.tiktok.utils.TemplateUtility;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class ReadmeGenerator
|
public class ReadmeGenerator {
|
||||||
{
|
public static void main(String[] args) {
|
||||||
public static void main(String[] args)
|
|
||||||
{
|
|
||||||
var generator = new ReadmeGenerator();
|
var generator = new ReadmeGenerator();
|
||||||
generator.generate();
|
generator.generate();
|
||||||
|
|
||||||
}
|
}
|
||||||
public void generate()
|
|
||||||
{
|
public void generate() {
|
||||||
var template = FilesUtility.getFileFromResource(ReadmeGenerator.class,"template.md");
|
var template = FilesUtility.getFileFromResource(ReadmeGenerator.class, "template.md");
|
||||||
var variables = new HashMap<String,Object>();
|
var variables = new HashMap<String, Object>();
|
||||||
|
|
||||||
variables.put("version", getCurrentVersion());
|
variables.put("version", getCurrentVersion());
|
||||||
|
variables.put("code-content", new CodeExamplesGenerator().run());
|
||||||
var exampleCodePath = "C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\Examples\\src\\main\\java\\io\\github\\jwdeveloper\\tiktok\\SimpleExample.java";
|
|
||||||
variables.put("code-content", getCodeExample(exampleCodePath));
|
|
||||||
|
|
||||||
variables.put("events-content", new EventsInfoGenerator().run());
|
variables.put("events-content", new EventsInfoGenerator().run());
|
||||||
|
variables.put("listener-content",new ListenerExampleGenerator().run());
|
||||||
var listenerExamplePath = "C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\Examples\\src\\main\\java\\io\\github\\jwdeveloper\\tiktok\\ListenerExample.java";
|
|
||||||
// variables.put("listener-content", getCodeExample(listenerExamplePath));
|
|
||||||
|
|
||||||
|
|
||||||
template = TemplateUtility.generateTemplate(template, variables);
|
template = TemplateUtility.generateTemplate(template, variables);
|
||||||
var outputPath = "C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\Tools-ReadmeGenerator\\src\\main\\resources\\output.md";
|
var outputPath = "C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\Tools-ReadmeGenerator\\src\\main\\resources\\output.md";
|
||||||
FilesUtility.saveFile(outputPath, template);
|
FilesUtility.saveFile(outputPath, template);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCurrentVersion()
|
public String getCurrentVersion() {
|
||||||
{
|
var version = System.getenv("version");
|
||||||
var version = System.getenv("version");;
|
;
|
||||||
|
|
||||||
return version == null?"NOT_FOUND":version;
|
return version == null ? "NOT_FOUND" : version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCodeExample(String path)
|
public String getCodeExample(String path) {
|
||||||
{
|
|
||||||
var content = FilesUtility.loadFileContent(path);
|
var content = FilesUtility.loadFileContent(path);
|
||||||
content = content.substring(content.indexOf("*/")+2);
|
content = content.substring(content.indexOf("*/") + 2);
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
# Introduction
|
# Introduction
|
||||||
A Java library inspired by [TikTokLive](https://github.com/isaackogan/TikTokLive) and [TikTokLiveSharp](https://github.com/sebheron/TikTokLiveSharp). Use it to receive live stream events such as comments and gifts in realtime from [TikTok LIVE](https://www.tiktok.com/live) by connecting to TikTok's internal WebCast push service.
|
A Java library inspired by [TikTokLive](https://github.com/isaackogan/TikTokLive) and [TikTokLiveSharp](https://github.com/frankvHoof93/TikTokLiveSharp). Use it to receive live stream events such as comments and gifts in realtime from [TikTok LIVE](https://www.tiktok.com/live) by connecting to TikTok's internal WebCast push service.
|
||||||
The library includes a wrapper that connects to the WebCast service using just the username (`uniqueId`). This allows you to connect to your own live chat as well as the live chat of other streamers.
|
The library includes a wrapper that connects to the WebCast service using just the username (`uniqueId`). This allows you to connect to your own live chat as well as the live chat of other streamers.
|
||||||
No credentials are required. Events such as [Members Joining](#member), [Gifts](#gift), [Subscriptions](#subscribe), [Viewers](#roomuser), [Follows](#social), [Shares](#social), [Questions](#questionnew), [Likes](#like) and [Battles](#linkmicbattle) can be tracked.
|
No credentials are required. Events such as [Members Joining](#member), [Gifts](#gift), [Subscriptions](#subscribe), [Viewers](#roomuser), [Follows](#social), [Shares](#social), [Questions](#questionnew), [Likes](#like) and [Battles](#linkmicbattle) can be tracked.
|
||||||
|
|
||||||
@@ -45,9 +45,8 @@ Do you prefer other programming languages?
|
|||||||
|
|
||||||
#### Overview
|
#### Overview
|
||||||
- [Getting started](#getting-started)
|
- [Getting started](#getting-started)
|
||||||
- [Configuration](#configuration)
|
|
||||||
- [Methods](#methods)
|
|
||||||
- [Events](#events)
|
- [Events](#events)
|
||||||
|
- [Listeners](#listeners)
|
||||||
- [Contributing](#contributing)
|
- [Contributing](#contributing)
|
||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
@@ -74,20 +73,20 @@ Do you prefer other programming languages?
|
|||||||
|
|
||||||
2. Create your first chat connection
|
2. Create your first chat connection
|
||||||
|
|
||||||
```java
|
|
||||||
{{code-content}}
|
{{code-content}}
|
||||||
```
|
|
||||||
## Events
|
## Events
|
||||||
|
|
||||||
{{events-content}}
|
{{events-content}}
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## Listener Example
|
## Listeners
|
||||||
|
|
||||||
```java
|
```java
|
||||||
{{listener-content}}
|
{{listener-content}}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
Your improvements are welcome! Feel free to open an <a href="https://github.com/jwdeveloper/TikTok-Live-Java/issues">issue</a> or <a href="https://github.com/jwdeveloper/TikTok-Live-Java/pulls">pull request</a>.
|
Your improvements are welcome! Feel free to open an <a href="https://github.com/jwdeveloper/TikTok-Live-Java/issues">issue</a> or <a href="https://github.com/jwdeveloper/TikTok-Live-Java/pulls">pull request</a>.
|
||||||
|
|||||||
Reference in New Issue
Block a user