Compare commits

...

82 Commits

Author SHA1 Message Date
Jacek W
3231924f8f Merge pull request #40 from kohlerpop1/kohlerpop1-fixes-updates
Optimized a few methods when calling and using the Api!
2023-12-22 18:46:56 +01:00
kohlerpop1
ea525470e2 Revert to StringBuilder and stacking stream line! 2023-12-22 12:22:50 -05:00
kohlerpop1
b0bf4ac606 Added @Getter to Badge classes and toString methods! 2023-12-22 10:32:49 -05:00
kohlerpop1
0b9f1570d0 Optimized a few methods when calling and using the Api! 2023-12-21 21:40:11 -05:00
kohlerpop1
7a4c7fecbd Merge remote-tracking branch 'origin/kohlerpop1-fixes-updates' into kohlerpop1-fixes-updates 2023-12-20 14:27:46 -05:00
GitHub Action
0ae9068858 Update version in pom.xml 2023-12-20 19:27:06 +00:00
kohlerpop1
8905958207 Merge remote-tracking branch 'origin/kohlerpop1-fixes-updates' into kohlerpop1-fixes-updates
# Conflicts:
#	Tools-EventsCollector/src/main/java/io/github/jwdeveloper/tiktok/tools/tester/mockClient/mocks/ApiServiceMock.java
2023-12-20 14:26:01 -05:00
JW
c12f3cc4dc . 2023-12-20 20:24:33 +01:00
David Kohler
7402899f52 Merge branch 'jwdeveloper:master' into kohlerpop1-fixes-updates 2023-12-20 14:19:37 -05:00
kohlerpop1
1b8b150d61 Removed not needed @Override in ApiServiceMock! 2023-12-20 14:18:55 -05:00
Jacek W
b2305b7bed Merge pull request #39 from kohlerpop1/kohlerpop1-fixes-updates
Added startTime to LiveRoomInfo to determine when the stream started!
2023-12-20 20:17:00 +01:00
kohlerpop1
7b911838a2 Added startTime to LiveRoomInfo to determine when the stream started! 2023-12-20 14:07:53 -05:00
Jacek W
e44cb71869 Update README.md 2023-12-19 21:57:24 +01:00
GitHub Action
af8c689417 Update version in pom.xml 2023-12-19 20:53:26 +00:00
Jacek W
81ac92fb33 Merge pull request #37 from jwdeveloper/develop-1-0-12
Including toUser in TikTokGiftEvent
2023-12-19 21:51:06 +01:00
JW
34a78b5435 Including toUser in TikTokGiftEvent 2023-12-19 21:49:27 +01:00
Jacek W
534cb7906d Merge pull request #36 from jwdeveloper/develop-1-0-12
Develop 1 0 12
2023-12-19 21:43:07 +01:00
JW
0bb8edfe5c Including toUser in TikTokGiftEvent 2023-12-19 21:31:58 +01:00
JW
4979c1b27a Merge remote-tracking branch 'origin/master' 2023-12-19 21:30:31 +01:00
Jacek W
f7c8ffdaa5 Update README.md 2023-12-19 17:34:07 +01:00
GitHub Action
c1fda687d3 Update version in pom.xml 2023-12-19 16:31:06 +00:00
JW
05c49c4545 . 2023-12-19 17:29:16 +01:00
Jacek W
7d36f36cee Update README.md 2023-12-19 14:01:48 +01:00
GitHub Action
f8a716429d Update version in pom.xml 2023-12-19 12:58:59 +00:00
Jacek W
fee805f0ea Merge pull request #35 from jwdeveloper/develop-1-0-10
Develop 1 0 10
2023-12-19 13:57:08 +01:00
JW
1733102aff Changes:
- TikTokHttpResponseEvent
  - Fixed User attributes in CommentEvent
  - Redesign .onMapper method
2023-12-19 13:56:25 +01:00
JW
89f54d5976 Merge branch 'master' into develop-1-0-10 2023-12-19 13:56:19 +01:00
JW
39055b5f3a Merge branch 'master' into develop-1-0-10 2023-12-19 13:54:50 +01:00
Jacek W
cd9e9ead85 Merge pull request #34 from jwdeveloper/develop-1-0-10
Develop 1 0 10
2023-12-19 13:48:47 +01:00
JW
5a2d2d23f0 Changes:
- TikTokHttpResponseEvent
  - Fixed User attributes in CommentEvent
  - Redesign .onMapper method
2023-12-19 13:46:11 +01:00
JW
3eed982d6b Changes:
- TikTokHttpResponseEvent
  - Fixed User attributes in CommentEvent
  - Redesign .onMapper method
2023-12-19 04:01:06 +01:00
GitHub Action
385560de3a Update version in pom.xml 2023-12-18 21:58:15 +00:00
Jacek W
2e37b6627b Merge pull request #33 from kohlerpop1/kohlerpop1-fixes/updates
Updates to TikTokGiftEvent & grammar fixes!
2023-12-18 22:56:33 +01:00
kohlerpop1
c4f0d63b43 Add toUser to TikTokGiftEvent to determine the correct user receiving a gift!
Made grammar fix to collaboration.md and README.md!
2023-12-18 16:52:40 -05:00
Jacek W
15550ed703 Update README.md 2023-12-12 19:49:52 +01:00
GitHub Action
c7d84218f2 Update version in pom.xml 2023-12-12 18:49:13 +00:00
Jacek W
1ecd192539 Merge pull request #30 from jwdeveloper/develop-1-0-8
updated structure of WebcastLinkLayerMessage
in proto file
2023-12-12 19:47:35 +01:00
JW
d6c0d50ac3 Changes:
updated structure of WebcastLinkLayerMessage
  in proto file
2023-12-12 19:46:37 +01:00
Jacek W
b4997da0a8 Merge pull request #29 from jwdeveloper/develop-1-0-8
updated structure of WebcastLinkLayerMessage
in proto file
2023-12-12 19:39:51 +01:00
JW
82990665b8 Changes:
updated structure of WebcastLinkLayerMessage
  in proto file
2023-12-12 19:38:55 +01:00
Jacek W
155b47977d Update README.md 2023-12-12 13:04:51 +01:00
Jacek W
3e262773a4 Update README.md 2023-12-11 23:37:30 +01:00
GitHub Action
89fbeb848b Update version in pom.xml 2023-12-11 22:28:01 +00:00
JW
aa99c5929b Changes:
onCustomEvent() <- registering custom events
  onMapping() <-  custom mappings
  check out 'CustomMappingExample'

  more gifs has been added
  exceptions are more explicit
2023-12-11 23:24:52 +01:00
JW
4dd866c6cc Changes:
onCustomEvent() <- registering custom events
  onMapping() <-  custom mappings
  check out 'CustomMappingExample'

  more gifs has been added
  exceptions are more explicit
2023-12-11 23:22:38 +01:00
Jacek W
0d384f0fdc Merge pull request #28 from jwdeveloper/develop-1-0-7
Develop 1 0 7
2023-12-11 23:20:03 +01:00
JW
3832db111e Changes:
onCustomEvent() <- registering custom events
  onMapping() <-  custom mappings
  check out 'CustomMappingExample'

  more gifs has been added
  exceptions are more explicit
2023-12-11 23:18:40 +01:00
JW
46d5f15d3f . 2023-12-11 03:56:17 +01:00
Jacek W
4f3ec1c6d9 Update collaboration.md 2023-12-05 02:56:53 +01:00
Jacek W
31075e5f09 Update collaboration.md 2023-12-05 02:55:32 +01:00
Jacek W
33a3f7afb8 Update collaboration.md 2023-12-05 02:33:33 +01:00
Jacek W
6c888c5d5b Update collaboration.md 2023-12-05 02:32:42 +01:00
Jacek W
214aa3b1ff Update collaboration.md 2023-12-05 02:30:39 +01:00
Jacek W
3f2c9083d5 Update README.md 2023-12-05 02:24:25 +01:00
Jacek W
450014759c Update collaboration.md 2023-12-05 02:17:50 +01:00
Jacek W
790f568244 Update collaboration.md 2023-12-05 02:13:43 +01:00
JW
e3e0d8a88e Merge remote-tracking branch 'origin/master' 2023-12-05 01:43:34 +01:00
JW
e0136d0f3b Collaboration Guide 2023-12-05 01:43:26 +01:00
Jacek W
dd5ccbfb7f Update README.md 2023-11-14 18:48:58 +01:00
GitHub Action
110a4fab4c Update version in pom.xml 2023-11-14 17:48:13 +00:00
Jacek W
69a2a6a338 Merge pull request #18 from jwdeveloper/develop-1-0-6
Changes:
  fixed TikTokLive.isHostNameValid()
  fixed TikTokLive.isLiveOnline()
  
  those methods was not working in some regions
2023-11-14 18:46:28 +01:00
JW
530551763c Changes:
fixed TikTokLive.isHostNameValid()
  fixed TikTokLive.isLiveOnline()

  those methods was not working in some regions
2023-11-14 18:44:09 +01:00
GitHub Action
ca1827853a Update version in pom.xml 2023-11-13 23:09:58 +00:00
Jacek W
ea8c740faa Merge pull request #17 from jwdeveloper/develop-1-0-5
New Events
- onLiveUnpaused()
- onRoomInfo() triggered when LiveRoomInfo got updated

Removed:
- clientSettings.setHandleExistingEvents - onRoom Replaced with onRoomInfo event - onRoomUserInfo Replaced with onRoomInfo event

Gifts:
- onGift event was not triggered for the more expensive gifts
- onGiftCombo with more expensive gifts was stuck in the GiftSendType.Begin state

Fixed:
- setPrintToConsole(false) was not disabling logs
2023-11-14 00:08:34 +01:00
JW
1977cbe8dc Changes:
New Events
     -  onLiveUnpaused()
     -  onRoomInfo() triggered when LiveRoomInfo got updated

  Removed:
      - clientSettings.setHandleExistingEvents
      - onRoom  Replaced with onRoomInfo event
      - onRoomUserInfo  Replaced with onRoomInfo event

  Gifts:
    - onGift event was not triggered for the more expensive gifts
    - onGiftCombo with more expensive gifts was stuck in the GiftSendType.Begin state

  Fixed:
     - setPrintToConsole(false) was not disabling logs
2023-11-14 00:07:14 +01:00
Jacek W
c3a48c4d70 Update README.md 2023-11-10 22:29:53 +01:00
GitHub Action
2c51844fd9 Update version in pom.xml 2023-11-10 21:29:22 +00:00
Jacek W
8ff4236452 Merge pull request #16 from jwdeveloper/develop-1-0-4
Changes:
   Generated new Gifts Json
   
   TikTokLive.isLiveOnline() check if live if online
   TikTokLive.isLiveOnlineAsync()
   
   TikTokLive.isHostNameValid() check if hostName is correct
   TikTokLive.isHostNameValidAsync()
2023-11-10 22:28:01 +01:00
Jacek W
7817aeb652 Merge pull request #15 from jwdeveloper/develop-1-0-4
Changes:
   Generated new Gifts Json
   
   TikTokLive.isLiveOnline() check if live if online
   TikTokLive.isLiveOnlineAsync()
   
   TikTokLive.isHostNameValid() check if hostName is correct
   TikTokLive.isHostNameValidAsync()
2023-11-10 22:24:53 +01:00
JW
4c122ab754 Changes:
Generated new Gifts Json

   TikTokLive.isLiveOnline() check if live if online
   TikTokLive.isLiveOnlineAsync()

   TikTokLive.isHostNameValid() check if hostName is correct
   TikTokLive.isHostNameValidAsync()
2023-11-10 22:24:14 +01:00
JW
519c22de8e Changes:
Generated new Gifts Json

   TikTokLive.isLiveOnline() check if live if online
   TikTokLive.isLiveOnlineAsync()

   TikTokLive.isHostNameValid() check if hostName is correct
   TikTokLive.isHostNameValidAsync()
2023-11-10 22:20:40 +01:00
JW
6d268c42f1 Changes:
Generated new Gifts Json

   TikTokLive.isLiveOnline() new method for checking if live if online
   TikTokLive.isLiveOnlineAsync()
2023-11-10 22:05:01 +01:00
Jacek W
788653484f Update README.md 2023-10-24 22:02:36 +02:00
GitHub Action
6cebbf891d Update version in pom.xml 2023-10-24 20:01:26 +00:00
Jacek W
cc32648988 Merge pull request #10 from Prokac/disconnect-fix
THX
2023-10-24 21:58:49 +02:00
Lysinka
4c797724d3 Update TikTokLiveClient.java 2023-10-24 19:07:08 +02:00
Jacek W
6941107db8 Update README.md 2023-10-13 14:00:20 +02:00
GitHub Action
ed70799cd9 Update version in pom.xml 2023-10-13 11:59:25 +00:00
JW
e12b0901f7 Merge remote-tracking branch 'origin/master' 2023-10-13 13:57:16 +02:00
JW
563e9618e2 Bug fixed: Not all tests was passing 2023-10-13 13:57:08 +02:00
Jacek W
82112f0140 Update README.md 2023-10-12 15:19:42 +02:00
GitHub Action
77e30de5e1 Update version in pom.xml 2023-10-12 13:19:01 +00:00
181 changed files with 81135 additions and 9817 deletions

4
.gitignore vendored
View File

@@ -1,10 +1,10 @@
backend-infrastructure/.aws-sam
# Created by https://www.gitignore.io/api/osx,linux,python,windows,pycharm,visualstudiocode
*.db
### Linux ###
*~
.db
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

3
.idea/protoeditor.xml generated
View File

@@ -64,6 +64,9 @@
<ImportPathEntry>
<option name="location" value="file://$PROJECT_DIR$/API/src/main/proto" />
</ImportPathEntry>
<ImportPathEntry>
<option name="location" value="file://$USER_HOME$/AppData/Local/JetBrains/IntelliJIdea2022.3/protoeditor" />
</ImportPathEntry>
</list>
</option>
<option name="descriptorPath" value="google/protobuf/descriptor.proto" />

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>TikTokLiveJava</artifactId>
<groupId>io.github.jwdeveloper.tiktok</groupId>
<version>1.0.0-Release</version>
<version>1.0.13-Release</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>API</artifactId>

View File

@@ -52,16 +52,11 @@ public class ClientSettings {
*/
private Duration retryConnectionTimeout;
/**
* Whether to handle Events received from Room when Connecting
*/
private boolean handleExistingEvents;
/**
* Whether to print Logs to Console
*/
private boolean printToConsole;
private boolean printToConsole = true;
/**
* LoggingLevel for Logs
*/
@@ -69,7 +64,7 @@ public class ClientSettings {
/**
* Optional: Use it if you need to change TikTok live hostname in builder
* Optional: Use it if you need to change TikTok live hostname in builder
*/
private String hostName;

View File

@@ -57,7 +57,6 @@ public class Constants {
var clientSettings = new ClientSettings();
clientSettings.setTimeout(Duration.ofSeconds(DEFAULT_TIMEOUT));
clientSettings.setClientLanguage("en-US");
clientSettings.setHandleExistingEvents(true);
clientSettings.setRetryOnConnectionFailure(false);
clientSettings.setRetryConnectionTimeout(Duration.ofSeconds(1));
clientSettings.setPrintToConsole(false);

View File

@@ -30,3 +30,6 @@ public @interface EventMeta
{
EventType eventType();
}

View File

@@ -26,7 +26,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface TikTokEventHandler
public @interface TikTokEventObserver
{
}

View File

@@ -0,0 +1,36 @@
/*
* 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.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Value;
import java.time.Duration;
@Data
@AllArgsConstructor
public class MessageMetaData
{
private Duration handlingTime;
}

View File

@@ -0,0 +1,45 @@
/*
* 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.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class TikTokUserInfo
{
UserStatus userStatus;
String roomId;
long startTime;
public enum UserStatus
{
NotFound,
Offline,
LivePaused,
Live
}
}

View File

@@ -0,0 +1,43 @@
/*
* 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;
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
import io.github.jwdeveloper.tiktok.annotations.EventType;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
import io.github.jwdeveloper.tiktok.data.models.users.User;
import lombok.Data;
@Data
@EventMeta(eventType = EventType.Message)
public class CustomEvent extends TikTokHeaderEvent {
private final User user;
private final String title;
public CustomEvent(User user, String title) {
this.user = user;
this.title = title;
}
}

View File

@@ -47,11 +47,11 @@ public class TikTokCommentEvent extends TikTokHeaderEvent {
public TikTokCommentEvent(WebcastChatMessage msg) {
super(msg.getCommon());
user = User.map(msg.getUser());
user = User.map(msg.getUser(),msg.getUserIdentity());
text = msg.getContent();
visibleToSender = msg.getVisibleToSender();
getUserLanguage = msg.getContentLanguage();
mentionedUser = User.map(msg.getAtUser(),msg.getUserIdentity());
mentionedUser = User.map(msg.getAtUser());
pictures = msg.getEmotesListList().stream().map(e -> Picture.map(e.getEmote().getImage())).toList();
}
}

View File

@@ -34,18 +34,10 @@ import java.util.List;
@Getter
@EventMeta(eventType = EventType.Message)
public class TikTokLinkEvent extends TikTokHeaderEvent {
private final String token;
private User user;
private final List<User> otherUsers;
public TikTokLinkEvent(WebcastLinkMessage msg) {
super(msg.getCommon());
token = msg.getToken();
if (msg.getUser().getUser().hasUser()) {
user = new User(msg.getUser().getUser().getUser());
}
otherUsers = msg.getUser().getOtherUsersList().stream().map(e -> new User(e.getUser())).toList();
}
}

View File

@@ -0,0 +1,32 @@
/*
* 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;
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
import io.github.jwdeveloper.tiktok.annotations.EventType;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
@EventMeta(eventType = EventType.Message)
public class TikTokLiveUnpausedEvent extends TikTokEvent {
}

View File

@@ -26,7 +26,9 @@ import io.github.jwdeveloper.tiktok.annotations.EventMeta;
import io.github.jwdeveloper.tiktok.annotations.EventType;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
import io.github.jwdeveloper.tiktok.data.models.users.User;
import io.github.jwdeveloper.tiktok.data.models.users.UserAttribute;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastMemberMessage;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastSubNotifyMessage;
import lombok.Getter;
/**
@@ -34,16 +36,20 @@ import lombok.Getter;
*/
@Getter
@EventMeta(eventType = EventType.Message)
public class TikTokSubscribeEvent extends TikTokHeaderEvent {
private User user;
public class TikTokSubscribeEvent extends TikTokHeaderEvent
{
private final User user;
public TikTokSubscribeEvent(WebcastMemberMessage msg) {
super(msg.getCommon());
if(msg.hasUser())
{
user = new User(msg.getUser());
public TikTokSubscribeEvent(WebcastMemberMessage msg) {
super(msg.getCommon());
user = User.map(msg.getUser());
user.addAttribute(UserAttribute.Subscriber);
}
public TikTokSubscribeEvent(WebcastSubNotifyMessage msg) {
super(msg.getCommon());
user = User.map(msg.getUser());
user.addAttribute(UserAttribute.Subscriber);
}
}
}

View File

@@ -20,36 +20,52 @@
* 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.room;
package io.github.jwdeveloper.tiktok.data.events.envelop;
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
import io.github.jwdeveloper.tiktok.annotations.EventType;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
import io.github.jwdeveloper.tiktok.data.models.RankingUser;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastRoomUserSeqMessage;
import lombok.Getter;
import io.github.jwdeveloper.tiktok.data.models.Text;
import java.util.List;
import java.util.stream.Collectors;
import io.github.jwdeveloper.tiktok.data.models.chest.Chest;
import io.github.jwdeveloper.tiktok.data.models.users.User;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastEnvelopeMessage;
import lombok.Value;
import java.util.Date;
@Getter
@EventMeta(eventType = EventType.Message)
public class TikTokRoomUserInfoEvent extends TikTokHeaderEvent {
private final int totalUsers;
@Value
public class TikTokChestEvent extends TikTokHeaderEvent {
/**
* Only top 5 users in ranking has detailed data
* rest has only ID
* Chest target
*/
private final List<RankingUser> usersRanking;
public TikTokRoomUserInfoEvent(WebcastRoomUserSeqMessage msg) {
super(msg.getCommon());
totalUsers = msg.getTotalUser();
usersRanking = msg.getRanksListList().stream().map(RankingUser::new)
.sorted((ru1, ru2) -> Integer.compare(ru2.getScore(), ru1.getScore()))
.collect(Collectors.toList());
}
Chest chest;
/**
* User that send a chest
*/
User user;
/**
* Time when chest has been open
*/
Date openedAt;
public TikTokChestEvent(Chest chest, WebcastEnvelopeMessage msg) {
super(msg.getCommon());
this.chest = chest;
var text = Text.map(msg.getCommon().getDisplayText());
var userPiece = (Text.UserTextPiece) text.getTextPieces().get(0);
user = userPiece.getUser();
var envelopInfo = msg.getEnvelopeInfo();
openedAt = new Date(envelopInfo.getUnpackAt());
}
}

View File

@@ -26,6 +26,7 @@ import io.github.jwdeveloper.tiktok.annotations.EventMeta;
import io.github.jwdeveloper.tiktok.annotations.EventType;
import io.github.jwdeveloper.tiktok.data.models.gifts.Gift;
import io.github.jwdeveloper.tiktok.data.models.gifts.GiftSendType;
import io.github.jwdeveloper.tiktok.data.models.users.User;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
import lombok.Getter;
@@ -40,7 +41,7 @@ import lombok.Getter;
* <p>Combo: 4 -> comboState = GiftSendType.Active</p>
* <p>Combo: 8 -> comboState = GiftSendType.Active</p>
* <p>Combo: 12 -> comboState = GiftSendType.Finsihed</p>
*
* <p>
* Remember if comboState is Finsihed both TikTokGiftComboEvent and TikTokGiftEvent event gets triggered
*/
@EventMeta(eventType = EventType.Message)
@@ -48,8 +49,8 @@ import lombok.Getter;
public class TikTokGiftComboEvent extends TikTokGiftEvent {
private final GiftSendType comboState;
public TikTokGiftComboEvent(Gift gift, WebcastGiftMessage msg, GiftSendType comboState) {
super(gift, msg);
public TikTokGiftComboEvent(Gift gift, User host, WebcastGiftMessage msg, GiftSendType comboState) {
super(gift, host, msg);
this.comboState = comboState;
}
}

View File

@@ -26,28 +26,38 @@ package io.github.jwdeveloper.tiktok.data.events.gift;
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
import io.github.jwdeveloper.tiktok.annotations.EventType;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
import io.github.jwdeveloper.tiktok.data.models.Picture;
import io.github.jwdeveloper.tiktok.data.models.gifts.Gift;
import io.github.jwdeveloper.tiktok.data.models.gifts.GiftSendType;
import io.github.jwdeveloper.tiktok.data.models.users.User;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
import lombok.Getter;
import java.util.ArrayList;
/*
/**
* Triggered when user sends gifts that has
* no combo (most of expensive gifts)
* or if combo has finished
* no combo (most of expensive gifts)
* or if combo has finished
*/
@EventMeta(eventType = EventType.Message)
@Getter
public class TikTokGiftEvent extends TikTokHeaderEvent {
private final Gift gift;
private final User user;
private final User toUser;
private final int combo;
public TikTokGiftEvent(Gift gift, WebcastGiftMessage msg) {
public TikTokGiftEvent(Gift gift, User liveHost, WebcastGiftMessage msg) {
super(msg.getCommon());
this.gift = gift;
user = User.map(msg.getUser(), msg.getUserIdentity());
if (msg.getToUser().getNickname().isEmpty()) {
toUser = liveHost;
} else {
toUser = User.map(msg.getToUser());
}
combo = msg.getComboCount();
}
}
}

View File

@@ -0,0 +1,42 @@
/*
* 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.http;
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
import io.github.jwdeveloper.tiktok.annotations.EventType;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.data.models.http.HttpData;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
@EventMeta(eventType = EventType.Debug)
public class TikTokHttpResponseEvent extends TikTokEvent
{
String url;
HttpData response;
HttpData request;
}

View File

@@ -1,67 +0,0 @@
/*
* 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.room;
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
import io.github.jwdeveloper.tiktok.annotations.EventType;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
import io.github.jwdeveloper.tiktok.data.models.users.User;
import io.github.jwdeveloper.tiktok.data.models.users.UserAttribute;
import io.github.jwdeveloper.tiktok.messages.webcast.RoomMessage;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLiveIntroMessage;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastRoomMessage;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastSystemMessage;
import lombok.Getter;
@Getter
@EventMeta(eventType = EventType.Message)
public class TikTokRoomEvent extends TikTokHeaderEvent
{
private User hostUser;
private String hostLanguage;
private final String welcomeMessage;
public TikTokRoomEvent(WebcastRoomMessage msg) {
super(msg.getCommon());
welcomeMessage = msg.getContent();
}
public TikTokRoomEvent(RoomMessage msg) {
super(msg.getCommon());
welcomeMessage = msg.getContent();
}
public TikTokRoomEvent(WebcastSystemMessage msg) {
super(msg.getCommon());
welcomeMessage = msg.getMessage();
}
public TikTokRoomEvent(WebcastLiveIntroMessage msg) {
super(msg.getCommon());
hostUser = User.map(msg.getHost());
hostUser.addAttribute(UserAttribute.LiveHost);
welcomeMessage = msg.getContent();
hostLanguage = msg.getLanguage();
}
}

View File

@@ -0,0 +1,42 @@
/*
* 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.room;
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
import io.github.jwdeveloper.tiktok.annotations.EventType;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.live.LiveRoomInfo;
import lombok.AllArgsConstructor;
import lombok.Getter;
/*
Triggered when LiveRoomInfo got updated such as likes, viewers, ranking ....
*/
@Getter
@AllArgsConstructor
@EventMeta(eventType = EventType.Message)
public class TikTokRoomInfoEvent extends TikTokEvent
{
LiveRoomInfo roomInfo;
}

View File

@@ -24,7 +24,9 @@ package io.github.jwdeveloper.tiktok.data.events.websocket;
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
import io.github.jwdeveloper.tiktok.annotations.EventType;
import io.github.jwdeveloper.tiktok.data.dto.MessageMetaData;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -34,22 +36,32 @@ import java.time.Duration;
/**
* Triggered every time a protobuf encoded webcast message arrives. You can deserialize the binary object depending on the use case.
* Triggered every time TikTok sends data. Data incoming as protobuf message.
* You can deserialize the binary object depending on the use case.
*/
@Getter
@AllArgsConstructor
@EventMeta(eventType = EventType.Debug)
public class TikTokWebsocketMessageEvent extends TikTokEvent
{
private TikTokEvent event;
public class TikTokWebsocketMessageEvent extends TikTokEvent {
/*
* Original message that is coming from TikTok
* message.method - Name of message type, for example "WebcastGiftMessage"
* message.payload - Bytes array that contains actual data of message.
* Example of parsing, WebcastGiftMessage giftMessage = WebcastGiftMessage.parseFrom(message.getPayload());
*/
private WebcastResponse.Message message;
private MetaData metaData;
/*
* TikTokLiveJava event that was created from TikTok message data
* Example: TikTokGiftEvent
*/
private TikTokEvent event;
/*
* Metadata information about mapping message to event, such as time and stuff
*/
private MessageMetaData metaData;
@Value
public static class MetaData
{
Duration handlingTime;
}
}

View File

@@ -39,4 +39,9 @@ public class TikTokWebsocketUnhandledMessageEvent extends TikTokUnhandledEvent<W
public TikTokWebsocketUnhandledMessageEvent(WebcastResponse.Message data) {
super(data);
}
public WebcastResponse.Message getMessage()
{
return this.getData();
}
}

View File

@@ -29,6 +29,7 @@ import lombok.Value;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.regex.Pattern;
@Getter
@@ -45,6 +46,12 @@ public class Text {
this.value = computeValue();
}
public <T extends TextPiece> Optional<TextPiece> getTextPiece(Class<T> type)
{
return textPieces.stream().filter(e -> e.getClass().equals(type)).findFirst();
}
public static Text map(io.github.jwdeveloper.tiktok.messages.data.Text input) {
var pieces = input.getPiecesListList().stream().map(Text::mapTextPiece).toList();
return new Text(input.getKey(), input.getDefaultPattern(), pieces);
@@ -98,6 +105,7 @@ public class Text {
}
}
@Value
public static class UserTextPiece extends TextPiece {
User user;

View File

@@ -24,19 +24,22 @@ package io.github.jwdeveloper.tiktok.data.models.badges;
import io.github.jwdeveloper.tiktok.data.models.Picture;
import io.github.jwdeveloper.tiktok.messages.data.BadgeStruct;
import lombok.Getter;
@Getter
public class CombineBadge extends Badge {
private final Picture picture;
private final String text;
private final String subText;
public CombineBadge(BadgeStruct.CombineBadge combineBadge) {
picture = Picture.map(combineBadge.getIcon());
text = combineBadge.getText().getDefaultPattern();
subText = combineBadge.getStr();
}
}
@Override
public String toString() {
return "CombineBadge{picture=" + picture +", text='" + text + "', subText='" + subText + "'}";
}
}

View File

@@ -24,12 +24,18 @@ package io.github.jwdeveloper.tiktok.data.models.badges;
import io.github.jwdeveloper.tiktok.data.models.Picture;
import io.github.jwdeveloper.tiktok.messages.data.BadgeStruct;
import lombok.Getter;
@Getter
public class PictureBadge extends Badge {
private final Picture picture;
public PictureBadge(BadgeStruct.ImageBadge imageBadge) {
public PictureBadge(BadgeStruct.ImageBadge imageBadge) {
picture = Picture.map(imageBadge.getImage());
}
}
@Override
public String toString() {
return "PictureBadge{picture=" + picture + "}";
}
}

View File

@@ -23,12 +23,18 @@
package io.github.jwdeveloper.tiktok.data.models.badges;
import io.github.jwdeveloper.tiktok.messages.data.BadgeStruct;
import lombok.Getter;
@Getter
public class StringBadge extends Badge {
private final String text;
public String text;
public StringBadge(BadgeStruct.StringBadge stringBadge) {
this.text = stringBadge.getStr();
}
}
@Override
public String toString() {
return "StringBadge{text='" + text + "'}";
}
}

View File

@@ -23,13 +23,18 @@
package io.github.jwdeveloper.tiktok.data.models.badges;
import io.github.jwdeveloper.tiktok.messages.data.BadgeStruct;
import lombok.Getter;
public class TextBadge extends Badge
{
@Getter
public class TextBadge extends Badge {
private final String text;
public TextBadge(BadgeStruct.TextBadge textBadge)
{
public TextBadge(BadgeStruct.TextBadge textBadge) {
this.text = textBadge.getDefaultPattern();
}
}
@Override
public String toString() {
return "TextBadge{text='" + text + "'}";
}
}

View File

@@ -0,0 +1,45 @@
/*
* 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.chest;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class Chest {
/**
* Total diamonds inside the chest
*/
int totalDiamonds;
/**
* Total users participated in chest
*/
int totalUsers;
}

View File

@@ -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.
*/
// This enum is generated
package io.github.jwdeveloper.tiktok.data.models.gifts;
@@ -9,13 +31,13 @@ import lombok.Getter;
public enum Gift {
UNDEFINED(-1, "undefined", -1, ""),
HEART(5480, "Heart", 10, "https://storage.streamdps.com/iblock/b7a/b7ae3af2d67d7b7708a69d765531712a/7a382fcc2e03076c9e4b089176de1395.webp"),
HEART(5480, "Heart", 10, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/98bea1b189fba75bf0ca766b4dc1976e.png~tplv-obj.jpg"),
HEART_5738(5738, "Heart", 200, "https://storage.streamdps.com/iblock/046/046417f5f825f44235c2ae98c56703a2/925cc55f3650d03ad58de6fa0edec143.png"),
HEART_6247(6247, "Heart", 1, "https://storage.streamdps.com/iblock/21d/21de8189873fc8550b8f19501effab4f/0be54b4cf3e40c52fca6be3f71220d69.png"),
HEART_6247(6247, "Heart", 1, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/dd300fd35a757d751301fba862a258f1~tplv-obj.jpg"),
INTERSTELLAR(6149, "Interstellar", 10000, "https://storage.streamdps.com/iblock/4e3/4e341b08230703a6f09ba3234c3fe717/3854ed8e881ebbe5208882602b30cf88.png"),
INTERSTELLAR(6149, "Interstellar", 10000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/8520d47b59c202a4534c1560a355ae06~tplv-obj.jpg"),
LOVE_CHAT(6205, "Love Chat", 400, "https://storage.streamdps.com/iblock/440/4402267722e227b72adc97db92504b75/ae0f562146e701f32ae96761ac67c5cc.png"),
@@ -33,9 +55,11 @@ public enum Gift {
PANTHER_PAWS_8358(8358, "Panther Paws", 199, "https://storage.streamdps.com/iblock/a25/a25d2409e1d851566987913c9fb9860f/6aeb9164cf39e2602933d28dbd106119.webp"),
GOLDEN_PARTY(9499, "Golden Party", 3000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/a00450f3e3aa1f01b62774950e5729c3.png~tplv-obj.jpg"),
SHOOTING_STARS(5753, "Shooting Stars", 1580, "https://storage.streamdps.com/iblock/b36/b36bb8c332ade25b2e591cd3ed164a99/a06c10f4dc562c24f4f5b6812b9fa01f.png"),
LION(6369, "Lion", 29999, "https://storage.streamdps.com/iblock/0c4/0c446fb276fafbb0f0d5e3abfedf2510/f4bbea9d03b1453bd37d571282334f1b.png"),
LION(6369, "Lion", 29999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/4fb89af2082a290b37d704e20f4fe729~tplv-obj.jpg"),
CAR_DRIFTING(8086, "Car Drifting", 3000, "https://storage.streamdps.com/iblock/4e5/4e537a5c27bc6be1887f40eb2995d38e/62635a8973c01d0a0330f778e5ba5872.webp"),
@@ -43,11 +67,13 @@ public enum Gift {
ENJOY_MUSIC(5685, "Enjoy Music", 1, "https://storage.streamdps.com/iblock/82b/82b1fc25e1aab4c5502c31bfd1c001d7/ce0e2cc4cecb12e0fc2938eb4871008c.webp"),
COOPER_FLIES_HOME(6862, "Cooper Flies Home", 1999, "https://storage.streamdps.com/iblock/778/7784f4e4b22c7acb8c90b9ccf4cfd71c/e3bb5fd549bc047912dda450fb714f84.webp"),
COOPER_FLIES_HOME(6862, "Cooper Flies Home", 1999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/3f1945b0d96e665a759f747e5e0cf7a9~tplv-obj.jpg"),
MAKE_UP_BOX(6033, "Make-up Box", 1999, "https://storage.streamdps.com/iblock/006/006d256121db1824975ae0f9f8a0fd1d/775b702c6935f6b7fc82fca6221d65b0.png"),
MAKE_UP_BOX(6033, "Make-up Box", 1999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/a29aa87203ec09c699e3dafa1944b23e~tplv-obj.jpg"),
LITTLE_CROWN(6097, "Little Crown", 99, "https://storage.streamdps.com/iblock/50d/50df20e691bbeeeb1c2faf03c2c86243/2b412c3b322b27cd9836bbe636ea2a1d.png"),
PLAY_SAMBA(5793, "Play Samba", 99, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/fd3d6cc127464bacded6ed009074ae2f~tplv-obj.png"),
LITTLE_CROWN(6097, "Little Crown", 99, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/cf3db11b94a975417043b53401d0afe1~tplv-obj.jpg"),
RUBY_RED(8434, "Ruby red", 88, "https://storage.streamdps.com/iblock/405/405fcf52a1de3d14ab9834c1f30cc330/0deed9ee2c79ba6bf2005b0ce667bf60.webp"),
@@ -81,7 +107,7 @@ public enum Gift {
GIVE_IT_ALL(6649, "Give It All", 1, "https://storage.streamdps.com/iblock/de8/de8468d1003361452021c2d4796bb0f6/574aa0cdd7b418a2a3af2ca4739e9e7f.webp"),
MARVELOUS_CONFETTI(7121, "Marvelous Confetti", 100, "https://storage.streamdps.com/iblock/a2e/a2e6e84d5786d5a4afb05d03cb76c519/cc8b527c9b83f76ee7fc314cc8cb80f6.webp"),
MARVELOUS_CONFETTI(7121, "Marvelous Confetti", 100, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/fccc851d351716bc8b34ec65786c727d~tplv-obj.jpg"),
PINKY_PROMISE(8810, "Pinky promise", 5, "https://storage.streamdps.com/iblock/686/6864e9132aa300e189e93054ad735407/fe1a1a4405f77f009f4a76a184bafc52.webp"),
@@ -93,25 +119,25 @@ public enum Gift {
WEIGHTS(5760, "Weights", 1, "https://storage.streamdps.com/iblock/d6f/d6f46242fd4f0396f5c5070ff960e83c/87884fe9998fea43e8aa56ecce15a541.png"),
RED_LIGHTNING(8419, "Red Lightning", 12000, "https://storage.streamdps.com/iblock/12a/12ac7db3c837f029beee318c45e3ad88/da93190dd1082f876b4461ec0924e453.webp"),
RED_LIGHTNING(8419, "Red Lightning", 12000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/5f48599c8d2a7bbc6e6fcf11ba2c809f~tplv-obj.jpg"),
GUACAMOLE(6519, "Guacamole", 6, "https://storage.streamdps.com/iblock/207/20793577805a0b4fe0efeb37cc0bd7d9/10e97510121def59e538f0290d2d751a.png"),
FINGER_HEART(5487, "Finger Heart", 5, "https://storage.streamdps.com/iblock/688/688f0c350f9cd9751cb02659f4ab105e/2b2d66c2f9767fc8332ee1b5ba0c1057.png"),
FINGER_HEART(5487, "Finger Heart", 5, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/a4c4dc437fd3a6632aba149769491f49.png~tplv-obj.jpg"),
COOPER_SWIMS_HOME(6863, "Cooper Swims Home", 3999, "https://storage.streamdps.com/iblock/493/4930e92e37637187f38ca100fa52b242/413beebb2e2c1a6f4640d73d3b6000d8.webp"),
RED_CARPET(6789, "Red Carpet", 1999, "https://storage.streamdps.com/iblock/bf1/bf11d2786cbcce31a9ba2f95982921be/4229588ababc215c9fab76e953647c89.webp"),
RED_CARPET(6789, "Red Carpet", 1999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/5b9bf90278f87b9ca0c286d3c8a12936~tplv-obj.jpg"),
CUPID(5236, "Cupid", 2888, "https://storage.streamdps.com/iblock/94f/94f6f0d4bfb3294395007ba45db34a54/e141809d2278e1ca80a5107bce4a16f6.png"),
MYSTERY_FIREWORK(7529, "Mystery Firework", 1999, "https://storage.streamdps.com/iblock/a53/a53a028b290673abcdaa7858e5753a99/666cd8c2e66d6fb004ca64c8112af989.webp"),
MYSTERY_FIREWORK(7529, "Mystery Firework", 1999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/c110230c5db903db5f060a432f5a86cd~tplv-obj.jpg"),
BUNGEO_PPANG(5644, "Bungeo-ppang", 1, "https://storage.streamdps.com/iblock/7af/7afe4a4d67c1343a2df4703537b897eb/cd51c9bbb8291363ea4189bd2370eb8c.png"),
SCENTED_CANDLE(7131, "Scented Candle", 20, "https://storage.streamdps.com/iblock/01f/01f4015c4cad98734c55ecd42824ace3/eb1d8dd998edd8f658c43c60d33b9904.webp"),
MOTORCYCLE(5765, "Motorcycle", 2988, "https://storage.streamdps.com/iblock/322/3226dd779addd06444ec9326eb25eb7c/0c6f14d291823969c916aa782c842d9a.png"),
MOTORCYCLE(5765, "Motorcycle", 2988, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/6517b8f2f76dc75ff0f4f73107f8780e~tplv-obj.jpg"),
DREAM_TEAM(7532, "Dream Team", 299, "https://storage.streamdps.com/iblock/252/2523636860d9336ab7cd149bbfb94533/b171f50afc37dc216144b4bc9ca259a1.webp"),
@@ -135,7 +161,7 @@ public enum Gift {
YELLOW_BUS(8263, "Yellow Bus", 6000, "https://storage.streamdps.com/iblock/88d/88df4387d65bcc77b691098fd649bd59/ad401a92ddba9aae15bb777f9f38638d.webp"),
ROSA_NEBULA(8912, "Rosa Nebula", 15000, "https://storage.streamdps.com/iblock/2d7/2d7dca6dc709e54b38336bedbd9eb06f/96de9ba917cf3f96bc15cb0f255b50c4.webp"),
ROSA_NEBULA(8912, "Rosa Nebula", 15000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/f722088231103b66875dae33f13f8719.png~tplv-obj.jpg"),
KISS(5284, "Kiss", 150, "https://storage.streamdps.com/iblock/d3d/d3df4a0ecebd25c21e7ce5a6f910f8f1/d9ce143ac4707f74d8b1fe4708a92ab3.png"),
@@ -151,11 +177,13 @@ public enum Gift {
LUCKY_PIG(7375, "Lucky Pig", 1, "https://storage.streamdps.com/iblock/bf8/bf8e32bd0bf5a916195b5848db571f4f/a9241b01b970aa44c2d5cea5e8ba69d6.webp"),
GARLAND_(5651, "Garland ", 1500, "https://storage.streamdps.com/iblock/2b7/2b715453ba05fa402edba017ac0c11a0/b31ad3573f6b4fe41e89e16f2615606d.png"),
GARLAND_(5651, "Garland ", 1500, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/69d7dadcd93942bad49d0b9874f69c1b~tplv-obj.jpg"),
COWBOY_HAT(8842, "Cowboy Hat", 199, "https://storage.streamdps.com/iblock/5f3/5f3df5eccbc82f458fdacd0f82d13e40/40980853c80e3da0e902a1db49ea9798.webp"),
SPORTS_CAR(6089, "Sports Car", 7000, "https://storage.streamdps.com/iblock/b61/b610a9669c8a833dfcc1d24c6ffef32a/a4fdb6b0c3a2efc75e09a0923976dd77.png"),
FESTA_JUNINA_S_HAT(8638, "Festa Junina's Hat", 199, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/61b32ccce11b289b3c1db7438dfb4450~tplv-obj.png"),
SPORTS_CAR(6089, "Sports Car", 7000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/e7ce188da898772f18aaffe49a7bd7db~tplv-obj.jpg"),
ICE_TEA(5464, "Ice Tea", 1, "https://storage.streamdps.com/iblock/531/5313a4ca89a7c7588a88898c8f1e9053/dab85392562772099474a050c251d340.png"),
@@ -165,7 +193,7 @@ public enum Gift {
WHALE_DIVING(6084, "Whale diving", 1750, "https://storage.streamdps.com/iblock/5b2/5b27c388fe0d4dbe0a5f0a44ba7a8410/602a5a7cf538240f48ccf47c13237aa2.png"),
WHALE_DIVING_6820(6820, "Whale diving", 2150, "https://storage.streamdps.com/iblock/db2/db286be21ff2672b6e825a883c8c3e8f/ab9021773e219665f526cee02252f936.webp"),
WHALE_DIVING_6820(6820, "Whale diving", 2150, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/46fa70966d8e931497f5289060f9a794~tplv-obj.jpg"),
DIAMOND_RING_OF_LOVE(5283, "Diamond ring of love", 300, "https://storage.streamdps.com/iblock/433/4334f4d32ccb792976b1097ae605d1d0/890c718960ebebdd65f1843ec944f483.png"),
@@ -175,7 +203,7 @@ public enum Gift {
MONEY_GUN_6365(6365, "Money Gun", 500, "https://storage.streamdps.com/iblock/25f/25f030f47cfc60d296bb1041ddb91f6e/ca3357a76a2be178c581530009ce215a.png"),
MONEY_GUN_7168(7168, "Money Gun", 500, "https://storage.streamdps.com/iblock/248/248d3e4000124666d17b89889bf7468b/9c7aa57e3bd14e2ed6c1d8acd53b1970.webp"),
MONEY_GUN_7168(7168, "Money Gun", 500, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/e0589e95a2b41970f0f30f6202f5fce6~tplv-obj.jpg"),
HONORABLE_PERSON(6525, "Honorable Person", 99, "https://storage.streamdps.com/iblock/46d/46deaf56b0ee85c34e23e793dbcbab73/4e8f3162028de2f938cda110554d51cc.webp"),
@@ -195,9 +223,11 @@ public enum Gift {
MAN_V_SEAGULL(9086, "Man V Seagull", 15000, "https://storage.streamdps.com/iblock/e5d/e5d95d519ee0ed7922de14f224a9504d/e80d8e840dd44cdf20de4c572c25e0f4.webp"),
GIFT_BOX(6834, "Gift Box", 1999, "https://storage.streamdps.com/iblock/daa/daa30e32902238fe45acd7ad97d93e67/f76b6dc0d74fa3dd7a0a3e7c703fae13.webp"),
GIFT_BOX(6834, "Gift Box", 1999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/9cc22f7c8ac233e129dec7b981b91b76~tplv-obj.jpg"),
GIFT_BOX_6835(6835, "Gift Box", 3999, "https://storage.streamdps.com/iblock/fe3/fe3ea09799010f4185e3f862431db84b/951f010f281aea5b15e90d74b7e6306c.webp"),
GIFT_BOX_6835(6835, "Gift Box", 3999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/3646c259f8ce6f79c762ad00ce51dda0~tplv-obj.jpg"),
FISHING_GEAR(5956, "Fishing Gear", 199, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/1b2353958374f585e25b2f2344c6d0ad~tplv-obj.png"),
ARCADE_GAME(5876, "Arcade Game", 1200, "https://storage.streamdps.com/iblock/d5a/d5aaa3c8ef3d271c2f93709c3ff51e67/721d870d5a5d9d82d726ff5a9ba3aa5e.png"),
@@ -217,13 +247,17 @@ public enum Gift {
GAMEPAD(6052, "Gamepad", 10, "https://storage.streamdps.com/iblock/711/711b578c104edcf1639ff4e2e7779660/6cbb6613fbbd40dac6dfd8857b05545a.png"),
LIVE_FEST_CLAPPERS(9333, "LIVE Fest Clappers", 100, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/63e85e00169ec5be3bfa90bb004cda5e.png~tplv-obj.png"),
RAINBOW(8616, "Rainbow", 1, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/5fb7267489192fc77c4c8b647c124680~tplv-obj.png"),
ORANGE_JUICE(5778, "Orange Juice", 1, "https://storage.streamdps.com/iblock/3d6/3d635024d8744f8648306d56a5c4f62f/be0f5f006bd2350e904b23b607e4f06b.png"),
GERRY_THE_GIRAFFE(6842, "Gerry the Giraffe", 1000, "https://storage.streamdps.com/iblock/792/792ef3f53d86b5cb066d5c0bb5b00a87/91aa5cf7f51a533841bea8617419c54d.webp"),
NOVEMBER(7177, "November", 88, "https://storage.streamdps.com/iblock/ee5/ee55ec79ae4695803d79a7fa0904333c/781835a90e8f6d8f216b54eb2a1b2b8c.webp"),
GG(6064, "GG", 1, "https://storage.streamdps.com/iblock/232/232e2afc8e6c022c5c78df18cf196663/f2ba6300ef54121763648a60d465eef5.png"),
GG(6064, "GG", 1, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/3f02fa9594bd1495ff4e8aa5ae265eef~tplv-obj.jpg"),
GG_8286(8286, "GG", 1, "https://storage.streamdps.com/iblock/993/993d6fe6ba90a007abd712557c96be80/26dd80bd9499dbed22cd6f1ac6ef6fd1.webp"),
@@ -235,7 +269,7 @@ public enum Gift {
ROMAN_EMPIRE(7166, "Roman Empire", 199, "https://storage.streamdps.com/iblock/c77/c778c4e5cd1c68a50dcc06e4bfc3aa08/48edf8b190d98b0a3cc4623e6cc9a22c.webp"),
CHEER_FOR_YOU(6713, "Cheer For You", 199, "https://storage.streamdps.com/iblock/9ac/9aca1e40fff8679e8d37ef5c566fb872/15abbbe55a2269339a6b28e5c582fbfd.webp"),
CHEER_FOR_YOU(6713, "Cheer For You", 199, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/1059dfa76c78dc17d7cf0a1fc2ece185~tplv-obj.jpg"),
TREASURE_CHEST(5513, "Treasure Chest", 100, "https://storage.streamdps.com/iblock/ef8/ef8e2b32aa2e81e7c7efa1e6913dcbc6/0282de629a9d41f4862150bec2e4f35b.png"),
@@ -251,15 +285,17 @@ public enum Gift {
PIZZA(7055, "Pizza", 40, "https://storage.streamdps.com/iblock/c9d/c9d7f483cc0059a1e8165bfbd1341688/307a559eb2b371b92b8ea36ae96bfa30.webp"),
AMUSEMENT_PARK(9466, "Amusement Park", 17000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/12ecc01c2984c5d85bb508e80103a3cb.png~tplv-obj.jpg"),
CLUB(6417, "Club", 2000, "https://storage.streamdps.com/iblock/49b/49be18ae5914346ffcaf15a519ba9c1c/41326cb23d22010f0c4a8edf5bd27615.webp"),
LOVE_BALLOON(5488, "LOVE Balloon", 699, "https://storage.streamdps.com/iblock/02e/02e14e15a34e20b9bc12631b89855609/40e6ba49ff1e8b344199e44b63adcb6f.png"),
DANCING_CAPYBARAS(8806, "Dancing Capybaras", 2200, "https://storage.streamdps.com/iblock/ac2/ac2606f1dc2504c9a1b7974f40074c87/c243031480e8f2e4bbd8e7a43228ff1f.webp"),
DUCK(6265, "Duck", 299, "https://storage.streamdps.com/iblock/7cc/7ccb5acba5bb4359f402941267f3d88e/1032cb33afecc207c136dcd2cf0bbea1.png"),
DUCK(6265, "Duck", 299, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/e172f660a1d4f95813a3ace0fde42323~tplv-obj.jpg"),
FLOWER_OVERFLOW(6148, "Flower Overflow", 4000, "https://storage.streamdps.com/iblock/891/891bc5302f00b006c23975bc80357be2/3b1bfc1ba027d7839fe822a7e51d2833.png"),
FLOWER_OVERFLOW(6148, "Flower Overflow", 4000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/743c4bb44e7e0bf251a7f2f5ada231ee~tplv-obj.jpg"),
PINK_SHOES(8815, "Pink shoes", 5, "https://storage.streamdps.com/iblock/387/387c559abfc868aa8f7d605a25748c14/06e08ba736cb17076b9c314058160ad2.webp"),
@@ -269,7 +305,7 @@ public enum Gift {
COUNTING_SHEEP(7984, "Counting Sheep", 1200, "https://storage.streamdps.com/iblock/f32/f32291f6832c1eb265820aede5db65b2/006d4bd8018d5da1addb803dabd2b64b.webp"),
DOUGHNUT(5879, "Doughnut", 30, "https://storage.streamdps.com/iblock/ae6/ae65a581d82f828e9e3834cd8444986a/9a1acf1d35f2cbef7a4c3929f9587567.png"),
DOUGHNUT(5879, "Doughnut", 30, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/4e7ad6bdf0a1d860c538f38026d4e812~tplv-obj.jpg"),
SPAGHETTI_KISS(7282, "Spaghetti Kiss", 500, "https://storage.streamdps.com/iblock/fba/fba8022bcf5a189adec072e5ffa1be77/708c406b13d9fd4811ae19a8be9c327b.webp"),
@@ -281,21 +317,25 @@ public enum Gift {
MATE_TEA(7089, "Mate tea", 10, "https://storage.streamdps.com/iblock/506/506e98699cdfefd679b35ea5170823b0/a95e9e3721c9b86e3342169b3211b30e.webp"),
TEAM_BRACELET(9139, "Team Bracelet", 2, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/54cb1eeca369e5bea1b97707ca05d189.png~tplv-obj.png"),
HAPPY_NEW_YEAR(6101, "Happy New Year", 199, "https://storage.streamdps.com/iblock/717/71785e60184d69e928972250d3029262/75e3567557eb65c1d9bab3ff99357cdf.webp"),
SAKURA_TRAIN(6244, "Sakura Train", 3999, "https://storage.streamdps.com/iblock/a8e/a8e50d5c5d0eaa42bd71dbeca3b1b95a/204910c857958e7e9efd0178d30a2fbe.png"),
AUTUMN_LEAVES(6967, "Autumn Leaves", 500, "https://storage.streamdps.com/iblock/f04/f042339687e8abaa2fc0e1976d9b11f4/251a0624bc3a23ba39d75467868dcbf8.webp"),
AUTUMN_LEAVES(5890, "Autumn leaves", 500, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/30adcaf443df63e3bfd2751ad251f87d~tplv-obj.png"),
FRANGIPANI(5992, "Frangipani", 1, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/7464fad59650123fe0989e426618847d~tplv-obj.png"),
SKI_GOGGLES(7781, "Ski Goggles", 199, "https://storage.streamdps.com/iblock/f42/f42cbce436db4e60adbf85641a768a12/fa9a4cea3c23829cf6f0725fea8d3c1a.webp"),
PAPER_CRANE(5659, "Paper Crane", 99, "https://storage.streamdps.com/iblock/6a0/6a0b418bc4ae8f04be3194c88389e9e7/bf071c7cc84cf3aac6435adbd222f577.png"),
PAPER_CRANE(5659, "Paper Crane", 99, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/0f158a08f7886189cdabf496e8a07c21~tplv-obj.jpg"),
BIGFOOT(9147, "Bigfoot", 3000, "https://storage.streamdps.com/iblock/f95/f95a4fcfa57150610fa50542db5b0990/ecb879cd751e580d3fe92770788c1735.webp"),
SO_BEAUTIFUL(7024, "So Beautiful", 1, "https://storage.streamdps.com/iblock/ad6/ad67c8d6c93ff4c375568b0bfabbed6f/c68dfd6fda7e8bd84f0bc7fa9ce47af0.webp"),
SUNGLASSES(5509, "Sunglasses", 199, "https://storage.streamdps.com/iblock/919/9191409989dbc6bb4808ce18f8d0d0d7/bc837a05add0cf0f37e946d605df1a54.png"),
SUNGLASSES(5509, "Sunglasses", 199, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/08af67ab13a8053269bf539fd27f3873.png~tplv-obj.jpg"),
PANDA(37, "Panda", 5, "https://storage.streamdps.com/iblock/833/833aadcba552a8a2cc779dd8d4c537c7/f952c72ee1f40e4fcd07d713b3da6565.png"),
@@ -305,7 +345,7 @@ public enum Gift {
TIKTOK_UNIVERSE_6041(6041, "TikTok Universe", 34999, "https://storage.streamdps.com/iblock/374/374cf4298ba2c9817bc87dc2aa48d385/f04c43000c1c33765615c7ef7cacc58d.png"),
TIKTOK_UNIVERSE_9072(9072, "TikTok Universe", 44999, "https://storage.streamdps.com/iblock/cb8/cb81dd4932de73d6c5874c05e93c511b/abb83322d4cb67b8ae6fc7ec15d4d426.webp"),
TIKTOK_UNIVERSE_9072(9072, "TikTok Universe", 44999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/8f471afbcebfda3841a6cc515e381f58~tplv-obj.jpg"),
CUDDLE_WITH_ME(8074, "Cuddle with Me", 500, "https://storage.streamdps.com/iblock/b73/b73e476594a2e9728a5d0ba459fbfb6c/3c37f3a0b52c276a3374bfc0c1247d5c.webp"),
@@ -317,23 +357,27 @@ public enum Gift {
ELEPHANT_TRUNK(8260, "Elephant trunk", 299, "https://storage.streamdps.com/iblock/1ea/1eafea22e99969312cda7c142d8eb3c5/59f72e0dce1bc4fcf83a34f56872b492.webp"),
TRAIN(5978, "Train", 899, "https://storage.streamdps.com/iblock/17d/17dfaee8b85e1b972f86b080729b4126/73c36a574fa91b8b44e1ff63ba130e93.png"),
TRAIN(5978, "Train", 899, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/4227ed71f2c494b554f9cbe2147d4899~tplv-obj.jpg"),
MAY(6470, "May", 1, "https://storage.streamdps.com/iblock/ec6/ec6d320bb93df97057208f5163d81a92/67cb233e8cf0454213300c945b2f9256.webp"),
WISHING_BOTTLE(7160, "Wishing Bottle", 1, "https://storage.streamdps.com/iblock/381/381ef41d500da1120bdfcf83f97e76fc/1a1c9b6be78144f22b8e858effc39333.webp"),
RABBIT(6348, "Rabbit", 1999, "https://storage.streamdps.com/iblock/151/151aef30aabf8be77064d93b4c947876/1a732f3990c54ac993ebe0d9a0316ac6.png"),
RABBIT(6348, "Rabbit", 1999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/61b42d630091b661e82fc8ed400b1de2~tplv-obj.jpg"),
ROSE(5655, "Rose", 1, "https://storage.streamdps.com/iblock/f59/f5902abbd13178017285a308606fd0dd/cf6a40558018965a8171cf5a575dd9de.png"),
ASMR(6240, "ASMR", 10, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/748e74c8309e08dbc5b03e03f28a0ea0~tplv-obj.png"),
ROSE(5655, "Rose", 1, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/eba3a9bb85c33e017f3648eaf88d7189~tplv-obj.jpg"),
TRENDING_FIGURE(9138, "Trending Figure", 999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/df7b556ccf369bf9a42fe83ec8a77acf.png~tplv-obj.jpg"),
ROSA(7997, "Rosa", 10, "https://storage.streamdps.com/iblock/486/486a2490c987c2bb97b6068fd5aac5ab/49d9045fcfe94bbfbd08c3363bb4512a.webp"),
ROSA_8913(8913, "Rosa", 10, "https://storage.streamdps.com/iblock/d75/d75e85cc034e46f992262e4791eebdb5/5bcd13609b96c3cea7d67a6f68b29a18.webp"),
ROSA_8913(8913, "Rosa", 10, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/eb77ead5c3abb6da6034d3cf6cfeb438~tplv-obj.jpg"),
COOPER_S_HOME(6864, "Cooper's Home", 5999, "https://storage.streamdps.com/iblock/2b4/2b405c6cee3848dbf54629bd25725246/b289cd0ec91e4658bd31e48b4e69674e.webp"),
CHEER_YOU_UP(8243, "Cheer You Up", 9, "https://storage.streamdps.com/iblock/788/788d5d3a74a511c5dad52353ffa00b14/bbc76c1cf6b20e20b2b4f149c04cb23d.webp"),
CHEER_YOU_UP(8243, "Cheer You Up", 9, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/97e0529ab9e5cbb60d95fc9ff1133ea6~tplv-obj.jpg"),
BOXING_ROBE(7989, "Boxing Robe", 99, "https://storage.streamdps.com/iblock/653/653d737cee4ef1f2cbd1d69d3aebdcee/478170842ea659c42df24028ea92f883.webp"),
@@ -343,23 +387,29 @@ public enum Gift {
FLAME_HEART(9087, "Flame heart", 1, "https://storage.streamdps.com/iblock/10d/10df10624cdeebe8ff5e0e89e8c8e960/28b8da2878a420f8465cbbc1ec1e6b58.webp"),
TIKTOK_SHUTTLE(6751, "TikTok Shuttle", 20000, "https://storage.streamdps.com/iblock/88e/88e4853bd66a5e7dfb92ff4889ba8c52/179f7f3a339166b1f3369bb9d829905d.webp"),
FAIRY_BREAD(5823, "Fairy Bread", 1, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/a42f9ac9cd6b26da03818ff65ac919f1~tplv-obj.png"),
TIKTOK_SHUTTLE(6751, "TikTok Shuttle", 20000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/8ef48feba8dd293a75ae9d4376fb17c9~tplv-obj.jpg"),
MAGGIE(7911, "Maggie", 15000, "https://storage.streamdps.com/iblock/a12/a12a1b23f1f6a19d728de84e1f43e21d/ff288346e9855a9bb6deb4450491028f.webp"),
PANDA_SKYDIVING(8812, "Panda skydiving", 2000, "https://storage.streamdps.com/iblock/a29/a29903a975ce45f7b9939b510412fcee/051afc0510a7349a9ebfcde9e0fdec24.webp"),
FIREWORKS(6090, "Fireworks", 1088, "https://storage.streamdps.com/iblock/eeb/eebfef5c217a749cf9a997d187a17d67/e1e443ee1532c9f04922acf770f04edb.png"),
FIREWORKS(6090, "Fireworks", 1088, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/9494c8a0bc5c03521ef65368e59cc2b8~tplv-obj.jpg"),
DANCING_BEAVER_IN_SUNGLASSES(5798, "Dancing beaver in sunglasses", 500, "https://storage.streamdps.com/iblock/f0d/f0d0ca698fdf0d0610afd1033d79f4c2/8989843eb6c8f1de3bb6d72260a5d208.png"),
GAMER_CYBER_MASK(7895, "Gamer Cyber Mask", 399, "https://storage.streamdps.com/iblock/383/383652cc1fd3cae9402eeae3a8f5ee1e/df8a16397bb0ed28c0e522b4cfb26500.webp"),
HAPPY_FATHER_S_DAY(8712, "Happy Father's Day", 1, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/193eba78ded4d388a0b5a7ae95943796~tplv-obj.png"),
KO(7542, "KO", 20, "https://storage.streamdps.com/iblock/e5e/e5efb63a21695a08d9647508aca3c95e/cffda8af4cc1a9f4a66eb01b11f4db85.webp"),
KO_7655(7655, "KO", 20, "https://storage.streamdps.com/iblock/aa6/aa613e765fe5c42519bd83d2d4705118/7db90e1f83b8c87c74dfdc8ee88440cb.webp"),
LEON_AND_LILI(8916, "Leon and Lili", 9699, "https://storage.streamdps.com/iblock/00e/00e32385d86e71d5126a0f7de0d102a5/e50f83ab840e595bb5c7175f91d0e071.webp"),
MAGIC_FOREST(9135, "Magic Forest", 6000, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/63a758dbef9788f690e97cd65dbbb8d2~tplv-obj.png"),
LEON_AND_LILI(8916, "Leon and Lili", 9699, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/6958244f3eeb69ce754f735b5833a4aa.png~tplv-obj.jpg"),
MAGIC_STAGE(6263, "Magic Stage", 2599, "https://storage.streamdps.com/iblock/399/399df717aefef9de9259e8256221076f/dfa2835c35b2177701ee65139bdfc59a.png"),
@@ -369,14 +419,16 @@ public enum Gift {
GOLDEN_TRUMPET(8767, "Golden Trumpet", 15, "https://storage.streamdps.com/iblock/a44/a4441a11d3cb073e855088a4eff72fdb/020b0d041c38b00b730b28806dbe6cc5.webp"),
HANDS_UP(8244, "Hands Up", 499, "https://storage.streamdps.com/iblock/e0f/e0f08e9e2d4ee388e6995b96c0ecdb11/c7e487b976e30be258208b2dcdbeabf8.webp"),
HANDS_UP(8244, "Hands Up", 499, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/f4d906542408e6c87cf0a42f7426f0c6~tplv-obj.jpg"),
HAT_AND_MUSTACHE(6427, "Hat and Mustache", 99, "https://storage.streamdps.com/iblock/2d8/2d8065490de12823e64617fe407c138b/b5ba8728531da2e0e52e23b9479c246a.png"),
HAT_AND_MUSTACHE(6427, "Hat and Mustache", 99, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/2f1e4f3f5c728ffbfa35705b480fdc92~tplv-obj.jpg"),
CONCERT(7880, "Concert", 2888, "https://storage.streamdps.com/iblock/0a5/0a59a6ed630ba5aa03392675e6a25654/9ea2257ab244985b43ee801d0889a626.webp"),
PAIMON_SURPRISE(8299, "Paimon Surprise", 1299, "https://storage.streamdps.com/iblock/ffc/ffc784ca54363f5d1d0c195419a3c19b/27096967caade6f066ce748bf5327244.webp"),
GOOD_EVENING(8267, "Good Evening", 399, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/0015a756ff783f37a2cf3b5d634b3cd6~tplv-obj.png"),
HI_MAY(6471, "Hi May", 88, "https://storage.streamdps.com/iblock/970/970b0a868ce24c4b7b7059a904fa7b00/622d597d3cec282d6d2c8129fedd5075.png"),
WEDDING(6286, "Wedding", 1400, "https://storage.streamdps.com/iblock/7be/7beeb7f1098cf5f784739a0be38a06f8/0678483823c912e4dea96fa19a2f0d86.png"),
@@ -399,39 +451,49 @@ public enum Gift {
MUSIC_NOTE(5915, "Music Note", 169, "https://storage.streamdps.com/iblock/cc1/cc17f136f458a86943d7fd503c0a34b4/c56797b8b830d159f31fe5ca5527f586.png"),
FLOWER_SHOW(5831, "Flower Show", 500, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/b6266323ef3ea0d313cbab6911ff8c46~tplv-obj.png"),
MAXWELL(8189, "Maxwell", 10, "https://storage.streamdps.com/iblock/82b/82b7041dcdd8fcc1842c0dd7b5a63099/73736d5ec979ad00f4b771397d9b998b.webp"),
LOVE_DROP(8277, "Love Drop", 1800, "https://storage.streamdps.com/iblock/896/896832589053f394e9b14cac7992a0d1/df08b30c59ff13f1eec030d1e27a2a35.webp"),
LOVE_DROP(8277, "Love Drop", 1800, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/1ea684b3104abb725491a509022f7c02~tplv-obj.jpg"),
WHITE_ROSE(8239, "White Rose", 1, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/a2d81f3847457be9083a9c76a59b08cb~tplv-obj.png"),
YACHT(6103, "Yacht", 9888, "https://storage.streamdps.com/iblock/b6c/b6c9d3c6df6733cc85149897764d2c6b/023d358a3d7a7a330ed006eb07117582.png"),
YACHT_9501(9501, "Yacht", 20000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/e69e2626f6ff43d1c1f2b8ae5ea42514.png~tplv-obj.jpg"),
WINDOW_BASKET(8648, "Window basket", 500, "https://storage.streamdps.com/iblock/a8d/a8d0c44c86385d4cd02ad2d840dcb148/8bbdca8666946a2e7172b3eaeed02303.webp"),
SWAN(5897, "Swan", 699, "https://storage.streamdps.com/iblock/bd1/bd1d065774ce50e2c0331dba965d1ac4/a423a5b7b80743d36b8960e79421060c.png"),
SWAN(5897, "Swan", 699, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/97a26919dbf6afe262c97e22a83f4bf1~tplv-obj.jpg"),
GREAT_TEAM(8203, "Great Team", 1, "https://storage.streamdps.com/iblock/95f/95f3f1519e2b1d025b9a0a1e2faa2fa5/ff1b5216cf3b50aa851d6bd865957dba.webp"),
HELLO_TRAVELER(7501, "Hello Traveler", 5, "https://storage.streamdps.com/iblock/a46/a4668dd315e2d9d84fd267fd0bc9ca59/0eb68fd9e58d9c9072d8ec7185103371.webp"),
HEARTS(5586, "Hearts", 199, "https://storage.streamdps.com/iblock/f28/f2886812bc78d33eab9d70e86b665753/b97d8bfa0bc6d960cad3bfcf5716be12.png"),
HEARTS(5586, "Hearts", 199, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/934b5a10dee8376df5870a61d2ea5cb6.png~tplv-obj.jpg"),
FOOTBALL_HELMET(7851, "Football Helmet", 50, "https://storage.streamdps.com/iblock/9cc/9cce61670c1a81b7954fcf3520dc15a2/b78182e9fd2ff1c6ae1256abd8e2e2bf.webp"),
SCORPIO_STAR_SIGN(7159, "Scorpio Star Sign", 9999, "https://storage.streamdps.com/iblock/c91/c91f3a3685b5c54d9e96d5f9443c4fda/50c48574ff60f328b7a50b80cd9aa4b8.webp"),
SOCCER_BALL(5852, "Soccer Ball", 39, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/e1932db6aea81bbddc4e7dc0229ac155~tplv-obj.png"),
GAME_CONTROLLER(6467, "Game Controller", 100, "https://storage.streamdps.com/iblock/603/6032c1b0d5c2c07abe04956b3cdd45cd/d75d75a7e81f96f39d2ffd574063924f.png"),
GAME_CONTROLLER_6960(6960, "Game Controller", 100, "https://storage.streamdps.com/iblock/030/030f63329d68d21c5faacab88006a17f/fbb8dd78b47184321d93e3ae5a1f2cca.webp"),
TIKTOK_UNIVERSE_(7312, "TikTok Universe+", 34999, "https://storage.streamdps.com/iblock/f23/f23b0f26a9b1cb931243bacfa5a3b7e4/17263e949df9e7e2f173e6eae68fd198.webp"),
TIKTOK_UNIVERSE_(7312, "TikTok Universe+", 34999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/b13105782e8bf8fbefaa83b7af413cee~tplv-obj.jpg"),
HANGING_LIGHTS(5937, "Hanging Lights", 199, "https://storage.streamdps.com/iblock/e03/e03da22fa8c302dbf1d9439c65380549/6d9f912b5a9253f91c01ed58e3ccbe47.png"),
FOOTY(5893, "Footy", 5, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/94f8ac5c7b6f90aba713b44ddac40bf1~tplv-obj.png"),
BATIK_CLOTHES(5461, "Batik Clothes", 1000, "https://storage.streamdps.com/iblock/46d/46d0f497391a934d27d9b993f444d8b2/121af719b172eed61d8a75c1b1341c9d.png"),
DANCING_QUEENS(9240, "Dancing queens", 20000, "https://storage.streamdps.com/iblock/c79/c793af446369ecef5238e73312c84ccd/464a76f3e6eaee9afc771f45a4bba9df.webp"),
TIKTOK(5269, "TikTok", 1, "https://storage.streamdps.com/iblock/50f/50f8e7cf26128a6e10d0b792019c1303/94aa2d574cfe6e3893c087cfb5a5efcd.png"),
TIKTOK(5269, "TikTok", 1, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/802a21ae29f9fae5abe3693de9f874bd~tplv-obj.jpg"),
AIR_DANCER(5661, "Air Dancer", 300, "https://storage.streamdps.com/iblock/8ab/8abe051a8ba9b99026dc3c0a12b59b9e/914def28d5bd9a77be433f35a51d3bc2.png"),
@@ -451,7 +513,7 @@ public enum Gift {
GAMING_CHAIR(6031, "Gaming Chair", 1200, "https://storage.streamdps.com/iblock/bd1/bd14b9754a264a2b1fca22c7171d79ac/448d467dd4d3e6a8945981c52017b11a.png"),
CHAMPION(5955, "Champion", 1500, "https://storage.streamdps.com/iblock/3c9/3c95aee9d94798b88b7132c0f1f006e3/60a55983aa3cf0b2c30de3b30aedcbea.png"),
CHAMPION(5955, "Champion", 1500, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/58ce827091411e667dd6ba8a93215f86~tplv-obj.jpg"),
STAR_ADVENTURES(6320, "Star Adventures", 1999, "https://storage.streamdps.com/iblock/411/4116197948fd486fa5543b87eae4e89e/e6895f7490ccd06c913917ab3e0f1884.png"),
@@ -461,7 +523,7 @@ public enum Gift {
ISLAND_OF_LOVE(6506, "Island of Love", 4000, "https://storage.streamdps.com/iblock/b4d/b4d960acabcbf7b72400d8711174e6f6/e31b32b8e14e7790fcde6f3e8dea975d.png"),
LEON_AND_LION(7823, "Leon and Lion", 34000, "https://storage.streamdps.com/iblock/a28/a28a82c70a624e448a96d3bebbfad3ea/833c0071d92604b5a544bf8f0ad72b68.webp"),
LEON_AND_LION(7823, "Leon and Lion", 34000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/a291aedacf27d22c3fd2d83575d2bee9~tplv-obj.jpg"),
CLOUD_BREAD(5826, "Cloud Bread", 1, "https://storage.streamdps.com/iblock/116/1166fd0ea70e5a7b7a51d718f2cbd06c/6ebf49c51e627d917d96291316c3f812.png"),
@@ -473,28 +535,40 @@ public enum Gift {
FOUNTAIN(8887, "Fountain", 1200, "https://storage.streamdps.com/iblock/07d/07d678346c7eb588bc3cbddf343ab791/8f8f50f5350e4b1c0b151aff333e43a4.webp"),
GARLAND_HEADPIECE(6437, "Garland Headpiece", 199, "https://storage.streamdps.com/iblock/c42/c42c09a6f9075eca708111ea59a33ebd/c097bdc90a3bff337a25f6c53aa1aee5.png"),
KOALA(5822, "Koala", 10, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/22c8fa54da366c111f7bb915d4429e2d~tplv-obj.png"),
GARLAND_HEADPIECE(6437, "Garland Headpiece", 199, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/bdbdd8aeb2b69c173a3ef666e63310f3~tplv-obj.jpg"),
AEROBIC_HEADBAND(9255, "Aerobic headband", 99, "https://storage.streamdps.com/iblock/3d9/3d98c2fbc96922da37a9d22881bb06b9/0a99af132ab8e3fe9806d2412abc6bf0.webp"),
MOUNTAINS(9516, "Mountains", 12000, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/51a7d74bcb4a6417be59f0ffc0b77e96.png~tplv-obj.png"),
FULL_MOON(7222, "Full moon", 299, "https://storage.streamdps.com/iblock/e64/e64dd135280596ce7f1aebbdc3e33a80/494b818b6a4217f1807255ca148c7b2d.webp"),
CHEEMS_DOG(6486, "Cheems Dog", 199, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/d2c9e50efa3b9ff1ed31c96440a9d3a1~tplv-obj.png"),
CAT_PAWS(6046, "Cat Paws", 1, "https://storage.streamdps.com/iblock/c04/c04061e18b637df6759417bfe5418c9c/89bc2c5278f4a3c28acebdd10f6bc089.webp"),
WAVING_HAND(5959, "Waving Hand", 7, "https://storage.streamdps.com/iblock/6da/6da44060164719c3bcb171fb06d6d0d4/a80d1fa6879b0970246f41c444dca47c.webp"),
FRUITS_HAT_(6744, "Fruits Hat ", 199, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/2316b31fc5259cc29f281d88fbca0568~tplv-obj.png"),
BUBBLES(5850, "Bubbles", 500, "https://storage.streamdps.com/iblock/4b1/4b1a012395fd18f6ed835539089dd3c3/98688050698f0180bdd46018a4e98ec1.png"),
SILVER_SPORTS_CAR(8433, "Silver sports car", 5000, "https://storage.streamdps.com/iblock/132/132eb0981780e3e268f844106037b277/a1afff85fc6c53482fccbea21709d36b.webp"),
LIGHTNING_STORM(9515, "Lightning Storm", 6000, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/6f673fbb0ae6860e2b1e254538c958ba.png~tplv-obj.png"),
RACCOON(8448, "Raccoon", 15, "https://storage.streamdps.com/iblock/539/5396582d174489f32525f871cb3087f8/041896a3554f3d4b8c86f486bc81b125.webp"),
HEART_ME(7934, "Heart Me", 1, "https://storage.streamdps.com/iblock/13e/13e5b040286e1eb50502af4539441cce/f82b75d67c3e4553d278404babdf91e2.webp"),
HEART_ME(7934, "Heart Me", 1, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/d56945782445b0b8c8658ed44f894c7b~tplv-obj.jpg"),
LEOPARD(7978, "Leopard", 15000, "https://storage.streamdps.com/iblock/eb4/eb4d116b15c03c2974b86fa400fa6a07/9a34b020e29f2d25f434387ae01b6386.webp"),
TIKTOK_TROPHY(7357, "TikTok Trophy", 699, "https://storage.streamdps.com/iblock/7f6/7f6d5df92bf4b5b559567b9a870d485f/1811197db0860ff395435d51d35598ef.webp"),
LOVE_BOMB(6050, "Love Bomb", 299, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/2a1c1b14f5e9f7be5d76fa4928f574f1~tplv-obj.png"),
TENNIS(6169, "Tennis", 1, "https://storage.streamdps.com/iblock/f20/f20121609887f7ff35952c1bc52529e2/9ff66229b1f81d21b15444ba2b53db98.png"),
NECKLACE(5662, "Necklace", 400, "https://storage.streamdps.com/iblock/a40/a40013bbd1e38e11c0772f8b605c6c25/567d58bd02385de4af1523980cb03a85.png"),
@@ -507,13 +581,15 @@ public enum Gift {
BIRTHDAY_CAKE_9097(9097, "Birthday Cake", 1, "https://storage.streamdps.com/iblock/5b9/5b9eca4a99e965cb25183681a07a5276/c28f7e9c4a8e42460225ff2d12300ae7.webp"),
BANANA_LEAF_VESSEL(5991, "Banana leaf vessel", 5, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/8e635863e20cfa3651bd8a5b762ae72d~tplv-obj.png"),
ICE_LOLLY(6545, "Ice Lolly", 10, "https://storage.streamdps.com/iblock/93d/93dda2498d64aa0a29d444103a7804dd/92fd7397fffbaa8755cb233815964bbf.png"),
CONFETTI(5585, "Confetti", 100, "https://storage.streamdps.com/iblock/364/3640905e132905eb2b0ff64a068db337/fcb80819257fb17f881eeb85b3a0b0d2.png"),
CONFETTI(5585, "Confetti", 100, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/cb4e11b3834e149f08e1cdcc93870b26~tplv-obj.jpg"),
MATCH__MATCH_(7068, "Match! Match!", 200, "https://storage.streamdps.com/iblock/cb4/cb43e14c94694d3d3ae355bdfc517afd/494cd902b8018b35b6dc0f0016c89694.webp"),
SHINY_AIR_BALLOON(7123, "Shiny air balloon", 1000, "https://storage.streamdps.com/iblock/bbf/bbf19d5a1bc2851cf5d7fea1b9fb0609/b636bdafd709c81fa041f72ffdf56645.webp"),
SHINY_AIR_BALLOON(7123, "Shiny air balloon", 1000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/9e7ebdca64b8f90fcc284bb04ab92d24~tplv-obj.jpg"),
RACE_CAR(6892, "Race Car", 12000, "https://storage.streamdps.com/iblock/c1d/c1dd91d0cb97495c4d69a389b3a5a1ae/ee71e32f9e7bfa24a1d0e0a6dc28add1.webp"),
@@ -521,7 +597,7 @@ public enum Gift {
MARIACHI_HAT_7094(7094, "Mariachi Hat", 199, "https://storage.streamdps.com/iblock/ada/ada653db47b3c097d794fc908a604357/aad16e67de36036f1ddfaf22627d6824.webp"),
SUNSET_SPEEDWAY(6203, "Sunset Speedway", 10000, "https://storage.streamdps.com/iblock/088/088e035c1766dc6d511735c97288eb74/855c619602420fe4f34eefe1ec809de6.png"),
SUNSET_SPEEDWAY(6203, "Sunset Speedway", 10000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/df63eee488dc0994f6f5cb2e65f2ae49~tplv-obj.jpg"),
DANCING_ADAM(7468, "Dancing Adam", 5000, "https://storage.streamdps.com/iblock/f5c/f5cda80a1f9853c49226a450faf26e8f/6318d17d7a2526f521123402d19a4c3e.webp"),
@@ -529,15 +605,17 @@ public enum Gift {
SCEPTRE_7364(7364, "Sceptre", 150, "https://storage.streamdps.com/iblock/d2d/d2d1b0359f480a7db08e490364d056b2/bcb44a039dfa4d148af6cde9f233ea13.webp"),
SEAL_AND_WHALE(8381, "Seal and Whale", 34500, "https://storage.streamdps.com/iblock/7ea/7eaaad60ec567af6679b633b13d45d67/a4efc1be2a75340110072f2b6bba554b.webp"),
SEAL_AND_WHALE(8381, "Seal and Whale", 34500, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/3781e9159ff09272826d3f2216ba36ef.png~tplv-obj.jpg"),
HAPPY_PARTY(8247, "Happy Party", 6999, "https://storage.streamdps.com/iblock/0f0/0f0bbac0fe85be28013b327a2e8c46e4/c1d7cbc8ea8493709416759f049b03be.webp"),
HAPPY_PARTY(8247, "Happy Party", 6999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/41774a8ba83c59055e5f2946d51215b4~tplv-obj.jpg"),
WE_LOVE(7503, "We Love", 299, "https://storage.streamdps.com/iblock/679/679e9e38e38f8a4ce707328aa92b8997/9fedb22710af980bbf7b3092b08ecb94.webp"),
HI_NOVEMBER(7176, "Hi November", 1, "https://storage.streamdps.com/iblock/2e1/2e1bd0d30bac3377a114d2080f9687b0/4213592ba44947c98100df3dd8969f32.webp"),
CELEBRATION_TIME(6790, "Celebration Time", 6999, "https://storage.streamdps.com/iblock/25e/25eb996989f2c9f66c3edcdfc6674049/42a32ced64d47b5bf8e7f57dd5b7a57f.webp"),
CELEBRATION_TIME(6790, "Celebration Time", 6999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/e73e786041d8218d8e9dbbc150855f1b~tplv-obj.jpg"),
EXCLUSIVE_YACHT(9524, "Exclusive Yacht", 20000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/da8c85d5ae09ebf320216202e8fa015d.png~tplv-obj.jpg"),
MONTY(7742, "Monty", 1, "https://storage.streamdps.com/iblock/c70/c70e3a9404b18068056d04d5394d739a/4e0e55d9d10a7747b7caf462cd87b4b3.webp"),
@@ -577,29 +655,35 @@ public enum Gift {
SWING(5899, "Swing", 399, "https://storage.streamdps.com/iblock/8a1/8a16a7c5d463793c8c3ab5aa407a87d8/dee86ec9c8e98ebcc58e2e3c09b93d10.png"),
STORMS_AT_SEA(9514, "Storms at sea", 2200, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/4918fbbdf220873dd8cae4c94d1ae037.png~tplv-obj.png"),
SUPERHERO_FIGHT(8814, "Superhero fight", 30000, "https://storage.streamdps.com/iblock/d6b/d6b1c955153c8f8c5048d6c8f0d1b418/97d04b889e64328e9ab07224f6072b5f.webp"),
COOKIE(6883, "Cookie", 5, "https://storage.streamdps.com/iblock/fd2/fd20c8c619b1d43efb9f2fe1923c48a7/45c056f74c9f214dc55d464eab43b224.webp"),
DOG_BONE(8108, "Dog Bone", 10, "https://storage.streamdps.com/iblock/8ba/8badf8e0a5bcbf8d98ed6c4fc0e16c69/b0a8a8020986eb564713c042d23f83b2.webp"),
RUSSIAN_CREPES(5547, "Russian Crepes", 5, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/8525a07c6bf16a74eee66e9ad119b3b8.png~tplv-obj.png"),
FLYING_JETS(7482, "Flying Jets", 5000, "https://storage.streamdps.com/iblock/5a4/5a4f3c7adc31f60326e3adf1a3a20bf9/bc96de02ceba4b91c1f9c996293974b4.webp"),
FLYING_JETS_7720(7720, "Flying Jets", 5000, "https://storage.streamdps.com/iblock/738/73887ee5dc4a63709a10a2e3eff67b7c/1588215b603e2495582288471573cd57.webp"),
FLYING_JETS_9500(9500, "Flying Jets", 5000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/1d067d13988e8754ed6adbebd89b9ee8.png~tplv-obj.jpg"),
INDOOR_FAN(6565, "Indoor Fan", 199, "https://storage.streamdps.com/iblock/499/499dc6bf36be95e90398a56d18bfeebe/231f634c0c86d034f193477f208f66ca.webp"),
MIC(5650, "Mic", 5, "https://storage.streamdps.com/iblock/1db/1dbec91a90cdeca9f7fb1ea7280ad5cd/cae0a287f4d2e8d0e1558dcbb4aa3b2f.png"),
FOREVER_ROSA(8914, "Forever Rosa", 399, "https://storage.streamdps.com/iblock/a97/a97e8f4489fb62aefe7afd0137e6cdad/3ebbb3e1119ff1c3b7bc9b5ced47a4e0.webp"),
FOREVER_ROSA(8914, "Forever Rosa", 399, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/863e7947bc793f694acbe970d70440a1.png~tplv-obj.jpg"),
ICE_CREAM_CONE(5827, "Ice Cream Cone", 1, "https://storage.streamdps.com/iblock/1a1/1a13988014fd9fb5990b3060beb2151d/71ba7d4c6eeaef46e5cc11fbf36ba3fa.png"),
ICE_CREAM_CONE(5827, "Ice Cream Cone", 1, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/968820bc85e274713c795a6aef3f7c67~tplv-obj.jpg"),
FLY_LOVE(8248, "Fly Love", 19999, "https://storage.streamdps.com/iblock/729/729736d11c9014d99d088fa77da2bcea/d461d23ae2f3c5d2014f78a34c0b8956.webp"),
FLY_LOVE(8248, "Fly Love", 19999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/a598ba4c7024f4d46c1268be4d82f901~tplv-obj.jpg"),
BEACH_DATE(6132, "Beach Date", 899, "https://storage.streamdps.com/iblock/504/504a5dfef033a7e90e4f07987b0c0f28/70ec484fc4c798d3e09a7fbcae83ee95.png"),
TRAVEL_WITH_YOU(6233, "Travel with You", 999, "https://storage.streamdps.com/iblock/5f1/5f15bb4166a3be380c71682d27b1e38f/ad2519381f60bb3e2c6b603ed4baff24.png"),
TRAVEL_WITH_YOU(6233, "Travel with You", 999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/753098e5a8f45afa965b73616c04cf89~tplv-obj.jpg"),
CHOCOLATE_STICK(6002, "Chocolate Stick", 1, "https://storage.streamdps.com/iblock/5c9/5c9487af2038c340fdbeb0b9ea4ff83e/b377ae8024881b93822f7b0a6bfe04e8.png"),
@@ -613,13 +697,17 @@ public enum Gift {
ROMANTIC_CARRIAGE(5627, "Romantic Carriage", 6000, "https://storage.streamdps.com/iblock/681/68132980826d9ddb208928c54a798f7f/e4f143cb38a0687729539972b2132ac1.png"),
AMAZING(5983, "Amazing", 5, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/18256fd3f4402601dd07c83adae3e9a2~tplv-obj.png"),
BRIDAL_VEIL(5902, "Bridal Veil", 299, "https://storage.streamdps.com/iblock/ac0/ac0cbd1870dd92251f6ef620acb652e5/fe8eca664be736231b8e8e2cc2237a15.png"),
TULIP_BOX(5325, "Tulip Box", 200, "https://storage.streamdps.com/iblock/d44/d4471e5deb9cb5831f846ca4c9df9c5d/7d1236ecd67b3e655c3dfd72673a423d.png"),
SQUIRREL(7213, "Squirrel", 1, "https://storage.streamdps.com/iblock/5c3/5c37dce1eab0d67386329f3a2920a874/38104bd52d316ea76464433b3b07dea7.webp"),
METEOR_SHOWER(6563, "Meteor Shower", 3000, "https://storage.streamdps.com/iblock/484/484359bdcbb83121575fcbce75e6d9c0/5d501b2acc4a12ca9fe685b0cf6fcaba.png"),
CHOC_CHIP_COOKIE(6416, "Choc Chip Cookie", 5, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/7dd2731de2e644301a329d3eb437b427~tplv-obj.png"),
METEOR_SHOWER(6563, "Meteor Shower", 3000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/71883933511237f7eaa1bf8cd12ed575~tplv-obj.jpg"),
CAKE(5720, "Cake", 20, "https://storage.streamdps.com/iblock/edb/edbe349c5a4be01ec1fbf2225d0f48dc/4169ef7f0263177384205df6663451c8.png"),
@@ -629,9 +717,9 @@ public enum Gift {
SNOWBOARD(7747, "Snowboard", 199, "https://storage.streamdps.com/iblock/9f1/9f1a3c5fe2fe7ef505a144e01fc37d29/cbac5622c575d34dfd943bc2a8f3d80c.webp"),
FIRE_PHOENIX(9092, "Fire Phoenix", 41999, "https://storage.streamdps.com/iblock/13b/13bd6d3510e802831552d711c688c958/ffedd22a99c1eb2ac888974816c979cb.webp"),
FIRE_PHOENIX(9092, "Fire Phoenix", 41999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/bfb8425a7e8fa03f9fec05a973a4a506.png~tplv-obj.jpg"),
STAR(6432, "Star", 99, "https://storage.streamdps.com/iblock/cc9/cc9317321e70cc776adc68bd3e0e66e7/4f3082259def021d1a2ed29e77a77713.png"),
STAR(6432, "Star", 99, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/485175fda92f4d2f862e915cbcf8f5c4~tplv-obj.jpg"),
SPRING_TRAIN(8152, "Spring train", 3999, "https://storage.streamdps.com/iblock/035/035862dc0952468fc95f02995cec0f22/eeb69650806ea4c2e22558ef4b5e2b47.webp"),
@@ -647,6 +735,8 @@ public enum Gift {
CAMPING(6322, "Camping", 250, "https://storage.streamdps.com/iblock/9a9/9a9370a392311149be37e7c40c3e960d/ecb9dcdacf3a2ae0abef79baf0c4f41c.webp"),
FAIRY_WINGS(9463, "Fairy Wings", 1, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/e504dc2f313b8c6df9e99a848e1b3a99.png~tplv-obj.png"),
TICKET(6856, "Ticket", 10, "https://storage.streamdps.com/iblock/434/434746bffe494ac6ad2eb5e7e4384955/92e426ea0b4d4a9f89d7e2786115cd20.webp"),
FLOWER_FLIGHT(8327, "Flower Flight", 399, "https://storage.streamdps.com/iblock/886/88657108678e20acb23ff7fea5b479f7/144ff90bc7bc304c7c28064812d85ba2.webp"),
@@ -659,17 +749,21 @@ public enum Gift {
CHOCOLATE(5860, "Chocolate", 1, "https://storage.streamdps.com/iblock/522/52287f41673e2fd836c83ec78e95f08a/77307666e41e09e54052fd321c2906c4.png"),
RIO_DE_JANEIRO(7218, "Rio de Janeiro", 9999, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/34c0eb43c3d50e8ab64408171ebbe733~tplv-obj.png"),
BLOOMING_RIBBONS(9498, "Blooming Ribbons", 1000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/f76750ab58ee30fc022c9e4e11d25c9d.png~tplv-obj.jpg"),
CORNFLOWER(8186, "Cornflower", 5, "https://storage.streamdps.com/iblock/025/025c50c390f6a12148a69728284c7298/36b50fe529db9d7db028b0774842e103.webp"),
ASMR_TIME_(6990, "ASMR Time ", 10, "https://storage.streamdps.com/iblock/49d/49dccba4525df92ed17678cc6ea47e95/b2c8c52d5294bb531d7d87a4c3ff97fe.webp"),
POOL_PARTY(5938, "Pool Party", 4999, "https://storage.streamdps.com/iblock/a27/a27e6730390e890198ebc0f3a2a6d68b/df71cae96fb8a3e616931c7c48a2574c.png"),
POOL_PARTY(5938, "Pool Party", 4999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/4147c5bcfad9623c693f83d5d6cba1f7~tplv-obj.jpg"),
MATCH_STAR(7070, "Match Star", 1, "https://storage.streamdps.com/iblock/497/497fa45aa565639b858e333ae2e0450c/f381f7c1c9a66fb6712e78a3b210b3ab.webp"),
MATCH_STAR_7074(7074, "Match Star", 1, "https://storage.streamdps.com/iblock/bd5/bd50fed09a13493a57589939f8419460/5b136dca770fbb5c96dc9c62e20bf6b0.webp"),
GLOW_STICK(6788, "Glow Stick", 1, "https://storage.streamdps.com/iblock/751/751d663d0939f5d4a5178c32731a8c03/29d8d050f88ee2eb30b4099c86017d58.webp"),
GLOW_STICK(6788, "Glow Stick", 1, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/8e1a5d66370c5586545e358e37c10d25~tplv-obj.jpg"),
MUSIC(6415, "Music", 499, "https://storage.streamdps.com/iblock/366/3663e0462a9eb4519288bf93fce16a76/ee50d49d9ab88cac71617c69be201161.webp"),
@@ -681,7 +775,9 @@ public enum Gift {
AIRSHIP(6327, "Airship", 1999, "https://storage.streamdps.com/iblock/85e/85e8a2811f78d9e6df7d00419394b88c/da5e075e4040fd8a3b60d4f28a2fb5db.webp"),
DRAGON_FLAME(7610, "Dragon Flame", 26999, "https://storage.streamdps.com/iblock/544/544a04d819ce2c2a51624bd4cd01e70d/489f08c5dc7c27d0c1fc2a97d2f79b1d.webp"),
HEALTH_POTION(7813, "Health Potion", 1, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/13f6a46b763c496306ff541daf3021a4~tplv-obj.png"),
DRAGON_FLAME(7610, "Dragon Flame", 26999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/89b4d1d93c1cc614e3a0903ac7a94e0c~tplv-obj.jpg"),
NASI_LEMAK(5588, "Nasi Lemak", 1, "https://storage.streamdps.com/iblock/565/56533f45e52bfd5f73f31ddf75812f46/f9aadd4e8227fa94828795c763b22fff.png"),
@@ -693,19 +789,21 @@ public enum Gift {
TELESCOPE(6733, "Telescope", 5, "https://storage.streamdps.com/iblock/0ff/0ff6c8d47e3d601ef9f775bfa6cf9647/4489d8324898af2a82d18ea04166db2c.webp"),
POWER_HUG(5631, "Power hug", 1, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/9578adce6e3da2d211583212bdfd1b0e~tplv-obj.png"),
SPACESHIP(6588, "Spaceship", 13999, "https://storage.streamdps.com/iblock/fb1/fb1096568dcc97c2575dec7441d0d651/245c4c7ce9bf5d5378586eb3a2478b42.webp"),
BIRTHDAY_CROWN(9096, "Birthday Crown", 99, "https://storage.streamdps.com/iblock/c07/c073f2d950a252aa24b7343655208c8a/68f6af6dc16ab51396cef18f50a43792.webp"),
LION_S_MANE(7985, "Lion's Mane", 500, "https://storage.streamdps.com/iblock/267/2670a5a8c9666b7afffb3255c2c104ee/abe9a0e7a6ef8b83d94df90f3a356748.webp"),
WATERMELON_LOVE(6781, "Watermelon Love", 1000, "https://storage.streamdps.com/iblock/44a/44a62f73bbaa2b0a6bd0a39d62f73033/e8775b631b23ed6756b9cdb4132ee85e.webp"),
WATERMELON_LOVE(6781, "Watermelon Love", 1000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/1d1650cd9bb0e39d72a6e759525ffe59~tplv-obj.jpg"),
COTTON_THE_SEAL(8349, "Cotton the Seal", 399, "https://storage.streamdps.com/iblock/6da/6dac7ca9a1f92e28287a9ef01e55a560/d0317b7d3411edd28a393a56d24a863f.webp"),
COTTON_THE_SEAL_8852(8852, "Cotton the Seal", 399, "https://storage.streamdps.com/iblock/a36/a36238dfeb0d768707d336eac32cdf82/cf84e06c4c8f1e9dce3db677fd4770a5.webp"),
ADAM_S_DREAM(7400, "Adams Dream", 25999, "https://storage.streamdps.com/iblock/d10/d10e9c17cf198b2da7ae2ad13ffa6541/33b7de1f4f63e68ce8fa6d5693770042.webp"),
ADAM_S_DREAM(7400, "Adams Dream", 25999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/9a586391fbb1e21621c4203e5563a9e0~tplv-obj.jpg"),
GOLDEN_SPORTS_CAR(5287, "Golden sports car", 29999, "https://storage.streamdps.com/iblock/4c1/4c1fa9bee06971f242e06b4578492c3a/2460543c6afe7d35854e3147811fcc1f.png"),
@@ -715,7 +813,7 @@ public enum Gift {
M4_BEATRIX_7656(7656, "M4 Beatrix", 20, "https://storage.streamdps.com/iblock/da7/da77071a5194b9d7a3a6e94a9dcb5a4f/04a7595d5f7ffb42c9e28a697f0feed3.webp"),
LIKE_POP(8130, "Like-Pop", 99, "https://storage.streamdps.com/iblock/272/2726ba4a1c7bbd0d4a483207b12d8f71/9c96b3106699eadcdf54c3e379418b99.webp"),
LIKE_POP(8130, "Like-Pop", 99, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/75eb7b4aca24eaa6e566b566c7d21e2f~tplv-obj.jpg"),
FOREST_FAIRY(9148, "Forest Fairy", 4000, "https://storage.streamdps.com/iblock/078/07801fde04dd77b439384738e630e59f/e50ece2683001006eae00866d6df7b63.webp"),
@@ -725,19 +823,23 @@ public enum Gift {
PUMPKIN_PIE(7396, "Pumpkin Pie", 5, "https://storage.streamdps.com/iblock/abf/abf5efb8fac6f64568b472c3afdb3e25/f85e4ef55b8c7d03f81351babd833c69.webp"),
EMAIL_MESSAGE(6199, "Email Message", 1000, "https://storage.streamdps.com/iblock/dc2/dc21bd6120598b10e5146c713249059e/4eb90329ca1344ccc1f88105ff0dafcf.png"),
EMAIL_MESSAGE(6199, "Email Message", 1000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/c959df6dbffd6f07849d22d2c3c07861~tplv-obj.jpg"),
PREMIUM_SHUTTLE(7125, "Premium Shuttle", 20000, "https://storage.streamdps.com/iblock/fc0/fc0bb0d7097635a7a91dd643f42a5258/cea9087fc79225ba647a6fa6bc60863c.webp"),
PREMIUM_SHUTTLE(7125, "Premium Shuttle", 20000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/c2b287adee5151b7889d6e3d45b72e44~tplv-obj.jpg"),
PARTY_HAT(6398, "Party hat", 199, "https://storage.streamdps.com/iblock/e92/e924ae4ad405da962162650abe98c01f/403b19fc0f2f47739d32448548be3263.png"),
HI_MARCH(7977, "Hi March", 88, "https://storage.streamdps.com/iblock/e22/e2266686271c7a90ff04517f248c6f73/0459d679c01a5bfa5a4be1d61ec81ec8.webp"),
FANTASTIC(6813, "Fantastic", 5, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/a1b2204b06aa19d45a0338e9f0099ea7~tplv-obj.png"),
HEDGEHOG(6868, "Hedgehog", 299, "https://storage.streamdps.com/iblock/841/841e924150793d6961df0a1c89cc67ca/5886839b7de0b1289303081f9af380f8.webp"),
LIVE_FEST(9334, "LIVE Fest", 1, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/1e98afffef90ed4b2cc9c9ebb88e3608.png~tplv-obj.png"),
I_LOVE_TR(7139, "I LOVE TR", 1, "https://storage.streamdps.com/iblock/84d/84d68e92c471e7da792aa98d856c824c/7728ac60043efb9c96e2ce0f77dbef31.webp"),
SHIBA_INU(5482, "Shiba Inu", 222, "https://storage.streamdps.com/iblock/a7e/a7ea6aebc44c52508dcbd85d8061af25/30b933d7c271571931f4e0d6788fd459.webp"),
SHIBA_INU(5482, "Shiba Inu", 222, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/ddbcee02f5b86b803b0ec34357cd82ec.png~tplv-obj.jpg"),
SHIBA_INU_7839(7839, "Shiba Inu", 199, "https://storage.streamdps.com/iblock/3c4/3c40e306064bb00719cb77dec261891a/bc24ae9f8a52d13475897170332d546f.webp"),
@@ -751,6 +853,8 @@ public enum Gift {
DEHYA(8298, "Dehya", 10, "https://storage.streamdps.com/iblock/c69/c6958678de541ee2bc86ca0705a092d6/d33c50b1f67560f9673724a34b01a63d.webp"),
PANETTONE(7814, "Panettone", 1, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/64ce2413a362442819b4551703b7b26c~tplv-obj.png"),
BASKETBALL(6269, "Basketball", 1, "https://storage.streamdps.com/iblock/1e1/1e15c5768844b752893c47c9699ffa5e/ac594ceeb59aa16782bfa62a46d832d8.png"),
SUNSET_IN_BALI(5835, "Sunset in Bali", 799, "https://storage.streamdps.com/iblock/970/97081f479a0fa7bfbd37eab0ce7109c1/9e17c532a2f217b1cd2f01e21783a3db.png"),
@@ -761,7 +865,11 @@ public enum Gift {
MP3(6472, "Mp3", 100, "https://storage.streamdps.com/iblock/20a/20a06df8f2d9428df8fd690a7ce4bdaf/40a50efc8884f8c973a58a749350c9c3.png"),
PHOENIX(7319, "Phoenix", 25999, "https://storage.streamdps.com/iblock/7d2/7d238b81518ab1e340e06adeb88c7c1c/ca9c644b2653d8315db71237b6b955eb.webp"),
RHYTHMIC_BEAR(9468, "Rhythmic Bear", 2999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/16eacf541e4bd6816e88139d079519f5.png~tplv-obj.jpg"),
CRYSTAL_BALL(6428, "Crystal Ball", 1700, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/7e4f9a99b7003ae05186f5324aae9fbf~tplv-obj.png"),
PHOENIX(7319, "Phoenix", 25999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/ef248375c4167d70c1642731c732c982~tplv-obj.jpg"),
BOUQUET_FLOWER(5780, "Bouquet Flower", 30, "https://storage.streamdps.com/iblock/ceb/cebb5d5f7004d6ccf9336ae20281be88/5061b1767c2325fe6704eb08d97c5cb8.png"),
@@ -771,7 +879,7 @@ public enum Gift {
PUG(6939, "Pug", 299, "https://storage.streamdps.com/iblock/367/367d7a870b489f203c084bd4338b5fba/6efbd5b994d91fa8a467bd338fcead92.webp"),
TIKTOK_STARS(8582, "TikTok Stars", 39999, "https://storage.streamdps.com/iblock/fb3/fb3c04af9d06b0cdf3df3da61f0c5705/b0f3fd913d2443626d8026eacef37a51.webp"),
TIKTOK_STARS(8582, "TikTok Stars", 39999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/b1667c891ed39fd68ba7252fff7a1e7c~tplv-obj.jpg"),
CHILL(6704, "Chill", 5, "https://storage.streamdps.com/iblock/7df/7dfcee6b2702691bf9c8ca0966b3c4b1/144aa8fff9ce8c64aa7fcb507bf6c1cd.webp"),
@@ -781,13 +889,15 @@ public enum Gift {
FRUITS_HAT(7091, "Fruits Hat", 199, "https://storage.streamdps.com/iblock/404/404cc4794702cc6feb93bf4517bc0762/05846cb2d9548cf2f0573159110ecb64.webp"),
SPINNING_TOP(6483, "Spinning Top", 10, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/6cde70e04a6b40a9879f7b99ff191808~tplv-obj.png"),
MISHKA_BEAR(5486, "Mishka Bear", 100, "https://storage.streamdps.com/iblock/880/8809f52dbf40e0d670067f8c223d7c04/c603798bc6cd2bdc5a032ddbeb55e258.png"),
MISHKA_BEAR_5566(5566, "Mishka Bear", 100, "https://storage.streamdps.com/iblock/010/010ccc7a5d5e21231b46cea3223d5b1f/aa9c15ca87e4df8dad9be22164978fc2.png"),
MISHKA_BEAR_7163(7163, "Mishka Bear", 100, "https://storage.streamdps.com/iblock/0cc/0ccd22056d7cd20351cfb11a8ec62bf1/4f7f3b65fad302160471f52bfc45fc34.webp"),
PRIVATE_JET(5767, "Private Jet", 4888, "https://storage.streamdps.com/iblock/a24/a246b6f08242ef1084e43708fcd4f4df/8bbe338da8052146506e3a802a3cd0d8.png"),
PRIVATE_JET(5767, "Private Jet", 4888, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/921c6084acaa2339792052058cbd3fd3~tplv-obj.jpg"),
BALALAIKA(5927, "Balalaika", 100, "https://storage.streamdps.com/iblock/d88/d88bc38371769262c006dccbaa43c9ff/1e0f5adda0546879e07126492ba6001c.webp"),
@@ -795,7 +905,7 @@ public enum Gift {
SPEEDSTER(8418, "Speedster", 15000, "https://storage.streamdps.com/iblock/96a/96a5a249a1701c3c03e0b2427bad3b2f/63fb5582c89c17f275fc99505505b719.webp"),
GEM_GUN(7122, "Gem Gun", 500, "https://storage.streamdps.com/iblock/939/9393cb0608187667ef6d5e377f1c0d69/9b5cb58300a50651228e505b7714fdea.webp"),
GEM_GUN(7122, "Gem Gun", 500, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/dd06007ade737f1001977590b11d3f61~tplv-obj.jpg"),
KNOCKOUT(8415, "Knockout", 4999, "https://storage.streamdps.com/iblock/1a5/1a56926523c34ab3b553180c42f7bc55/7a6076446639aade9d5498df45ba7f9b.webp"),
@@ -809,13 +919,17 @@ public enum Gift {
BIG_LOVE(7224, "Big Love", 5, "https://storage.streamdps.com/iblock/9d7/9d791fea266e119ffd938095526a1b55/1923108683e8c0aba3b78e1d0e8137cf.webp"),
TGIF(6592, "TGIF", 1, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/2734231d880b5cd20149f4cc8c760279~tplv-obj.png"),
GOLDEN_GAMEPAD(6582, "Golden Gamepad", 30, "https://storage.streamdps.com/iblock/e85/e85940610dd45adc8733b51106c60712/ca839e1139ca0b94070c1e38093e95ec.png"),
COCONUT_TREE(5794, "Coconut Tree", 199, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/eb0923dbab5251f4c2e0496b11b55c4f~tplv-obj.png"),
SUMMER_BAND(6555, "Summer Band", 3999, "https://storage.streamdps.com/iblock/43b/43b88814d979720d80a6e17258ab3bd8/b1abf3d90ae212317d6ae339ed5f5be7.png"),
GORILLA(8602, "Gorilla", 30000, "https://storage.streamdps.com/iblock/1e2/1e29b9d1a0263f1487498dc556cdcbc1/bec227242f8c9b258855071aa050ac17.webp"),
THUMBS_UP(6246, "Thumbs Up", 1, "https://storage.streamdps.com/iblock/267/2675b04a24fc0d674ca25874493769c4/49252fd7c65b99a3acf3e2ee18af2d67.png"),
THUMBS_UP(6246, "Thumbs Up", 1, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/570a663e27bdc460e05556fd1596771a~tplv-obj.jpg"),
TOWARDS_THE_FUTURE(6625, "Towards the future", 28888, "https://storage.streamdps.com/iblock/b2f/b2f6915948e5eabce83a39c525eebe6f/005804958a7917fd06a09ddeb3f41a0e.png"),
@@ -827,23 +941,27 @@ public enum Gift {
COOPER_SKATES_HOME(6865, "Cooper Skates Home", 599, "https://storage.streamdps.com/iblock/041/04184b09ec8e7bf137d33cf57ce4eec9/3c2e360b023b9980e54e9d9a394883b9.webp"),
EXCLUSIVE_JET(9523, "Exclusive Jet", 5000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/1cc167a00aa4d5dfe48018afb38c3daa.png~tplv-obj.jpg"),
BIRTHDAY_PARTY(6787, "Birthday Party", 6999, "https://storage.streamdps.com/iblock/135/135b2ac0877de059f56e510b0ac70d08/07285ba7471fb98743bfe308d0b58ce2.webp"),
BIRTHDAY_PARTY_9095(9095, "Birthday Party", 6999, "https://storage.streamdps.com/iblock/d0d/d0d1164a9ed81239b70cb25b93927023/d0dba293643c67dc33c1f4dda04e5b50.webp"),
TEASING(6390, "Teasing", 401, "https://storage.streamdps.com/iblock/e14/e14c9b35975f1da5b8a5e3f116dae2bb/9f8cea9b65620e8376e44802c25ddf27.png"),
CRICKET(6006, "Cricket", 99, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/408d55c0526ada808be7db3e22c02a56~tplv-obj.png"),
FOAMY_DRINK(6740, "Foamy Drink", 100, "https://storage.streamdps.com/iblock/cc8/cc8133c73d5ca2cb5fde306f5b4e2a11/fb273956755fe6fbf7263023a9c36ebe.webp"),
CAPYBARA(8217, "Capybara", 30, "https://storage.streamdps.com/iblock/e94/e944534be54186446d7c38563c772029/553d899c4bd4be31e7b051bb36e842f8.webp"),
GUMMY(6126, "Gummy", 5, "https://storage.streamdps.com/iblock/c33/c338d672d2ccd9de8df40d7afe23e041/cf38b075df9389388a847e24a5af4a9e.png"),
LEON_THE_KITTEN(6646, "Leon the Kitten", 4888, "https://storage.streamdps.com/iblock/6db/6dbac11d1406b04bd70ef473fac91fb6/42a0a84bd8a818dbe2c98d84233f12fb.png"),
LEON_THE_KITTEN(6646, "Leon the Kitten", 4888, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/a7748baba012c9e2d98a30dce7cc5a27~tplv-obj.jpg"),
STAR_THRONE(7764, "Star Throne", 7999, "https://storage.streamdps.com/iblock/af5/af5b1fac4d7a0b540057460e0ab0730a/864a37b3f4a8ad6d2e174bfa6e2e4f32.webp"),
STAR_THRONE(7764, "Star Throne", 7999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/30063f6bc45aecc575c49ff3dbc33831~tplv-obj.jpg"),
STAR_THRONE_8420(8420, "Star Throne", 7999, "https://storage.streamdps.com/iblock/cb8/cb8068130463628181f0b84a4408e871/2495b97f5f4868e9e71612120c4eded5.webp"),
STAR_THRONE_8420(8420, "Star Throne", 7999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/30063f6bc45aecc575c49ff3dbc33831~tplv-obj.jpg"),
PLANET(5954, "Planet", 15000, "https://storage.streamdps.com/iblock/dc5/dc50bbe9b153d9f714919d386325a223/b296c2101cb24bc65e8abd2977d6c123.png"),
@@ -867,11 +985,11 @@ public enum Gift {
TINY_DINY_7591(7591, "Tiny Diny", 10, "https://storage.streamdps.com/iblock/b24/b24309d4ea6722875678e492ae12fb3f/864ac7928a78b43be2d1ee93915a53f5.webp"),
CORGI(6267, "Corgi", 299, "https://storage.streamdps.com/iblock/5ad/5ada6717da571d87542b081113bddaa6/2fe60d73a96b698efc61a1a434b4f3ed.png"),
CORGI(6267, "Corgi", 299, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/148eef0884fdb12058d1c6897d1e02b9~tplv-obj.jpg"),
DIAMOND_KING(5337, "Diamond King", 1500, "https://storage.streamdps.com/iblock/d7a/d7a7a3a0933ddead34a48a03d965f77a/bb50ca99cdfbdc705cacff9af43a1b20.png"),
LOCK_AND_KEY(5880, "Lock and Key", 199, "https://storage.streamdps.com/iblock/daf/daf918a2e001ce161e116e5c3a2a4cfb/f673b5dfc3bba9a9529425a4fa9e446f.png"),
LOCK_AND_KEY(5880, "Lock and Key", 199, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/2c9cec686b98281f7319b1a02ba2864a~tplv-obj.jpg"),
TTEOKBOKKI(5645, "Tteokbokki", 5, "https://storage.streamdps.com/iblock/81c/81ca5954462f21f506095fe410dd2aaf/c07e9b0bb8d0559874b780495cc0e451.png"),
@@ -879,7 +997,9 @@ public enum Gift {
GRAPES(7234, "Grapes", 1, "https://storage.streamdps.com/iblock/442/442580106ac8748b79ef450eb25b5981/df624c619c48b583adee184bca134c80.webp"),
SAM_THE_WHALE(8391, "Sam the Whale", 30000, "https://storage.streamdps.com/iblock/3e6/3e6b7b154146a376da3ec918eace0bf6/682a9a304ddd18ad08702f15236f4293.webp"),
LLAMA_GREETINGS(6531, "Llama Greetings", 299, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/a6b95ce6350f5f4bdff6880ac6993789~tplv-obj.png"),
SAM_THE_WHALE(8391, "Sam the Whale", 30000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/f48a1887eb88238738996bb997b31c0f.png~tplv-obj.jpg"),
DIAMOND_TREE(7963, "Diamond Tree", 1088, "https://storage.streamdps.com/iblock/47a/47afc3c8563cacbff2ce13f2310a2fc4/84761a2a3e0431bda3bf3d2cc9d02b3f.webp"),
@@ -887,23 +1007,27 @@ public enum Gift {
LOVE_YOU_5919(5919, "Love you", 20, "https://storage.streamdps.com/iblock/728/728eb443836e4ea999aa2cf341f26561/69d6c2bce8f5523d186a03b7eef20e1b.png"),
LOVE_YOU_6890(6890, "Love you", 1, "https://storage.streamdps.com/iblock/0d9/0d984742e147a8bf2fd0f06b1421a825/c42e82a95ae799de0e860947971440ed.webp"),
LOVE_YOU_6890(6890, "Love you", 1, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/ab0a7b44bfc140923bb74164f6f880ab~tplv-obj.jpg"),
HERE_WE_GO(8245, "Here We Go", 1799, "https://storage.streamdps.com/iblock/eb4/eb455b32af55203ea8eca269775cbe9e/9c39ed829f6bb4730b9fadc0d7dff5d3.webp"),
HERE_WE_GO(8245, "Here We Go", 1799, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/61b76a51a3757f0ff1cdc33b16c4d8ae~tplv-obj.jpg"),
CHASING_THE_DREAM(7467, "Chasing the Dream", 1500, "https://storage.streamdps.com/iblock/63a/63a21b726641e8bb50715bfe2e147d93/613bfe9574775d0c5b9be197cd96a745.webp"),
CHASING_THE_DREAM(7467, "Chasing the Dream", 1500, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/1ea8dbb805466c4ced19f29e9590040f~tplv-obj.jpg"),
BIRD_WHISPERER(8344, "Bird Whisperer", 5000, "https://storage.streamdps.com/iblock/079/079bf5895816fb04293d01375eaf23a5/672128ca0f65deb0e75e2a9a690a79f0.webp"),
GOOD_NIGHT(8268, "Good Night", 399, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/b7b55087141bd5f965eb31a99a5f157b~tplv-obj.png"),
ALIEN_PEACE_SIGN(7831, "Alien Peace Sign", 1, "https://storage.streamdps.com/iblock/5f7/5f7b29f5c7a4ca3a4dbbe8dc0e195459/cd83433a0f1697a0b66a891cbd7cf1af.webp"),
THE_MAGIC_LAMP(7161, "The Magic Lamp", 1000, "https://storage.streamdps.com/iblock/e0d/e0d45fccd69220f321531383d97f51fc/4296cc4b886f31bb5b2cf106ebf640ab.webp"),
TACO_(6113, "Taco ", 9, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/43d06db8c962623dbed6ecf70fb89ca8~tplv-obj.png"),
TIARA(8496, "Tiara", 299, "https://storage.streamdps.com/iblock/1b1/1b1ee7b697bae41ee2cbf834d1f1099e/303eec791a710c2417bb5075529681d9.webp"),
COFFEE(5333, "Coffee", 1, "https://storage.streamdps.com/iblock/920/920b64634d946a2238950c353c16df81/0fe22d9bdee1bd6d9d77f66bcd8cf45a.png"),
COFFEE_5479(5479, "Coffee", 1, "https://storage.streamdps.com/iblock/c01/c01ca7de81469018ef06e3b0e09a2814/04bb6e747afdb5334e8c29074e24f474.webp"),
COFFEE_5479(5479, "Coffee", 1, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/02492214b9bd50fee2d69fd0d089c025.png~tplv-obj.jpg"),
COFFEE_5933(5933, "Coffee", 10, "https://storage.streamdps.com/iblock/6d7/6d7c47d7f1862904fb26bf7b8297befb/fe6a95bcfc5abe6545f44983045aae65.png"),
@@ -917,9 +1041,9 @@ public enum Gift {
GARDENING(8232, "Gardening", 500, "https://storage.streamdps.com/iblock/304/304792b9ecf0559337cbd177eac7d286/87a750e1dfaf6d811af3d9970a64501d.webp"),
GOLD_MINE(5587, "Gold Mine", 1000, "https://storage.streamdps.com/iblock/d76/d766ebb3d04903c05a2f2d5883fd1cd7/7c99a5f7fed51db01ce85151e55e313e.png"),
GOLD_MINE(5587, "Gold Mine", 1000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/58cbff1bd592ae4365a450c4bf767f3a.png~tplv-obj.jpg"),
HAND_HEARTS(5660, "Hand Hearts", 100, "https://storage.streamdps.com/iblock/9ae/9aed27eb6e8cea1b14e14c2e15eb7308/4ccd4fad65bab7a9b8f9c66a321476b2.png"),
HAND_HEARTS(5660, "Hand Hearts", 100, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/6cd022271dc4669d182cad856384870f~tplv-obj.jpg"),
GUITAR(6723, "Guitar", 99, "https://storage.streamdps.com/iblock/95e/95e6348b4ebcc6a163b9be452f3ee3ff/84a43f426dabe8772de4d6002827b064.webp"),
@@ -927,7 +1051,7 @@ public enum Gift {
GUITAR_7883(7883, "Guitar", 99, "https://storage.streamdps.com/iblock/808/808c6a6e16e3ff0ee02479354102e337/ce5fe5c52bca407ac24c253361ec1968.webp"),
MIRROR_BLOOM(6200, "Mirror Bloom", 1000, "https://storage.streamdps.com/iblock/a68/a681c2ef079138e0e51cac719a2ec2b6/40f50e2272250dd118389987d09ab80b.png"),
MIRROR_BLOOM(6200, "Mirror Bloom", 1000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/a9d0e9406230fa9a901d992a90574e39~tplv-obj.jpg"),
CHEF_S_HAT(6725, "Chef's Hat", 199, "https://storage.streamdps.com/iblock/da8/da87653d13440ecbe3a6f04abb4e6314/08ab9e948762a6bb041bb1963cacf07f.webp"),
@@ -935,8 +1059,12 @@ public enum Gift {
OWL(5885, "Owl", 500, "https://storage.streamdps.com/iblock/e87/e87fc92de64aa711c6ce23ed3b2214c2/338e115665b1c9f75108b50a43adb95b.png"),
TOP_HOST(6194, "Top Host", 199, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/5947dc37282c417b411c61f20ee7d6d4~tplv-obj.png"),
TIKTOK_CROWN(8873, "TikTok Crown", 299, "https://storage.streamdps.com/iblock/a79/a790613bdf2e83725d0519bbf289529d/83bb670c15ab91b9192c50300f4c8054.webp"),
LOVED(6705, "Loved", 5, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/2a41781b0a29ba3c409c5dd83eed07f8~tplv-obj.png"),
ON_FIRE(6840, "On Fire", 200, "https://storage.streamdps.com/iblock/cba/cba95075d6b63b84fbc52abb9d1d8208/d93ecc0b966bf972f01e77339a68e124.webp"),
ON_FIRE_6958(6958, "On Fire", 200, "https://storage.streamdps.com/iblock/4ec/4ec314b4ee7dff4e92a8e1e75100dddf/19c9b5d8b5f24b1465632a31e55edca1.webp"),
@@ -947,9 +1075,11 @@ public enum Gift {
TELEPHONE_BOX(6381, "Telephone Box", 2100, "https://storage.streamdps.com/iblock/a2e/a2ee002433a7295464359db46c025adf/5f026787f952abbffd3d7fc1b4cbe1c2.webp"),
BOXING_GLOVES(6007, "Boxing Gloves", 299, "https://storage.streamdps.com/iblock/e4a/e4ac69d94221b6157d4381b779b0c7a5/2fbb331b9697c6515c9bb1a4487153a6.png"),
BOXING_GLOVES(6007, "Boxing Gloves", 299, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/9f8bd92363c400c284179f6719b6ba9c~tplv-obj.jpg"),
FERRIS_WHEEL(5652, "Ferris Wheel", 3000, "https://storage.streamdps.com/iblock/210/21071962989420fb8d118a8d84684707/837718d3a337816f89652d44ef970a90.png"),
FRUIT_FRIENDS(9465, "Fruit Friends", 299, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/1153dd51308c556cb4fcc48c7d62209f.png~tplv-obj.jpg"),
FERRIS_WHEEL(5652, "Ferris Wheel", 3000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/3c7291ad4c2a6d4f70505c3e296ecebe~tplv-obj.jpg"),
RUGBY_BALL(6249, "Rugby Ball", 10, "https://storage.streamdps.com/iblock/d53/d53d3efae1c69b949373db455da077cf/fa22f0507a304597b013268524a8573f.png"),
@@ -959,6 +1089,8 @@ public enum Gift {
GARDEN_GNOME(7002, "Garden Gnome", 1, "https://storage.streamdps.com/iblock/c1e/c1efcf386f4ffc5626e0be1ef1ecd93a/210fa9d66c1f0c1968608b40c4e698ea.webp"),
LILI_THE_LEOPARD(9467, "Lili the Leopard", 6599, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/7be03e1af477d1dbc6eb742d0c969372.png~tplv-obj.jpg"),
MUSIC_BOX(5964, "Music Box", 2399, "https://storage.streamdps.com/iblock/f01/f01f2da5e18be863eb7e3a1375bb6206/499e06f8f76e5e90964184c25365cdec.png"),
PRINCE(7398, "Prince", 500, "https://storage.streamdps.com/iblock/38b/38b4963191222c66267858149e662b7d/d98b625b2a3a261d2c12caaae61b479f.webp"),
@@ -977,7 +1109,7 @@ public enum Gift {
UNICORN_FANTASY_5475(5475, "Unicorn Fantasy", 5000, "https://storage.streamdps.com/iblock/b12/b129b116380a326df64aedb5a269b670/b1409c04e4d7490645dd39e76a078ae3.webp"),
UNICORN_FANTASY_5483(5483, "Unicorn Fantasy", 5000, "https://storage.streamdps.com/iblock/127/12778ef1e111b6342b11f778833bb346/ac4f70c4095012c8579e9cabef98e848.webp"),
UNICORN_FANTASY_5483(5483, "Unicorn Fantasy", 5000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/483c644e67e9bb1dd5970f2df00b7576.png~tplv-obj.jpg"),
UNICORN_FANTASY_7237(7237, "Unicorn Fantasy", 5000, "https://storage.streamdps.com/iblock/136/136dc4c068ddc7a89b10df8d9f4800d8/3b4f386e75506f3ad5519e4330888427.webp"),
@@ -993,9 +1125,9 @@ public enum Gift {
PIM_BEAR(9043, "Pim Bear", 1500, "https://storage.streamdps.com/iblock/204/2043f85b8f2e2ee638ff3a1799eda329/2319b052e0e64799842751d9fee4d438.webp"),
SIGNATURE_JET(7124, "Signature Jet", 4888, "https://storage.streamdps.com/iblock/681/6816084aca12a2bb0da2cf05174322f5/928ee6f6bfe12d363c1bbc7f8b03e7e0.webp"),
SIGNATURE_JET(7124, "Signature Jet", 4888, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/fe27eba54a50c0a687e3dc0f2c02067d~tplv-obj.jpg"),
CAP(6104, "Cap", 99, "https://storage.streamdps.com/iblock/349/349b158378b1b0f0fa447869c8f2e690/7a65e6037be114fa888bf04177a62f6a.png"),
CAP(6104, "Cap", 99, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/6c2ab2da19249ea570a2ece5e3377f04~tplv-obj.jpg"),
BLUE_BEAD(5319, "Blue Bead", 5, "https://storage.streamdps.com/iblock/afe/afe8100602b9b735b74ab34365032ec7/d778bfcb66bff177989590909b969ef2.png"),
@@ -1005,6 +1137,8 @@ public enum Gift {
STARS_SNAP(8581, "Stars Snap", 10, "https://storage.streamdps.com/iblock/318/318a8ce7e87f37f90bf5e3fbf773d827/e67f69439ae7c4bbf03bdaffd6e961a2.webp"),
BRAVO(7812, "Bravo", 1, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/b25e72d59e9771b09da8c8c70f395f82~tplv-obj.png"),
SUPERB_TEAM(8202, "Superb Team", 1, "https://storage.streamdps.com/iblock/e6e/e6e8cdd5e84f701dc627b8cc3e280d4c/29ce845878feb46152b20a75a3259d56.webp"),
GLOWING_JELLYFISH(8978, "Glowing Jellyfish", 1000, "https://storage.streamdps.com/iblock/e65/e65b1f71b4fe5709b454299439cb2674/36471857a2ba78694be934a54a0fa8d2.webp"),
@@ -1013,6 +1147,8 @@ public enum Gift {
NACHOS(7088, "Nachos", 9, "https://storage.streamdps.com/iblock/ff1/ff16cd1c796189ed8fcfdb019eb224ef/1ae8b0b05294c56b99197256fcaa3fd4.webp"),
SNAG(6411, "Snag", 5, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/aa2d9b162c766a7fdf71fcead6d7bbcd~tplv-obj.png"),
APPETIZERS(6106, "Appetizers", 19, "https://storage.streamdps.com/iblock/76b/76b94aaced493a2448cf655b5468feaf/8c1bea41ec9fb547f0a0eb46d658a1c8.png"),
LOVE_LETTER(7932, "Love Letter", 1, "https://storage.streamdps.com/iblock/a40/a40cb58d5e8c07fa3e46a9acb4e34f6f/477507a1b14df0a22ef895c6214f3789.webp"),
@@ -1023,11 +1159,15 @@ public enum Gift {
BUMPER_CARS(5996, "Bumper Cars", 1288, "https://storage.streamdps.com/iblock/53b/53b569311552b729d1b347268370e576/8f236deca90a65e7046f7576d69976af.png"),
CAKE_SLICE(6784, "Cake Slice", 1, "https://storage.streamdps.com/iblock/a1d/a1dfaa8ad7e0b7a164af7468971f8118/ad3a323fa40f3dd967e65049d2d0764f.webp"),
CAMPFIRE(5843, "Campfire", 388, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/e280eb1b7fe92b4efe612d98064d5a2d~tplv-obj.png"),
CAKE_SLICE(6784, "Cake Slice", 1, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/f681afb4be36d8a321eac741d387f1e2~tplv-obj.jpg"),
EXCLUSIVE_SPARK(9522, "Exclusive Spark", 1000, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/resource/f0bda1eb6856e2feea9cfcb6c575c8a0.png~tplv-obj.jpg"),
CROCODILE(8740, "Crocodile", 10, "https://storage.streamdps.com/iblock/4e2/4e2d9df24c472158b8ed93546fc73b16/75722a173b75d601e0a80a679902529f.webp"),
LOVE_YOU_6671(6671, "Love You", 199, "https://storage.streamdps.com/iblock/e7a/e7a3ea587e77f417c83596ad2a729f4e/fc521ab0494eb35cef33fde0c2b51555.webp"),
LOVE_YOU_6671(6671, "Love You", 199, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/134e51c00f46e01976399883ca4e4798~tplv-obj.jpg"),
NO_1_TEAM(8205, "No.1 Team", 5, "https://storage.streamdps.com/iblock/27f/27fe97cb0f1b8056fa0aedc918ea560e/966df61a39e36fe0f7237e55c3298117.webp"),
@@ -1039,9 +1179,13 @@ public enum Gift {
DIAMOND_CROWN_5604(5604, "Diamond Crown", 1499, "https://storage.streamdps.com/iblock/3b5/3b56c2352a02829ac4445094a3f76b51/738ad17c91919a940ee2001f9f262a95.png"),
COCONUT_DRINK(8225, "Coconut Drink", 5, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/ce27ad017f987240dc447e65ae866f4f~tplv-obj.png"),
M4_TROPHY(7544, "M4 Trophy", 450, "https://storage.streamdps.com/iblock/f40/f40a34a8e59806907deaa4f74df3462d/8deac28cb21517228bcd354645a987ea.webp"),
PERFUME(5658, "Perfume", 20, "https://storage.streamdps.com/iblock/8af/8af143c49ed92f431b6312185ea03b0a/cd5792b709a7f56cbb2b6669a0e13c29.png"),
FLOWER(6034, "Flower", 299, "https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/9c20971eeb28b6b4ba37e57df3983da0~tplv-obj.png"),
PERFUME(5658, "Perfume", 20, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/20b8f61246c7b6032777bb81bf4ee055~tplv-obj.jpg"),
KISS_YOUR_HEART(6661, "Kiss your Heart", 99, "https://storage.streamdps.com/iblock/13d/13d940df83e04a30523ca88c080ee8d8/213f06af314da4637a9ae8fc25bfaea3.webp"),
@@ -1063,7 +1207,7 @@ public enum Gift {
JETSKI(5774, "Jetski", 2199, "https://storage.streamdps.com/iblock/b38/b38473c5d43c224d986556d4134342c2/db8aa2a8f093a3475ff18116e54dd5c7.png"),
CORAL(5731, "Coral", 499, "https://storage.streamdps.com/iblock/cbe/cbe961d32956be86339a542b76faed88/cd807cda047c9eaf69c24162916ff1fd.png"),
CORAL(5731, "Coral", 499, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/d4faa402c32bf4f92bee654b2663d9f1~tplv-obj.jpg"),
PIRATE_S_SHIP(7598, "Pirates Ship", 15000, "https://storage.streamdps.com/iblock/475/4753e54cae562b34edbf1a157cd60b21/722409ec69cfaf707d611b0987799296.webp"),
@@ -1073,7 +1217,7 @@ public enum Gift {
WELCOME(6350, "Welcome", 9, "https://storage.streamdps.com/iblock/dda/ddaf400cc8b931bf1f1b2cdad4a9f7b0/2239c73a8edc68cfe66d2fae426d83bc.png"),
THUNDER_FALCON(8651, "Thunder Falcon", 39999, "https://storage.streamdps.com/iblock/b5d/b5dd904138691d16f6378e1f215fbc00/80a7b0ef77670cf6b7eb31fcae76fe80.webp"),
THUNDER_FALCON(8651, "Thunder Falcon", 39999, "https://p16-webcast.tiktokcdn.com/img/maliva/webcast-va/26f3fbcda383e6093a19b8e7351a164c~tplv-obj.jpg"),
BALLOONS(5756, "Balloons", 10, "https://storage.streamdps.com/iblock/462/462490a4e0da5abad033f4a57564041c/fe0831b660748b851ffd0e5a74847105.png");

View File

@@ -0,0 +1,82 @@
/*
* 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.http;
import lombok.Data;
import java.net.URI;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.*;
@Data
public class HttpData {
String url;
String method;
Map<String, List<String>> headers = new TreeMap<>();
Map<String, String> parameters = new TreeMap<>();
int status;
String body = "";
public static HttpData map(HttpRequest request) {
var data = new HttpData();
data.setUrl(request.uri().getPath());
data.setMethod(request.method());
data.setParameters(extractQueryParams(request.uri()));
data.setStatus(200);
if (request.bodyPublisher().isPresent()) {
data.setBody(request.bodyPublisher().get().toString());
}
data.setHeaders(Collections.unmodifiableMap(request.headers().map()));
return data;
}
public static HttpData map(HttpResponse<String> response) {
var data = new HttpData();
data.setUrl(response.uri().getPath());
data.setMethod(response.request().method());
data.setParameters(extractQueryParams(response.uri()));
data.setStatus(200);
data.setBody(response.body());
data.setHeaders(Collections.unmodifiableMap(response.headers().map()));
return data;
}
private static Map<String, String> extractQueryParams(URI uri) {
Map<String, String> params = new HashMap<>();
String query = uri.getQuery();
if (query != null && !query.isEmpty()) {
for (String param : query.split("&")) {
String[] keyValue = param.split("=");
if (keyValue.length > 1) {
params.put(keyValue[0], keyValue[1]);
} else {
params.put(keyValue[0], ""); // Empty value for parameter without explicit value
}
}
}
return params;
}
}

View File

@@ -45,6 +45,8 @@ public class User {
@Getter(AccessLevel.NONE)
private Set<UserAttribute> attributes;
public List<UserAttribute> getAttributes() {
return attributes.stream().toList();
}
@@ -107,6 +109,23 @@ public class User {
this.attributes = new HashSet<>();
}
public User(Long id,
String name,
String profileName,
Picture picture,
long following,
long followers,
List<Badge> badges) {
this.id = id;
this.name = name;
this.profileName = profileName;
this.picture = picture;
this.following = following;
this.followers = followers;
this.badges = badges;
this.attributes = new HashSet<>();
}
public User(Long userId,
String nickName) {
this.id = userId;

View File

@@ -26,15 +26,20 @@ package io.github.jwdeveloper.tiktok.exceptions;
/**
* Happens when incoming data from TikTok can not be mapped to TikTokEvent's
*/
public class TikTokMessageMappingException extends TikTokLiveException
{
public TikTokMessageMappingException(Class<?> inputClazz, Class<?> outputClass, Throwable throwable)
{
super("Unable to handle mapping from class: " + inputClazz.getSimpleName() + " to class " + outputClass.getSimpleName(),throwable);
public class TikTokMessageMappingException extends TikTokLiveException {
public TikTokMessageMappingException(Class<?> inputClazz, Class<?> outputClass, Throwable throwable) {
super("Unable to handle mapping from class: " + inputClazz.getSimpleName() + " to class " + outputClass.getSimpleName(), throwable);
}
public TikTokMessageMappingException(Class<?> inputClazz, Class<?> outputClass, String message)
{
super("Unable to handle mapping from class: " + inputClazz.getSimpleName() + " to class " + outputClass.getSimpleName()+": "+message);
public TikTokMessageMappingException(Class<?> inputClazz, Class<?> outputClass, String message) {
super("Unable to handle mapping from class: " + inputClazz.getSimpleName() + " to class " + outputClass.getSimpleName() + ": " + message);
}
public TikTokMessageMappingException(Class<?> inputClazz, String message, Throwable throwable) {
super("Unable to handle mapping from class: " + inputClazz.getSimpleName() + ": " + message, throwable);
}
public TikTokMessageMappingException(String message, Throwable throwable) {
super( message, throwable);
}
}

View File

@@ -31,4 +31,5 @@ public interface TikTokHttpRequest {
String get(String url);
String post(String url);
}

View File

@@ -22,6 +22,7 @@
*/
package io.github.jwdeveloper.tiktok.live;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.listener.ListenersManager;
import io.github.jwdeveloper.tiktok.listener.TikTokEventListener;
@@ -55,6 +56,11 @@ public interface LiveClient {
void disconnect();
/**
* Use to manually invoke event
*/
void publishEvent(TikTokEvent event);
/**
* Get information about gifts
*/

View File

@@ -22,14 +22,32 @@
*/
package io.github.jwdeveloper.tiktok.live;
import io.github.jwdeveloper.tiktok.data.models.RankingUser;
import io.github.jwdeveloper.tiktok.data.models.users.User;
import io.github.jwdeveloper.tiktok.models.ConnectionState;
import java.util.List;
public interface LiveRoomInfo
{
/**
*
* @return get current count of viewers of live
*/
int getViewersCount();
/**
*
* @return get total current count of viewers since beginning of live
*/
int getTotalViewersCount();
int getLikesCount();
long getStartTime();
boolean isAgeRestricted();
String getRoomId();
String getHostName();
String getTitle();
User getHostUser();
List<RankingUser> getUsersRanking();
ConnectionState getConnectionState();
}
}

View File

@@ -22,16 +22,19 @@
*/
package io.github.jwdeveloper.tiktok.live;
import io.github.jwdeveloper.tiktok.data.models.users.User;
import lombok.Data;
@Data
public class LiveRoomMeta {
private LiveRoomStatus status;
private boolean ageRestricted;
private String titie;
private int likeCount;
private int totalViewers;
private int viewers;
private User host;
public enum LiveRoomStatus
{

View File

@@ -26,8 +26,8 @@ import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.data.events.*;
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftComboEvent;
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftEvent;
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomEvent;
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomUserInfoEvent;
import io.github.jwdeveloper.tiktok.data.events.http.TikTokHttpResponseEvent;
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomInfoEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokFollowEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokJoinEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokLikeEvent;
@@ -39,52 +39,141 @@ import io.github.jwdeveloper.tiktok.data.events.websocket.TikTokWebsocketUnhandl
public interface EventsBuilder<T> {
T onRoom(EventConsumer<TikTokRoomEvent> event);
/**
* Invoked whenever specified event is triggered
*
* @param eventClass event class
* @param action action
*/
<E extends TikTokEvent> T onEvent(Class<E> eventClass, EventConsumer<E> action);
T onRoomUserInfo(EventConsumer<TikTokRoomUserInfoEvent> event);
T onComment(EventConsumer<TikTokCommentEvent> event);
/**
* Invoked whenever any event is triggered
*
* @param action
* @return
*/
T onEvent(EventConsumer<TikTokEvent> action);
T onWebsocketMessage(EventConsumer<TikTokWebsocketMessageEvent> event);
/**
* Invoked when information about room (live) got updated such as viewer count, etc..
*
* @param action
* @return
*/
T onRoomInfo(EventConsumer<TikTokRoomInfoEvent> action);
T onWebsocketResponse(EventConsumer<TikTokWebsocketResponseEvent> event);
/**
* Invoked when someone send message to chat
*
* @param action
* @return
*/
T onComment(EventConsumer<TikTokCommentEvent> action);
T onWebsocketUnhandledMessage(EventConsumer<TikTokWebsocketUnhandledMessageEvent> event);
T onGiftCombo(EventConsumer<TikTokGiftComboEvent> event);
T onGift(EventConsumer<TikTokGiftEvent> event);
/**
* Invoked when TikTokLiveJava makes http request and getting response
*
* @param action
* @return
*/
T onHttpResponse(EventConsumer<TikTokHttpResponseEvent> action);
T onQuestion(EventConsumer<TikTokQuestionEvent> event);
/**
* Invoked when TikTok protocolBuffer data "message" was successfully mapped to event
* events contains protocol-buffer "Message" and TikTokLiveJava "Event"
*
* @param action
* @return
*/
T onWebsocketMessage(EventConsumer<TikTokWebsocketMessageEvent> action);
T onSubscribe(EventConsumer<TikTokSubscribeEvent> event);
/**
* Invoked when there was not found event mapper for TikTok protocolBuffer data "message"
*
* @param action
* @return
*/
T onWebsocketUnhandledMessage(EventConsumer<TikTokWebsocketUnhandledMessageEvent> action);
T onFollow(EventConsumer<TikTokFollowEvent> event);
/**
* Invoked every time TikTok sends protocolBuffer data to websocket
* Response contains list of messages that are later mapped to events
* @param action
* @return
*/
T onWebsocketResponse(EventConsumer<TikTokWebsocketResponseEvent> action);
T onLike(EventConsumer<TikTokLikeEvent> event);
T onEmote(EventConsumer<TikTokEmoteEvent> event);
/**
* Invoked for gifts that has no combo, or when combo finishes
* @param action
* @return
*/
T onGift(EventConsumer<TikTokGiftEvent> action);
T onJoin(EventConsumer<TikTokJoinEvent> event);
/**
* Invoked for gifts that has combo options such as roses
* @param action
* @return
*/
T onGiftCombo(EventConsumer<TikTokGiftComboEvent> action);
T onShare(EventConsumer<TikTokShareEvent> event);
T onUnhandledSocial(EventConsumer<TikTokUnhandledSocialEvent> event);
T onLivePaused(EventConsumer<TikTokLivePausedEvent> event);
T onQuestion(EventConsumer<TikTokQuestionEvent> action);
T onLiveEnded(EventConsumer<TikTokLiveEndedEvent> event);
T onSubscribe(EventConsumer<TikTokSubscribeEvent> action);
T onConnected(EventConsumer<TikTokConnectedEvent> event);
T onFollow(EventConsumer<TikTokFollowEvent> action);
T onReconnecting(EventConsumer<TikTokReconnectingEvent> event);
T onLike(EventConsumer<TikTokLikeEvent> action);
T onDisconnected(EventConsumer<TikTokDisconnectedEvent> event);
T onEmote(EventConsumer<TikTokEmoteEvent> action);
T onError(EventConsumer<TikTokErrorEvent> event);
T onJoin(EventConsumer<TikTokJoinEvent> action);
T onEvent(EventConsumer<TikTokEvent> event);
T onShare(EventConsumer<TikTokShareEvent> action);
T onLivePaused(EventConsumer<TikTokLivePausedEvent> action);
T onLiveUnpaused(EventConsumer<TikTokLiveUnpausedEvent> action);
T onLiveEnded(EventConsumer<TikTokLiveEndedEvent> action);
/**
* Invoked when client has been successfully connected to live
* @param action
* @return
*/
T onConnected(EventConsumer<TikTokConnectedEvent> action);
/**
* Invoked when client tries to reconnect
* @param action
* @return
*/
T onReconnecting(EventConsumer<TikTokReconnectingEvent> action);
/**
* Invoked when client disconnected
* @param action
* @return
*/
T onDisconnected(EventConsumer<TikTokDisconnectedEvent> action);
/**
* Invoked when exception was throed inside client or event handler
* @param action
* @return
*/
T onError(EventConsumer<TikTokErrorEvent> action);
// TODO Figure out how those events works
// T onChest(EventConsumer<TikTokChestEvent> event);
//T onLinkMicFanTicket(TikTokEventConsumer<TikTokLinkMicFanTicketEvent> event);
//T onEnvelope(TikTokEventConsumer<TikTokEnvelopeEvent> event);

View File

@@ -23,20 +23,60 @@
package io.github.jwdeveloper.tiktok.live.builder;
import io.github.jwdeveloper.tiktok.ClientSettings;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.listener.TikTokEventListener;
import io.github.jwdeveloper.tiktok.live.LiveClient;
import io.github.jwdeveloper.tiktok.mappers.TikTokMapper;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import java.util.function.Function;
public interface LiveClientBuilder extends EventsBuilder<LiveClientBuilder> {
LiveClientBuilder configure(Consumer<ClientSettings> consumer);
/**
* This method is triggered after default mappings are registered
* It could be used to OVERRIDE behaviour of mappings and implement custom behaviour
*
* Be aware if for example you override WebcastGiftEvent, onGiftEvent() will not be working
*
* @param onCustomMappings lambda method
* @return
*/
LiveClientBuilder onMapping(Consumer<TikTokMapper> onCustomMappings);
/**
* Configuration of client settings
* @see ClientSettings
* @param onConfigure
* @return
*/
LiveClientBuilder configure(Consumer<ClientSettings> onConfigure);
/**
* @see TikTokEventListener
* Adding events listener class, its fancy way to register events without using lamda method
* but actual method in class that implements TikTokEventListener
* @return
*/
LiveClientBuilder addListener(TikTokEventListener listener);
/**
*
* @return LiveClient object
*/
LiveClient build();
/**
*
* @return LiveClient object and connects to TikTok live
*/
LiveClient buildAndConnect();
/**
*
* @return LiveClient object and connects to TikTok live asynchronously
*/
CompletableFuture<LiveClient> buildAndConnectAsync();
}

View File

@@ -0,0 +1,58 @@
/*
* 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;
import com.google.protobuf.GeneratedMessageV3;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.mappers.data.MappingAction;
import io.github.jwdeveloper.tiktok.mappers.data.MappingResult;
import java.util.function.Function;
public interface TikTokMapper {
/**
* * if mapper is not found for messageName, TikTokLiveException is thrown
*
* @param messageName
* @return TikTokMapperModel
*/
TikTokMapperModel forMessage(String messageName);
TikTokMapperModel forMessage(Class<? extends GeneratedMessageV3> mapperName);
TikTokMapperModel forMessage(String mapperName, MappingAction<MappingResult> onMapping);
TikTokMapperModel forMessage(Class<? extends GeneratedMessageV3> mapperName, MappingAction<MappingResult> onMapping);
TikTokMapperModel forMessage(Class<? extends GeneratedMessageV3> mapperName, Function<byte[], TikTokEvent> onMapping);
TikTokMapperModel forAnyMessage();
boolean isRegistered(String mapperName);
<T extends GeneratedMessageV3> boolean isRegistered(Class<T> mapperName);
}

View File

@@ -0,0 +1,68 @@
/*
* 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;
import com.google.protobuf.GeneratedMessageV3;
import io.github.jwdeveloper.tiktok.exceptions.TikTokMessageMappingException;
import io.github.jwdeveloper.tiktok.utils.ProtoBufferObject;
public interface TikTokMapperHelper {
/**
* @param bytes protocol buffer data bytes
* @param messageClass class that we want to serialize bytes to
* @param <T> @messageClass must be class that is made by protocol buffer
* @return object of type @messageClass
*/
<T extends GeneratedMessageV3> T bytesToWebcastObject(byte[] bytes, Class<T> messageClass);
/**
* @param bytes protocol buffer data bytes
* @param messageName class that we want to serialize bytes to
* @return protocol buffer objects if class for @messageName has been found
* @throws TikTokMessageMappingException if there is no suitable class for messageName
*/
Object bytesToWebcastObject(byte[] bytes, String messageName);
/**
* @param messageName checks wheaten TikTokLiveJava has class representation for certain protocol-buffer message name
* @return false if class is not found
*/
boolean isMessageHasProtoClass(String messageName);
/**
* @param bytes protocol buffer data bytes
* @return tree structure of protocol buffer object
* @see ProtoBufferObject
*/
ProtoBufferObject bytesToProtoBufferStructure(byte[] bytes);
/**
* Converts object to json
*
* @param obj any object
* @return pretty formatted json
*/
String toJson(Object obj);
}

View File

@@ -20,24 +20,39 @@
* 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.tools.collector.db;
package io.github.jwdeveloper.tiktok.mappers;
import io.github.jwdeveloper.tiktok.tools.collector.tables.TikTokMessageModel;
import io.github.jwdeveloper.tiktok.tools.collector.tables.TikTokResponseModel;
import org.jdbi.v3.sqlobject.config.RegisterBeanMapper;
import org.jdbi.v3.sqlobject.customizer.BindBean;
import org.jdbi.v3.sqlobject.statement.SqlQuery;
import org.jdbi.v3.sqlobject.statement.SqlUpdate;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.mappers.data.AfterMappingAction;
import io.github.jwdeveloper.tiktok.mappers.data.MappingAction;
import io.github.jwdeveloper.tiktok.mappers.data.MappingResult;
import java.util.List;
import java.util.function.Function;
@RegisterBeanMapper(TikTokResponseModel.class)
public interface TikTokResponseModelDAO
{
@SqlUpdate("INSERT INTO TikTokResponseModel (hostName, response, createdAt) " +
"VALUES (:hostName, :response, :createdAt)")
void insert(@BindBean TikTokResponseModel message);
public interface TikTokMapperModel {
@SqlQuery("SELECT * FROM TikTokResponseModel")
List<TikTokResponseModel> select();
/**
* @return name of websocket message that this mapper is mapping from
*/
String getSourceMessageName();
/**
* @param action Input bytes from websocket, you can modify it and returns different bytes
*/
TikTokMapperModel onBeforeMapping(MappingAction<byte[]> action);
/**
* @param action Input bytes from websocket. As output returns list of tiktok live events
*/
TikTokMapperModel onMapping(MappingAction<MappingResult> action);
/**
* @param action You can modify output list of TikTokLive events
* @see AfterMappingAction
*/
TikTokMapperModel onAfterMapping(Function<MappingResult, List<TikTokEvent>> action);
}

View File

@@ -0,0 +1,37 @@
/*
* 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.data;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import java.util.List;
@FunctionalInterface
public interface AfterMappingAction {
/**
* @param source object that was used as source to create events
* @param events list of events prepared before, could be modified or changed
* @return list of events that will be invoked
*/
List<TikTokEvent> onAfterMapping(Object source, List<TikTokEvent> events);
}

View File

@@ -0,0 +1,38 @@
/*
* 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.data;
import io.github.jwdeveloper.tiktok.mappers.TikTokMapperHelper;
@FunctionalInterface
public interface MappingAction<T> {
/**
* @param inputBytes incoming bytes from TikTok server. The represents protocol buffer message that was send to client
* @param messageName name of protocol buffer message
* @param mapperHelper utils and helper methods that can be use to debbug/display/deserialize protocol buffer data
* @return
*/
T onMapping(byte[] inputBytes, String messageName, TikTokMapperHelper mapperHelper);
}

View File

@@ -0,0 +1,53 @@
/*
* 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.data;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.List;
@AllArgsConstructor
@Getter
public class MappingResult
{
Object source;
List<TikTokEvent> events;
String message;
public static MappingResult of(Object source) {
return new MappingResult(source, List.of(),"");
}
public static MappingResult of(Object source, List<TikTokEvent> events) {
return new MappingResult(source, events,"");
}
public static MappingResult of(Object source,TikTokEvent events) {
return new MappingResult(source, List.of(events),"");
}
}

View File

@@ -25,8 +25,10 @@ package io.github.jwdeveloper.tiktok.utils;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.GsonBuilder;
import io.github.jwdeveloper.tiktok.data.dto.MessageMetaData;
import java.awt.*;
import java.time.Duration;
import java.util.ArrayList;
public class JsonUtil {
@@ -34,13 +36,25 @@ public class JsonUtil {
return new GsonBuilder()
.addSerializationExclusionStrategy(new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes fieldAttributes) {
public boolean shouldSkipField(FieldAttributes fieldAttributes)
{
return false;
}
@Override
public boolean shouldSkipClass(Class<?> aClass) {
return aClass.equals(Image.class);
public boolean shouldSkipClass(Class<?> aClass)
{
if(aClass.equals(Image.class))
{
return true;
}
if(aClass.equals(MessageMetaData.class))
{
return true;
}
return false;
}
})
.disableHtmlEscaping()

View File

@@ -0,0 +1,78 @@
/*
* 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;
import java.nio.file.Path;
import java.util.Map;
import java.util.TreeMap;
public class ProtoBufferFileGenerator {
public static String generate(ProtoBufferObject protoBuffObj, String name) {
var sb = new StringBuilder();
var offset = 2;
sb.append("message ").append(name).append(" { \n");
var objects = new TreeMap<String, ProtoBufferObject>();
var objectCounter = 0;
for (var entry : protoBuffObj.getFields().entrySet()) {
var index = entry.getKey();
var field = entry.getValue();
var fieldName = field.type.toLowerCase() + "Value";
var value = field.value;
if (field.value instanceof ProtoBufferObject object) {
fieldName += objectCounter;
value = "";
objects.put(fieldName,object);
objectCounter++;
}
for (var i = 0; i < offset; i++) {
sb.append(" ");
}
sb.append(field.type).append(" ").append(fieldName)
.append(" ")
.append("=")
.append(" ")
.append(index)
.append(";")
.append(" //")
.append(value)
.append("\n");
}
sb.append(" \n");
for(var object : objects.entrySet())
{
var structure = generate(object.getValue(),object.getKey());
sb.append(structure);
}
sb.append(" \n");
sb.append("} \n");
return sb.toString();
}
}

View File

@@ -0,0 +1,53 @@
/*
* 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;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
public class ProtoBufferJsonGenerator {
public static JsonObject genratejson(ProtoBufferObject protoBuffObj) {
JsonObject jsonObject = new JsonObject();
for (var entry : protoBuffObj.getFields().entrySet()) {
var fieldName = entry.getKey() + "_" + entry.getValue().type;
if (entry.getValue().value instanceof ProtoBufferObject protoObj)
{
JsonObject childJson = genratejson(protoObj);
jsonObject.add(fieldName, childJson);
continue;
}
var value = entry.getValue().value.toString();
jsonObject.addProperty(fieldName, value);
}
return jsonObject;
}
public static String generate(ProtoBufferObject protoBufferObject) {
var json = genratejson(protoBufferObject);
var gson = new GsonBuilder().setPrettyPrinting().create();
return gson.toJson(json);
}
}

View File

@@ -0,0 +1,98 @@
/*
* 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;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Map;
import java.util.TreeMap;
public class ProtoBufferObject {
@Getter
private final Map<Integer, ProtoBufferField> fields;
public ProtoBufferObject() {
this.fields = new TreeMap<>();
}
public void addField(int index, String type, Object value) {
fields.put(index, new ProtoBufferField(type, value));
}
public void addField(int index, ProtoBufferField value) {
fields.put(index, value);
}
public String toProtoFile()
{
return ProtoBufferFileGenerator.generate(this,"UnknownMessage");
}
public String toJson()
{
return ProtoBufferJsonGenerator.generate(this);
}
@Override
public String toString() {
return toString(0, true);
}
public String toString(int offset ,boolean nested) {
var sb = new StringBuilder();
sb.append("\n");
for (var entry : fields.entrySet()) {
var index = entry.getKey();
var field = entry.getValue();
for(var i =0;i<offset;i++)
{
sb.append(" ");
}
sb.append(index).append(" ")
.append(field.type).append(" ");
var value = field.value;
if (value instanceof ProtoBufferObject child) {
sb.append(child.toString(offset+2,nested));
} else {
sb.append(entry.getValue().value);
}
sb.append("\n");
}
return sb.toString();
}
@AllArgsConstructor
public class ProtoBufferField {
public String type;
public Object value;
}
}

View File

@@ -0,0 +1,116 @@
/*
* 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;
import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.UnknownFieldSet;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
import java.util.Base64;
public class ProtocolUtils {
public static String toBase64(byte[] bytes) {
return Base64.getEncoder().encodeToString(bytes);
}
public static String toBase64(WebcastResponse.Message bytes) {
return Base64.getEncoder().encodeToString(bytes.toByteArray());
}
public static byte[] fromBase64(String base64) {
return Base64.getDecoder().decode(base64);
}
public static ProtoBufferObject getProtocolBufferStructure(byte[] bytes) {
try {
var files = UnknownFieldSet.parseFrom(bytes);
var protoBufferObject = new ProtoBufferObject();
createStructure(files, protoBufferObject);
return protoBufferObject;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public static void createStructure(UnknownFieldSet unknownFieldSet, ProtoBufferObject root) throws InvalidProtocolBufferException {
for (var entry : unknownFieldSet.asMap().entrySet()) {
var objectValue = entry.getValue();
var type = "undefind";
Object value = null;
var index = entry.getKey();
if (!objectValue.getLengthDelimitedList().isEmpty()) {
var nestedObject = new ProtoBufferObject();
for (var str : objectValue.getLengthDelimitedList()) {
try {
var nestedFieldsSet = UnknownFieldSet.parseFrom(str);
createStructure(nestedFieldsSet, nestedObject);
} catch (Exception e)
{
type = "string";
value = str.toStringUtf8();
}
}
if (value != null) {
root.addField(index, "string", value);
} else {
root.addField(index, "object", nestedObject);
}
continue;
}
if (!objectValue.getFixed32List().isEmpty()) {
type = "Fixed32List";
value = objectValue.getFixed32List();
}
if (!objectValue.getFixed64List().isEmpty()) {
type = "Fixed64List";
value = objectValue.getFixed64List();
}
if (!objectValue.getGroupList().isEmpty()) {
type = "getGroupList";
value = objectValue.getGroupList();
}
if (!objectValue.getVarintList().isEmpty()) {
type = "int";
value = objectValue.getVarintList().get(0);
}
root.addField(index, type, value);
}
}
public static WebcastResponse.Message fromBase64ToMessage(String base64) throws InvalidProtocolBufferException {
var bytes = fromBase64(base64);
return WebcastResponse.Message.parseFrom(bytes);
}
}

View File

@@ -64,8 +64,8 @@ message Text {
string stringValue = 11;
oneof textPieceType
{
TextPieceUser userValue = 21;
TextPieceGift giftValue = 22;
TextPieceUser userValue = 21;
TextPieceGift giftValue = 22;
}
TextPiecePatternRef patternRefValue = 24;
}
@@ -155,7 +155,7 @@ message BadgeStruct {
message ProfileCardPanel {
bool useNewProfileCardStyle = 1;
// BadgeTextPosition badgeTextPosition = 2; // Enum
// BadgeTextPosition badgeTextPosition = 2; // Enum
ProjectionConfig projectionConfig = 3;
ProfileContent profileContent = 4;
}
@@ -973,4 +973,545 @@ message FanTicketRoomNoticeContent {
int64 MatchId = 3;
int64 EventTime = 4;
string FanTicketIconUrl = 5;
}
message LinkerAcceptNoticeContent {
int64 FromUserId = 1;
int64 FromRoomId = 2;
int64 ToUserId = 3;
}
message LinkerCancelContent {
int64 FromUserId = 1;
int64 ToUserId = 2;
int64 CancelType = 3;
int64 ActionId = 4;
}
message LinkerCloseContent {
}
message LinkerCreateContent {
int64 OwnerId = 1;
int64 OwnerRoomId = 2;
int64 LinkType = 3;
}
message LinkerEnterContent {
repeated User LinkedUsersList = 1;
// LinkmicMultiLiveEnum AnchorMultiLiveEnum = 2;
// Data.LinkmicUserSettingInfo AnchorSettingInfo = 3;
}
message LinkerInviteContent {
int64 FromUserId = 1;
int64 FromRoomId = 2;
string ToRtcExtInfo = 3;
bool RtcJoinChannel = 4;
int64 Vendor = 5;
string SecFromUserId = 6;
string ToLinkmicIdStr = 7;
User FromUser = 8;
int64 RequiredMicIdx = 9;
map<int64, string> RtcExtInfoMap = 10;
//Data.LinkmicMultiLiveEnum AnchorMultiLiveEnum = 11;
//Data.LinkmicUserSettingInfo AnchorSettingInfo = 12;
string InviterLinkmicIdStr = 13;
// InviteTopHostInfo FromTopHostInfo = 16;
int64 ActionId = 17;
// repeated LinkmicUserInfo LinkedUsersList = 18;
// Data.PerceptionDialogInfo Dialog = 19;
// Data.PunishEventInfo PunishInfo = 20;
int32 FromRoomAgeRestricted = 21;
// Data.Tag FromTag = 22;
// repeated Data.CohostABTestSetting AbTestSettingList = 23;
// Data.LinkerInviteMessageExtra LinkerInviteMsgExtra = 101;
}
message LinkerKickOutContent {
int64 FromUserId = 1;
//LinkMic.KickoutReason KickoutReason = 2;
}
message LinkerLeaveContent {
int64 UserId = 1;
string LinkmicIdStr = 2;
int64 SendLeaveUid = 3;
int64 LeaveReason = 4;
}
message LinkerLinkedListChangeContent {
repeated User LinkedUsersList = 1;
}
message LinkerListChangeContent {
repeated LinkLayerListUser LinkedUsersList = 1;
repeated LinkLayerListUser AppliedUsersList = 2;
repeated LinkLayerListUser ConnectingUsersList = 3;
}
message LinkerMediaChangeContent {
// MicIdxOperation Op = 1;
int64 ToUserId = 2;
int64 AnchorId = 3;
int64 RoomId = 4;
// LinkerSceneType ChangeScene = 5;
}
message LinkerMicIdxUpdateContent {
LinkerMicIdxUpdateInfo MicIdxUpdateInfo = 1;
}
message LinkerMicIdxUpdateInfo {
// MicIdxOperation Op = 1;
int64 UserId = 2;
int64 MicIdx = 3;
}
message LinkerMuteContent {
int64 UserId = 1;
// Data.MuteStatus Status = 2;
}
message LinkerRandomMatchContent {
User User = 1;
int64 RoomId = 2;
int64 InviteType = 3;
string MatchId = 4;
int64 InnerChannelId = 5;
}
message LinkerReplyContent {
int64 FromUserId = 1;
int64 FromRoomId = 2;
// LinkmicInfo FromUserLinkmicInfo = 3;
int64 ToUserId = 4;
// LinkmicInfo ToUserLinkmicInfo = 5;
int64 LinkType = 6;
int64 ReplyStatus = 7;
LinkerSetting LinkerSetting = 8;
User FromUser = 9;
User ToUser = 10;
map<int64, string> RtcExtInfoMap = 11;
LinkerMicIdxUpdateInfo InviteeMicIdxUpdateInfo = 12;
map<int64, int64> ApplierMicIdxInfoMap = 13;
// Data.LinkmicMultiLiveEnum AnchorMultiLiveEnum = 14;
// Data.LinkmicUserSettingInfo AnchorSettingInfo = 15;
int64 ActionId = 16;
// repeated LinkmicUserInfo LinkedUsersList = 17;
int64 SourceType = 18;
}
message LinkerSetting {
int64 MaxMemberLimit = 1;
int64 LinkType = 2;
int64 Scene = 3;
int64 OwnerUserId = 4;
int64 OwnerRoomId = 5;
int64 Vendor = 6;
}
message LinkerSysKickOutContent {
int64 UserId = 1;
string LinkmicIdStr = 2;
}
message LinkerUpdateUserContent {
int64 FromUserId = 1;
int64 ToUserId = 2;
map<string, string> UpdateInfoMap = 3;
}
message LinkerUpdateUserSettingContent {
// Data.LinkmicUserSettingInfo UpdateUserSettingInfo = 1;
}
message LinkerWaitingListChangeContent {
}
message LinkmicUserSettingInfo {
int64 userId = 1;
int64 layout = 2; // @warning Enum not found, should be Layout
int64 fixMicNum = 3; // @warning Enum not found, should be FixMicNum
int64 allowRequestFromUser = 4; // @warning Enum not found, should be AllowRequestFromUser
int64 allowRequestFromFollowerOnly = 5; // @warning Enum not found, should be AllowRequestFromFollowerOnly
LinkmicApplierSortSetting applierSortSetting = 7; // Enum
}
message Player {
int64 roomId = 1;
int64 userId = 2;
}
message AllListUser {
repeated LinkLayerListUser linkedList = 2;
repeated LinkLayerListUser appliedList = 3;
repeated LinkLayerListUser invitedList = 4;
repeated LinkLayerListUser readyList = 5;
}
message LinkLayerListUser {
User user = 1;
int64 linkmicId = 2;
Position pos = 3;
int64 linkedTimeNano = 4;
string appVersion = 5;
int64 magicNumber1 = 7;
}
message Position {
int32 type = 1;
LinkPosition link = 2;
}
message LinkPosition {
int32 position = 1;
int32 opt = 2;
}
message GroupPlayer {
int64 channelId = 1;
User user = 2;
}
message DSLConfig {
int32 sceneVersion = 1;
string layoutId = 2;
}
message GroupChannelAllUser {
int64 groupChannelId = 1;
repeated GroupChannelUser userList = 2;
}
message GroupChannelUser {
int64 channelId = 1;
GroupStatus status = 2; // Enum
TextType type = 3; // Enum
AllListUser allUser = 4;
int64 joinTime = 5;
int64 linkedTime = 6;
GroupPlayer ownerUser = 7;
}
message RTCExtraInfo {
RTCEngineConfig liveRtcEngineConfig = 1;
repeated RTCLiveVideoParam liveRtcVideoParamList = 2;
RTCBitrateMap rtcBitrateMap = 3;
int32 rtcFps = 4;
string rtcBusinessId = 8;
int32 interactClientType = 10;
message RTCEngineConfig {
string rtcAppId = 1;
string rtcUserId = 2;
string rtcToken = 3;
int64 rtcChannelId = 4;
}
message RTCLiveVideoParam {
int32 strategyId = 1;
RTCVideoParam params = 2;
}
message RTCVideoParam {
int32 width = 1;
int32 height = 2;
int32 fps = 3;
int32 bitrateKbps = 4;
}
message RTCBitrateMap {
int32 xx1 = 1;
int32 xx2 = 2;
int32 xx3 = 3;
int32 xx4 = 4;
}
}
message CreateChannelContent {
Player owner = 1;
string ownerLinkMicId = 2;
}
message ListChangeContent {
TextType type = 1; // Enum
AllListUser list = 2;
}
message MultiLiveContent {
InviteBizContent inviteBizContent = 2;
ReplyBizContent replyBizContent = 3;
PermitBizContent permitBizContent = 4;
KickOutBizContent kickOutBizContent = 6;
message InviteBizContent {
LinkmicUserSettingInfo anchorSettingInfo = 1;
int64 inviteSource = 2; // @warning Enum not found, should be InviteSource
User operatorUserInfo = 3;
int64 operatorLinkAdminType = 4; // @warning Enum not found, should be OperatorLinkAdminType
User inviteeUserInfo = 5;
}
message ReplyBizContent {
int32 linkType = 1;
int32 isTurnOffInvitation = 2;
User replyUserInfo = 3;
}
message PermitBizContent {
LinkmicUserSettingInfo anchorSettingInfo = 1;
int64 expireTimestamp = 2;
User operatorUserInfo = 3;
int64 operatorLinkAdminType = 4; // @warning Enum not found, should be OperatorLinkAdminType
}
message KickOutBizContent {
User operatorUserInfo = 1;
int64 operatorLinkAdminType = 2; // @warning Enum not found, should be OperatorLinkAdminType
User kickPlayerUserInfo = 3;
}
}
message InviteContent {
Player invitor = 1;
RTCExtraInfo inviteeRtcExtInfo = 2;
string invitorLinkMicId = 3;
string inviteeLinkMicId = 4;
bool isOwner = 5;
Position pos = 6;
DSLConfig dsl = 7;
User invitee = 8;
User operator = 9;
}
// @ApplyContent
// proto.webcast.im
// C:\Users\ja\RiderProjects\TikTokProBufferGenerator\Application\output\sources\test.js
message ApplyContent {
Player applier = 1;
string applierLinkMicId = 2;
}
// @PermitApplyContent
// proto.webcast.im
// C:\Users\ja\RiderProjects\TikTokProBufferGenerator\Application\output\sources\test.js
message PermitApplyContent {
Player permiter = 1;
string permiterLinkMicId = 2;
Position applierPos = 3;
ReplyStatus replyStatus = 4; // Enum
DSLConfig dsl = 5;
User applier = 6;
User operator = 7;
string applierLinkMicId = 8;
}
// @ReplyInviteContent
// proto.webcast.im
// C:\Users\ja\RiderProjects\TikTokProBufferGenerator\Application\output\sources\test.js
message ReplyInviteContent {
Player invitee = 1;
ReplyStatus replyStatus = 2; // Enum
string inviteeLinkMicId = 3;
Position inviteePos = 4;
Player inviteOperatorUser = 5;
}
// @KickOutContent
// proto.webcast.im
// C:\Users\ja\RiderProjects\TikTokProBufferGenerator\Application\output\sources\test.js
message KickOutContent {
Player offliner = 1;
KickoutReason kickoutReason = 2; // Enum
}
// @CancelApplyContent
// proto.webcast.im
// C:\Users\ja\RiderProjects\TikTokProBufferGenerator\Application\output\sources\test.js
message CancelApplyContent {
Player applier = 1;
string applierLinkMicId = 2;
}
// @CancelInviteContent
// proto.webcast.im
// C:\Users\ja\RiderProjects\TikTokProBufferGenerator\Application\output\sources\test.js
message CancelInviteContent {
Player invitor = 1;
string invitorLinkMicId = 2;
string inviteeLinkMicId = 3;
int64 inviteSeqId = 4;
Player invitee = 5;
}
// @LeaveContent
// proto.webcast.im
// C:\Users\ja\RiderProjects\TikTokProBufferGenerator\Application\output\sources\test.js
message LeaveContent {
Player leaver = 1;
int64 leaveReason = 2;
}
// @FinishChannelContent
// proto.webcast.im
// C:\Users\ja\RiderProjects\TikTokProBufferGenerator\Application\output\sources\test.js
message FinishChannelContent {
Player owner = 1;
int64 finishReason = 2;
}
// @JoinDirectContent
// proto.webcast.im
// C:\Users\ja\RiderProjects\TikTokProBufferGenerator\Application\output\sources\test.js
message JoinDirectContent {
LinkLayerListUser joiner = 1;
AllListUser allUsers = 2;
}
// @LeaveJoinGroupContent
// proto.webcast.im
// C:\Users\ja\RiderProjects\TikTokProBufferGenerator\Application\output\sources\test.js
message LeaveJoinGroupContent {
GroupPlayer operator = 1;
int64 groupChannelId = 2;
string leaveSource = 3;
}
// @PermitJoinGroupContent
// proto.webcast.im
message PermitJoinGroupContent {
GroupPlayer approver = 1;
AgreeStatus agreeStatus = 2; // Enum
TextType type = 3; // Enum
repeated RTCExtraInfo groupExtInfoList = 4;
GroupChannelAllUser groupUser = 5;
}
// @CancelJoinGroupContent
// proto.webcast.im
message CancelJoinGroupContent {
repeated GroupPlayer leaverList = 1;
GroupPlayer operator = 2;
TextType type = 3; // Enum
}
message P2PGroupChangeContent {
repeated RTCExtraInfo groupExtInfoList = 1;
GroupChannelAllUser groupUser = 2;
}
message BusinessContent {
int64 overLength = 1;
MultiLiveContent multiLiveContent = 100;
CohostContent cohostContent = 200;
message CohostContent {
JoinGroupBizContent joinGroupBizContent = 1;
}
message JoinGroupBizContent {
int32 fromRoomAgeRestricted = 1;
Tag fromTag = 2;
PerceptionDialogInfo dialog = 3;
PunishEventInfo punishInfo = 4;
JoinGroupMessageExtra joinGroupMsgExtra = 101;
}
message Tag {
int32 tagType = 1;
string tagValue = 2;
string tagText = 3;
}
message PerceptionDialogInfo {
int64 iconType = 1; // @warning Enum not found, should be IconType
Text title = 2;
Text subTitle = 3;
Text adviceActionText = 4;
Text defaultActionText = 5;
string violationDetailUrl = 6;
int32 scene = 7;
int64 targetUserId = 8;
int64 targetRoomId = 9;
int64 countDownTime = 10;
bool showFeedback = 11;
repeated PerceptionFeedbackOption feedbackOptionsList = 12;
int64 policyTip = 13;
}
message PerceptionFeedbackOption {
int64 id = 1;
string contentKey = 2;
}
message JoinGroupMessageExtra {
int64 sourceType = 1;
RivalExtra extra = 2;
repeated RivalExtra otherUsersList = 3;
// @RivalExtra
// proto.webcast.im.JoinGroupMessageExtra
// C:\Users\ja\RiderProjects\TikTokProBufferGenerator\Application\output\sources\test.js
message RivalExtra {
int64 userCount = 4;
Image avatarThumb = 5;
string displayId = 6;
AuthenticationInfo authenticationInfo = 7;
string nickname = 8;
int64 followStatus = 9;
Hashtag hashtag = 10;
TopHostInfo topHostInfo = 11;
int64 userId = 12;
bool isBestTeammate = 13;
message AuthenticationInfo {
string customVerify = 1;
string enterpriseVerifyReason = 2;
Image authenticationBadge = 3;
}
}
}
message Hashtag {
int64 id = 1;
string title = 2;
Image image = 3;
HashtagNamespace namespace = 4; // Enum
}
message TopHostInfo {
string rankType = 1;
int64 topIndex = 2;
}
}
message JoinGroupContent {
GroupChannelAllUser groupUser = 1;
GroupPlayer joinUser = 2;
TextType type = 3; // Enum
}

View File

@@ -25,6 +25,85 @@ enum EmotePrivateType {
EMOTE_PRIVATE_TYPE_SUB_WAVE = 1;
}
enum TextType {
DISPLAY_TEXT = 0;
CONTENT = 1;
}
enum LinkmicApplierSortSetting {
LINKMIC_APPLIER_SORT_SETTING_NONE = 0;
LINKMIC_APPLIER_SORT_SETTING_BY_GIFT_SCORE = 1;
}
enum HashtagNamespace {
GLOBAL = 0;
GAMING = 1;
}
enum AgreeStatus {
AGREE_UNKNOWN = 0;
AGREE = 1;
REJECT = 2;
}
enum KickoutReason {
KICKOUT_REASON_UNKNOWN = 0;
KICKOUT_REASON_FIRST_FRAME_TIMEOUT = 1;
KICKOUT_REASON_BY_HOST = 2;
KICKOUT_REASON_RTC_LOST_CONNECTION = 3;
KICKOUT_REASON_BY_PUNISH = 4;
KICKOUT_REASON_BY_ADMIN = 5;
KICKOUT_REASON_HOST_REMOVE_ALL_GUESTS = 6;
}
enum GroupStatus {
GROUP_STATUS_UNKNOWN = 0;
GROUP_STATUS_WAITING = 1;
GROUP_STATUS_LINKED = 3;
}
enum BusinessCase {
BUSINESS_NOT_SET = 0;
APPLY_BIZ_CONTENT = 1;
INVITE_BIZ_CONTENT = 2;
REPLY_BIZ_CONTENT = 3;
PERMIT_BIZ_CONTENT = 4;
JOIN_DIRECT_BIZ_CONTENT = 5;
KICK_OUT_BIZ_CONTENT = 6;
LIST_CHANGE_BIZ_CONTENT = 11;
MULTI_LIVE_CONTENT = 100;
COHOST_CONTENT = 200;
}
enum ReplyStatus {
REPLY_STATUS_UNKNOWN = 0;
REPLY_STATUS_AGREE = 1;
REPLY_STATUS_REFUSE_PERSONALLY = 2;
REPLY_STATUS_REFUSE_TYPE_NOT_SUPPORT = 3;
REPLY_STATUS_REFUSE_PROCESSING_INVITATION = 4;
REPLY_STATUS_REFUSE_BY_TIMEOUT = 5;
REPLY_STATUS_REFUSE_EXCEPTION = 6;
REPLY_STATUS_REFUSE_SYSTEM_NOT_SUPPORTED = 7;
REPLY_STATUS_REFUSE_SUBTYPE_DIFFERENCE = 8;
REPLY_STATUS_REFUSE_IN_MICROOM = 9;
REPLY_STATUS_REFUSE_NOT_LOAD_PLUGIN = 10;
REPLY_STATUS_REFUSE_IN_MULTI_GUEST = 11;
REPLY_STATUS_REFUSE_PAUSE_LIVE = 12;
REPLY_STATUS_REFUSE_OPEN_CAMERA_DIALOG_SHOWING = 13;
REPLY_STATUS_REFUSE_DRAW_GUESSING = 14;
REPLY_STATUS_REFUSE_RANDOM_MATCHING = 15;
REPLY_STATUS_REFUSE_IN_MATCH_PROCESSING = 16;
REPLY_STATUS_REFUSE_IN_MICROOM_FOR_MULTI_COHOST = 17;
REPLY_STATUS_REFUSE_COHOST_FINISHED = 18;
REPLY_STATUS_REFUSE_NOT_CONNECTED = 19;
REPLY_STATUS_REFUSE_LINKMIC_FULL = 20;
REPLY_STATUS_REFUSE_ARC_INCOMPATIBLE = 21;
REPLY_STATUS_REFUSE_PROCESSING_OTHER_INVITE = 22;
REPLY_STATUS_REFUSE_PROCESSING_OTHER_APPLY = 23;
REPLY_STATUS_REFUSE_IN_ANCHOR_COHOST = 24;
REPLY_STATUS_REFUSE_TOPIC_PAIRING = 25;
}
enum SubscribeType {
SUBSCRIBETYPE_ONCE = 0;
@@ -68,6 +147,7 @@ enum MemberMessageAction {
enum ControlAction {
ControlActionUNKNOWN = 0;
STREAM_PAUSED = 1; // Stream Paused by Host
STREAM_UNPAUSED = 2;
STREAM_ENDED = 3; // Stream Ended by Host
}
@@ -110,4 +190,76 @@ enum BarrageType
FansLevelUpgrade = 10;
FansLevelEntrance = 11;
GamePartnership = 12;
}
enum EnvelopeBusinessType
{
BusinessTypeUnknown = 0;
BusinessTypeUserDiamond = 1;
BusinessTypePlatformDiamond = 2;
BusinessTypePlatformShell = 3;
BusinessTypePortal = 4;
BusinessTypePlatformMerch = 5;
BusinessTypeEoYDiamond = 6;
BusinessTypeFanClubGtM = 7;
}
enum EnvelopeFollowShowStatus
{
EnvelopeFollowShowUnknown = 0;
EnvelopeFollowShow = 1;
EnvelopeFollowNotShow = 2;
}
enum EnvelopeDisplay
{
EnvelopeDisplayUnknown = 0;
EnvelopeDisplayNew = 1;
EnvelopeDisplayHide = 2;
}
enum CommonContentCase {
COMMON_CONTENT_NOT_SET = 0;
CREATE_CHANNEL_CONTENT = 100;
LIST_CHANGE_CONTENT = 102;
INVITE_CONTENT = 103;
APPLY_CONTENT = 104;
PERMIT_APPLY_CONTENT = 105;
REPLY_INVITE_CONTENT = 106;
KICK_OUT_CONTENT = 107;
CANCEL_APPLY_CONTENT = 108;
CANCEL_INVITE_CONTENT = 109;
LEAVE_CONTENT = 110;
FINISH_CONTENT = 111;
JOIN_DIRECT_CONTENT = 112;
JOIN_GROUP_CONTENT = 113;
PERMIT_GROUP_CONTENT = 114;
CANCEL_GROUP_CONTENT = 115;
LEAVE_GROUP_CONTENT = 116;
P2P_GROUP_CHANGE_CONTENT = 117;
GROUP_CHANGE_CONTENT = 118;
}
enum MessageType {
MESSAGETYPE_SUBSUCCESS = 0;
MESSAGETYPE_ANCHORREMINDER = 1;
MESSAGETYPE_ENTERROOMEXPIRESOON = 2;
MESSAGETYPE_SUBGOALCREATETOANCHOR = 3;
MESSAGETYPE_SUBGOALCOMPLETETOAUDIENCE = 4;
MESSAGETYPE_SUBGOALCOMPLETETOANCHOR = 5;
MESSAGETYPE_SUBGIFTTIKTOK2USERNOTICE = 6;
MESSAGETYPE_SUBGIFTTIKTOK2ANCHORNOTICE = 7;
MESSAGETYPE_SUBGIFTTRECEIVESENDNOTICE = 8;
MESSAGETYPE_SUBGIFTSENDSUCCEEDROOMMESSAGE = 9;
MESSAGETYPE_SUBGIFTSENDSUCCEEDANCHORNOTICE = 10;
MESSAGETYPE_SUBGIFTLOWVERSIONUPGRADENOTICE = 11;
MESSAGETYPE_SUBGIFTUSERBUYAUTHNOTICE = 12;
}
enum Scene {
SCENE_UNKNOWN = 0;
SCENE_CO_HOST = 2;
SCENE_MULTI_LIVE = 4;
}

View File

@@ -18,7 +18,7 @@ message WebcastPushFrame {
uint64 LogId = 2;
uint64 Service = 3;
uint64 Method = 4;
map<string,string> headers = 5;
map<string, string> headers = 5;
string PayloadEncoding = 6;
string PayloadType = 7;
bytes Payload = 8;
@@ -81,6 +81,13 @@ message WebcastGiftMessage {
bool isFirstSent = 25;
string orderId = 28;
UserIdentity userIdentity = 32;
UserGiftReciever userGiftReciever = 23;
message UserGiftReciever
{
int64 userId = 1;
string deviceName = 10;
}
message GiftIMPriority {
repeated int64 queueSizesList = 1;
@@ -177,6 +184,8 @@ message WebcastCaptionMessage {
}
}
// Comment sent by User
//@WebcastChatMessage
message WebcastChatMessage {
@@ -195,7 +204,7 @@ message WebcastChatMessage {
int32 quickChatScene = 16;
int32 communityFlaggedStatus = 17;
UserIdentity UserIdentity = 18;
map<int32,string> CommentQualityScores = 19;
map<int32, string> CommentQualityScores = 19;
// @EmoteWithIndex
// proto.webcast.im.ChatMessage
@@ -246,13 +255,13 @@ message WebcastEmoteChatMessage {
message WebcastEnvelopeMessage {
Common common = 1;
EnvelopeInfo envelopeInfo = 2;
int64 display = 3; // @warning Enum not found, should be Display
EnvelopeDisplay display = 3; // @warning Enum not found, should be Display
// @EnvelopeInfo
// proto.webcast.im.EnvelopeMessage
message EnvelopeInfo {
string envelopeId = 1;
int64 businessType = 2; // @warning Enum not found, should be BusinessType
EnvelopeBusinessType businessType = 2;
string envelopeIdc = 3;
string sendUserName = 4;
int32 diamondCount = 5;
@@ -262,7 +271,7 @@ message WebcastEnvelopeMessage {
Image sendUserAvatar = 9;
string createAt = 10;
string roomId = 11;
int64 followShowStatus = 12; // @warning Enum not found, should be FollowShowStatus
EnvelopeFollowShowStatus followShowStatus = 12; // @warning Enum not found, should be FollowShowStatus
int32 skinId = 13;
}
}
@@ -275,14 +284,14 @@ message WebcastGoalUpdateMessage {
int64 contributorId = 4;
Image contributorAvatar = 5;
string contributorDisplayId = 6;
// SubGoal contributeSubgoal = 7;
// SubGoal contributeSubgoal = 7;
int64 contributeCount = 9;
int64 contributeScore = 10;
int64 giftRepeatCount = 11;
string contributorIdStr = 12;
bool pin = 13;
bool unpin = 14;
// GoalPinInfo pinInfo = 15;
// GoalPinInfo pinInfo = 15;
}
// Message related to Chat-moderation?
@@ -346,7 +355,7 @@ message WebcastSocialMessage {
message WebcastSubNotifyMessage {
Common common = 1;
User user = 2;
// ExhibitionType exhibitionType = 3; // Enum
// ExhibitionType exhibitionType = 3; // Enum
int64 subMonth = 4;
SubscribeType subscribeType = 5; // Enum
OldSubscribeStatus oldSubscribeStatus = 6; // Enum
@@ -440,7 +449,7 @@ message WebcastMemberMessage {
//@WebcastPollMessage
message WebcastPollMessage {
Common common = 1;
int32 messageType = 2;
MessageType messageType = 2;
int64 pollId = 3;
PollStartContent startContent = 4;
PollEndContent endContent = 5;
@@ -505,6 +514,9 @@ message WebcastHourlyRankMessage {
}
}
//<Battles>
//@WebcastLinkMicArmies
message WebcastLinkMicArmies {
Common common = 1;
@@ -521,6 +533,45 @@ message WebcastLinkMicArmies {
uint32 data4 = 12;
uint32 data5 = 13;
}
//@WebcastLinkMicBattlePunishFinish
message WebcastLinkMicBattlePunishFinish {
Common Header = 1;
uint64 Id1 = 2;
uint64 Timestamp = 3;
uint32 Data4 = 4;
uint64 Id2 = 5;
LinkMicBattlePunishFinishData Data6 = 6;
message LinkMicBattlePunishFinishData {
uint64 Id2 = 1; // Same as Id2 in outer object (loser?)
uint64 Timestamp = 2;
uint32 Data3 = 3;
uint64 Id1 = 4; // Same as Id1 in outer object (winner?)
uint32 Data5 = 5;
uint32 Data6 = 6;
uint32 Data8 = 8;
}
}
//@WebcastLinkmicBattleTaskMessage
message WebcastLinkmicBattleTaskMessage {
Common Header = 1;
uint32 Data2 = 2;
LinkmicBattleTaskData Data3 = 3;
LinkmicBattleTaskData2 Data5 = 5;
message LinkmicBattleTaskData {
BattleTaskData Data1 = 1;
}
message BattleTaskData {
uint32 Data1 = 1;
}
message LinkmicBattleTaskData2 {
uint32 Data1 = 1;
uint32 Data2 = 2;
}
}
//@WebcastLinkMicBattle
message WebcastLinkMicBattle {
@@ -570,11 +621,10 @@ message WebcastLinkMicFanTicketMethod {
Common common = 1;
FanTicketRoomNoticeContent FanTicketRoomNotice = 2;
}
//@WebcastLinkMicMethod
message WebcastLinkMicMethod {
Common common = 1;
int64 messageType = 2;
MessageType messageType = 2;
string accessKey = 3;
int64 anchorLinkmicId = 4;
int64 userId = 5;
@@ -588,6 +638,8 @@ message WebcastLinkMicMethod {
int64 inviteUid = 13;
}
//<Battles>
//@WebcastLiveIntroMessage
message WebcastLiveIntroMessage {
Common common = 1;
@@ -630,7 +682,7 @@ message WebcastMsgDetectMessage {
bool detectP2PMsg = 3;
bool detectRoomMsg = 4;
bool httpOptimize = 5;
}
}
}
//@WebcastOecLiveShoppingMessage
@@ -681,39 +733,63 @@ message WebcastSystemMessage {
//@WebcastLinkMessage
message WebcastLinkMessage {
Common common = 1;
uint32 data1 = 2;
uint64 data2 = 3;
uint32 data3 = 4;
LinkMessageData data = 18;
LinkMessageUserContainer user = 20;
string token = 200;
message LinkMessageData {
DataContainer data = 1; // index 1 is an Id
}
message LinkMessageUserContainer {
LinkMessageUser user = 1;
repeated LinkMessageUser otherUsers = 2;
message LinkMessageUser {
User user = 1;
uint64 timeStamp = 2;
uint32 data1 = 4;
string idString = 5;
uint32 data2 = 7;
}
}
MessageType MessageType = 2;
int64 LinkerId = 3;
Scene Scene = 4;
LinkerInviteContent InviteContent = 5;
LinkerReplyContent ReplyContent = 6;
LinkerCreateContent CreateContent = 7;
LinkerCloseContent CloseContent = 8;
LinkerEnterContent EnterContent = 9;
LinkerLeaveContent LeaveContent = 10;
LinkerCancelContent CancelContent = 11;
LinkerKickOutContent KickOutContent = 12;
LinkerLinkedListChangeContent LinkedListChangeContent = 13;
LinkerUpdateUserContent UpdateUserContent = 14;
LinkerWaitingListChangeContent WaitingListChangeContent = 15;
LinkerMuteContent MuteContent = 16;
LinkerRandomMatchContent RandomMatchContent = 17;
LinkerUpdateUserSettingContent UpdateUserSettingContent = 18;
LinkerMicIdxUpdateContent MicIdxUpdateContent = 19;
LinkerListChangeContent ListChangeContent = 20;
// CohostListChangeContent CohostListChangeContent = 21;
LinkerMediaChangeContent MediaChangeContent = 22;
LinkerAcceptNoticeContent ReplyAcceptNoticeContent = 23;
LinkerSysKickOutContent SysKickOutContent = 101;
// LinkmicUserToastContent UserToastContent = 102;
string Extra = 200;
int64 ExpireTimestamp = 201;
string TransferExtra = 202;
}
//@WebcastLinkLayerMessage
// @WebcastLinkLayerMessage
message WebcastLinkLayerMessage {
Common common = 1;
LinkLayerMessageType messageType = 2;
MessageType messageType = 2; // Enum
int64 channelId = 3;
Scene scene = 4; // Enum
CreateChannelContent createChannelContent = 100;
ListChangeContent listChangeContent = 102;
InviteContent inviteContent = 103;
ApplyContent applyContent = 104;
PermitApplyContent permitApplyContent = 105;
ReplyInviteContent replyInviteContent = 106;
KickOutContent kickOutContent = 107;
CancelApplyContent cancelApplyContent = 108;
CancelInviteContent cancelInviteContent = 109;
LeaveContent leaveContent = 110;
FinishChannelContent finishContent = 111;
JoinDirectContent joinDirectContent = 112;
JoinGroupContent joinGroupContent = 113;
PermitJoinGroupContent permitGroupContent = 114;
CancelJoinGroupContent cancelGroupContent = 115;
LeaveJoinGroupContent leaveGroupContent = 116;
P2PGroupChangeContent p2pGroupChangeContent = 117;
BusinessContent businessContent = 200;
}
// @RoomVerifyMessage
message RoomVerifyMessage {
Common common = 1;
int32 action = 2;

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>TikTokLiveJava</artifactId>
<groupId>io.github.jwdeveloper.tiktok</groupId>
<version>1.0.0-Release</version>
<version>1.0.13-Release</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -41,12 +41,28 @@
<artifactId>Java-WebSocket</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version> <!-- Use the desired TestNG version -->
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<argLine>-Xmx512m</argLine>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>

View File

@@ -23,12 +23,69 @@
package io.github.jwdeveloper.tiktok;
import io.github.jwdeveloper.tiktok.http.TikTokDataChecker;
import io.github.jwdeveloper.tiktok.live.builder.LiveClientBuilder;
import java.util.concurrent.CompletableFuture;
public class TikTokLive
{
/**
*
* @param hostName profile name of Tiktok user could be found in profile link
* example: https://www.tiktok.com/@dostawcavideo hostName would be dostawcavideo
* @return LiveClientBuilder
*/
public static LiveClientBuilder newClient(String hostName)
{
return new TikTokLiveClientBuilder(hostName);
}
/**
*
* @param hostName profile name of Tiktok user could be found in profile link
* example: https://www.tiktok.com/@dostawcavideo hostName would be dostawcavideo
* @return true if live is Online, false if is offline
*/
public static boolean isLiveOnline(String hostName)
{
return new TikTokDataChecker().isOnline(hostName);
}
/**
*
* @param hostName profile name of Tiktok user could be found in profile link
* example: https://www.tiktok.com/@dostawcavideo hostName would be dostawcavideo
* @return true if live is Online, false if is offline
*/
public static CompletableFuture<Boolean> isLiveOnlineAsync(String hostName)
{
return new TikTokDataChecker().isOnlineAsync(hostName);
}
/**
*
* @param hostName profile name of Tiktok user could be found in profile link
* example: https://www.tiktok.com/@dostawcavideo hostName would be dostawcavideo
* @return true is hostName name is valid and exists, false if not
*/
public static boolean isHostNameValid(String hostName)
{
return new TikTokDataChecker().isHostNameValid(hostName);
}
/**
*
* @param hostName profile name of Tiktok user could be found in profile link
* example: https://www.tiktok.com/@dostawcavideo hostName would be dostawcavideo
* @return true is hostName name is valid and exists, false if not
*/
public static CompletableFuture<Boolean> isHostNameValidAsync(String hostName)
{
return new TikTokDataChecker().isHostNameValidAsync(hostName);
}
}

View File

@@ -22,9 +22,12 @@
*/
package io.github.jwdeveloper.tiktok;
import io.github.jwdeveloper.tiktok.data.dto.TikTokUserInfo;
import io.github.jwdeveloper.tiktok.data.events.TikTokDisconnectedEvent;
import io.github.jwdeveloper.tiktok.data.events.TikTokErrorEvent;
import io.github.jwdeveloper.tiktok.data.events.TikTokReconnectingEvent;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomInfoEvent;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveOfflineHostException;
import io.github.jwdeveloper.tiktok.gifts.TikTokGiftManager;
@@ -92,8 +95,7 @@ public class TikTokLiveClient implements LiveClient {
public void connect() {
try {
tryConnect();
} catch (TikTokLiveException e)
{
} catch (TikTokLiveException e) {
setState(ConnectionState.DISCONNECTED);
tikTokEventHandler.publish(this, new TikTokErrorEvent(e));
tikTokEventHandler.publish(this, new TikTokDisconnectedEvent());
@@ -108,11 +110,15 @@ public class TikTokLiveClient implements LiveClient {
this.connect();
}
throw e;
} catch (Exception e) {
logger.info("Unhandled exception report this bug to github https://github.com/jwdeveloper/TikTokLiveJava/issues");
this.disconnect();
e.printStackTrace();
}
}
public void disconnect() {
if (!liveRoomInfo.hasConnectionState(ConnectionState.CONNECTED)) {
if (liveRoomInfo.hasConnectionState(ConnectionState.DISCONNECTED)) {
return;
}
webSocketClient.stop();
@@ -127,25 +133,38 @@ public class TikTokLiveClient implements LiveClient {
setState(ConnectionState.CONNECTING);
apiService.updateSessionId();
TikTokUserInfo info = apiService.fetchUserInfoFromTikTokApi(liveRoomInfo.getHostName());
liveRoomInfo.setStartTime(info.getStartTime());
if (clientSettings.getRoomId() != null) {
liveRoomInfo.setRoomId(clientSettings.getRoomId());
logger.info("Using roomID from settings: " + clientSettings.getRoomId());
} else {
var roomId = apiService.fetchRoomId(liveRoomInfo.getHostName());
liveRoomInfo.setRoomId(roomId);
liveRoomInfo.setRoomId(info.getRoomId());
}
apiService.updateRoomId(liveRoomInfo.getRoomId());
var roomData = apiService.fetchRoomInfo();
if (roomData.getStatus() != LiveRoomMeta.LiveRoomStatus.HostOnline) {
throw new TikTokLiveOfflineHostException("LiveStream for Host name could not be found. Is the Host online?");
var liveRoomMeta = apiService.fetchRoomInfo();
if (liveRoomMeta.getStatus() == LiveRoomMeta.LiveRoomStatus.HostNotFound) {
throw new TikTokLiveOfflineHostException("LiveStream for Host name could not be found.");
}
if (liveRoomMeta.getStatus() == LiveRoomMeta.LiveRoomStatus.HostOffline) {
throw new TikTokLiveOfflineHostException("LiveStream for not be found, is the Host offline?");
}
liveRoomInfo.setTitle(liveRoomMeta.getTitie());
liveRoomInfo.setViewersCount(liveRoomMeta.getViewers());
liveRoomInfo.setTotalViewersCount(liveRoomMeta.getTotalViewers());
liveRoomInfo.setAgeRestricted(liveRoomMeta.isAgeRestricted());
liveRoomInfo.setHost(liveRoomMeta.getHost());
var clientData = apiService.fetchClientData();
webSocketClient.start(clientData, this);
setState(ConnectionState.CONNECTED);
tikTokEventHandler.publish(this, new TikTokRoomInfoEvent(liveRoomInfo));
}
@@ -174,4 +193,8 @@ public class TikTokLiveClient implements LiveClient {
liveRoomInfo.setConnectionState(connectionState);
}
}
public void publishEvent(TikTokEvent event)
{
tikTokEventHandler.publish(this, event);
}
}

View File

@@ -24,12 +24,13 @@ package io.github.jwdeveloper.tiktok;
import io.github.jwdeveloper.tiktok.data.events.*;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.data.events.envelop.TikTokChestEvent;
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftComboEvent;
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftEvent;
import io.github.jwdeveloper.tiktok.data.events.http.TikTokHttpResponseEvent;
import io.github.jwdeveloper.tiktok.data.events.poll.TikTokPollEvent;
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomEvent;
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomInfoEvent;
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomPinEvent;
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomUserInfoEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokFollowEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokJoinEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokLikeEvent;
@@ -40,18 +41,27 @@ import io.github.jwdeveloper.tiktok.data.events.websocket.TikTokWebsocketUnhandl
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
import io.github.jwdeveloper.tiktok.gifts.TikTokGiftManager;
import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
import io.github.jwdeveloper.tiktok.handlers.TikTokMessageHandlerRegistration;
import io.github.jwdeveloper.tiktok.handlers.events.TikTokGiftEventHandler;
import io.github.jwdeveloper.tiktok.handlers.TikTokMessageHandler;
import io.github.jwdeveloper.tiktok.http.TikTokApiService;
import io.github.jwdeveloper.tiktok.http.TikTokCookieJar;
import io.github.jwdeveloper.tiktok.http.TikTokHttpClient;
import io.github.jwdeveloper.tiktok.http.TikTokHttpRequestFactory;
import io.github.jwdeveloper.tiktok.listener.TikTokEventListener;
import io.github.jwdeveloper.tiktok.listener.TikTokListenersManager;
import io.github.jwdeveloper.tiktok.live.GiftManager;
import io.github.jwdeveloper.tiktok.live.LiveClient;
import io.github.jwdeveloper.tiktok.live.builder.EventConsumer;
import io.github.jwdeveloper.tiktok.live.builder.LiveClientBuilder;
import io.github.jwdeveloper.tiktok.mappers.TikTokGenericEventMapper;
import io.github.jwdeveloper.tiktok.mappers.TikTokLiveMapper;
import io.github.jwdeveloper.tiktok.mappers.TikTokLiveMapperHelper;
import io.github.jwdeveloper.tiktok.mappers.TikTokMapper;
import io.github.jwdeveloper.tiktok.mappers.data.MappingResult;
import io.github.jwdeveloper.tiktok.mappers.handlers.TikTokCommonEventHandler;
import io.github.jwdeveloper.tiktok.mappers.handlers.TikTokGiftEventHandler;
import io.github.jwdeveloper.tiktok.mappers.handlers.TikTokRoomInfoEventHandler;
import io.github.jwdeveloper.tiktok.mappers.handlers.TikTokSocialMediaEventHandler;
import io.github.jwdeveloper.tiktok.messages.webcast.*;
import io.github.jwdeveloper.tiktok.utils.ConsoleColors;
import io.github.jwdeveloper.tiktok.websocket.TikTokWebSocketClient;
@@ -65,9 +75,11 @@ import java.util.logging.*;
public class TikTokLiveClientBuilder implements LiveClientBuilder {
protected final ClientSettings clientSettings;
protected final Logger logger;
protected final TikTokEventObserver tikTokEventHandler;
protected final List<TikTokEventListener> listeners;
protected Consumer<TikTokMapper> onCustomMappings;
public TikTokLiveClientBuilder(String userName) {
this.tikTokEventHandler = new TikTokEventObserver();
@@ -75,10 +87,18 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
this.clientSettings.setHostName(userName);
this.logger = Logger.getLogger(TikTokLive.class.getSimpleName() + " " + userName);
this.listeners = new ArrayList<>();
this.onCustomMappings = (e) -> {
};
}
public TikTokLiveClientBuilder configure(Consumer<ClientSettings> consumer) {
consumer.accept(clientSettings);
public LiveClientBuilder onMapping(Consumer<TikTokMapper> onCustomMappings) {
this.onCustomMappings = onCustomMappings;
return this;
}
public TikTokLiveClientBuilder configure(Consumer<ClientSettings> onConfigure) {
onConfigure.accept(clientSettings);
return this;
}
@@ -93,17 +113,16 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
clientSettings.setTimeout(Duration.ofSeconds(Constants.DEFAULT_TIMEOUT));
}
if (clientSettings.getClientLanguage() == null || clientSettings.getClientLanguage().equals("")) {
if (clientSettings.getClientLanguage() == null || clientSettings.getClientLanguage().isEmpty()) {
clientSettings.setClientLanguage(Constants.DefaultClientSettings().getClientLanguage());
}
if (clientSettings.getHostName() == null || clientSettings.getHostName().equals("")) {
if (clientSettings.getHostName() == null || clientSettings.getHostName().isEmpty()) {
throw new TikTokLiveException("HostName can not be null");
}
if (clientSettings.getHostName().startsWith("@"))
{
if (clientSettings.getHostName().startsWith("@")) {
clientSettings.setHostName(clientSettings.getHostName().substring(1));
}
@@ -130,11 +149,9 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
logger.setLevel(clientSettings.getLogLevel());
if (clientSettings.isPrintToConsole() && clientSettings.getLogLevel() == Level.OFF) {
logger.setLevel(Level.ALL);
if (!clientSettings.isPrintToConsole()) {
logger.setLevel(Level.OFF);
}
}
public LiveClient build() {
@@ -145,23 +162,18 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
var listenerManager = new TikTokListenersManager(listeners, tikTokEventHandler);
var cookieJar = new TikTokCookieJar();
var requestFactory = new TikTokHttpRequestFactory(cookieJar);
var requestFactory = new TikTokHttpRequestFactory(cookieJar, tikTokEventHandler);
var apiClient = new TikTokHttpClient(cookieJar, requestFactory);
var apiService = new TikTokApiService(apiClient, logger, clientSettings);
var giftManager = new TikTokGiftManager();
var eventMapper = new TikTokGenericEventMapper();
var giftHandler = new TikTokGiftEventHandler(giftManager);
var giftManager = new TikTokGiftManager(logger);
var eventsMapper = createMapper(giftManager, tiktokRoomInfo);
var messageHandler = new TikTokMessageHandler(tikTokEventHandler, eventsMapper);
var webResponseHandler = new TikTokMessageHandlerRegistration(tikTokEventHandler,
tiktokRoomInfo,
eventMapper,
giftHandler
);
var webSocketClient = new TikTokWebSocketClient(logger,
var webSocketClient = new TikTokWebSocketClient(
cookieJar,
clientSettings,
webResponseHandler,
messageHandler,
tikTokEventHandler);
return new TikTokLiveClient(tiktokRoomInfo,
@@ -174,6 +186,93 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
logger);
}
public TikTokLiveMapper createMapper(GiftManager giftManager, TikTokRoomInfo roomInfo) {
var eventMapper = new TikTokGenericEventMapper();
var mapper = new TikTokLiveMapper(new TikTokLiveMapperHelper(eventMapper));
//ConnectionEvents events
var commonHandler = new TikTokCommonEventHandler();
var giftHandler = new TikTokGiftEventHandler(giftManager, roomInfo);
var roomInfoHandler = new TikTokRoomInfoEventHandler(roomInfo);
var socialHandler = new TikTokSocialMediaEventHandler(roomInfo);
mapper.forMessage(WebcastControlMessage.class, commonHandler::handleWebcastControlMessage);
//Room status events
mapper.forMessage(WebcastLiveIntroMessage.class, roomInfoHandler::handleIntro);
mapper.forMessage(WebcastRoomUserSeqMessage.class, roomInfoHandler::handleUserRanking);
mapper.forMessage(WebcastCaptionMessage.class, (inputBytes, messageName, mapperHelper) ->
{
var messageObject = mapperHelper.bytesToWebcastObject(inputBytes, WebcastCaptionMessage.class);
return MappingResult.of(messageObject, new TikTokCaptionEvent(messageObject));
});
//User Interactions events
mapper.forMessage(WebcastChatMessage.class, (inputBytes, messageName, mapperHelper) ->
{
var messageObject = mapperHelper.bytesToWebcastObject(inputBytes, WebcastChatMessage.class);
return MappingResult.of(messageObject, new TikTokCommentEvent(messageObject));
});
mapper.forMessage(WebcastSubNotifyMessage.class, (inputBytes, messageName, mapperHelper) ->
{
var messageObject = mapperHelper.bytesToWebcastObject(inputBytes, WebcastSubNotifyMessage.class);
return MappingResult.of(messageObject, new TikTokSubscribeEvent(messageObject));
});
mapper.forMessage(WebcastEmoteChatMessage.class, (inputBytes, messageName, mapperHelper) ->
{
var messageObject = mapperHelper.bytesToWebcastObject(inputBytes, WebcastEmoteChatMessage.class);
return MappingResult.of(messageObject, new TikTokEmoteEvent(messageObject));
});
mapper.forMessage(WebcastQuestionNewMessage.class, (inputBytes, messageName, mapperHelper) ->
{
var messageObject = mapperHelper.bytesToWebcastObject(inputBytes, WebcastQuestionNewMessage.class);
return MappingResult.of(messageObject, new TikTokQuestionEvent(messageObject));
});
mapper.forMessage(WebcastLikeMessage.class, roomInfoHandler::handleLike);
mapper.forMessage(WebcastGiftMessage.class, giftHandler::handleGifts);
mapper.forMessage(WebcastSocialMessage.class, socialHandler::handle);
mapper.forMessage(WebcastMemberMessage.class, roomInfoHandler::handleMemberMessage);
//Host Interaction events
mapper.forMessage(WebcastPollMessage.class, commonHandler::handlePollEvent);
mapper.forMessage(WebcastRoomPinMessage.class, commonHandler::handlePinMessage);
mapper.forMessage(WebcastChatMessage.class, (inputBytes, messageName, mapperHelper) ->
{
var messageObject = mapperHelper.bytesToWebcastObject(inputBytes, WebcastChatMessage.class);
return MappingResult.of(messageObject, new TikTokCommentEvent(messageObject));
});
//LinkMic events
// mapper.webcastObjectToConstructor(WebcastLinkMicBattle.class, TikTokLinkMicBattleEvent.class);
// mapper.webcastObjectToConstructor(WebcastLinkMicArmies.class, TikTokLinkMicArmiesEvent.class);
// mapper.webcastObjectToConstructor(WebcastLinkMicMethod.class, TikTokLinkMicMethodEvent.class);
// mapper.webcastObjectToConstructor(WebcastLinkMicFanTicketMethod.class, TikTokLinkMicFanTicketEvent.class);
//Rank events
// mapper.webcastObjectToConstructor(WebcastRankTextMessage.class, TikTokRankTextEvent.class);
// mapper.webcastObjectToConstructor(WebcastRankUpdateMessage.class, TikTokRankUpdateEvent.class);
// mapper.webcastObjectToConstructor(WebcastHourlyRankMessage.class, TikTokRankUpdateEvent.class);
//Others events
// mapper.webcastObjectToConstructor(WebcastInRoomBannerMessage.class, TikTokInRoomBannerEvent.class);
// mapper.webcastObjectToConstructor(WebcastMsgDetectMessage.class, TikTokDetectEvent.class);
// mapper.webcastObjectToConstructor(WebcastBarrageMessage.class, TikTokBarrageEvent.class);
// mapper.webcastObjectToConstructor(WebcastUnauthorizedMemberMessage.class, TikTokUnauthorizedMemberEvent.class);
// mapper.webcastObjectToConstructor(WebcastOecLiveShoppingMessage.class, TikTokShopEvent.class);
// mapper.webcastObjectToConstructor(WebcastImDeleteMessage.class, TikTokIMDeleteEvent.class);
// mapper.bytesToEvents(WebcastEnvelopeMessage.class, commonHandler::handleEnvelop);
onCustomMappings.accept(mapper);
return mapper;
}
public LiveClient buildAndConnect() {
var client = build();
client.connect();
@@ -184,12 +283,20 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
return build().connectAsync();
}
public TikTokLiveClientBuilder onUnhandledSocial(
EventConsumer<TikTokUnhandledSocialEvent> event) {
tikTokEventHandler.subscribe(TikTokUnhandledSocialEvent.class, event);
return this;
}
// @Override
public LiveClientBuilder onChest(EventConsumer<TikTokChestEvent> event) {
tikTokEventHandler.subscribe(TikTokChestEvent.class, event);
return this;
}
public TikTokLiveClientBuilder onLinkMicFanTicket(
EventConsumer<TikTokLinkMicFanTicketEvent> event) {
tikTokEventHandler.subscribe(TikTokLinkMicFanTicketEvent.class, event);
@@ -239,16 +346,31 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
return this;
}
public TikTokLiveClientBuilder onRoom(EventConsumer<TikTokRoomEvent> event) {
tikTokEventHandler.subscribe(TikTokRoomEvent.class, event);
@Override
public <E extends TikTokEvent> LiveClientBuilder onEvent(Class<E> eventClass, EventConsumer<E> event) {
tikTokEventHandler.subscribe(eventClass, event);
return this;
}
@Override
public LiveClientBuilder onRoomInfo(EventConsumer<TikTokRoomInfoEvent> event) {
tikTokEventHandler.subscribe(TikTokRoomInfoEvent.class, event);
return this;
}
public TikTokLiveClientBuilder onLivePaused(EventConsumer<TikTokLivePausedEvent> event) {
tikTokEventHandler.subscribe(TikTokLivePausedEvent.class, event);
return this;
}
@Override
public LiveClientBuilder onLiveUnpaused(EventConsumer<TikTokLiveUnpausedEvent> event) {
tikTokEventHandler.subscribe(TikTokLiveUnpausedEvent.class, event);
return this;
}
public TikTokLiveClientBuilder onLike(EventConsumer<TikTokLikeEvent> event) {
tikTokEventHandler.subscribe(TikTokLikeEvent.class, event);
return this;
@@ -321,15 +443,14 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
return this;
}
public TikTokLiveClientBuilder onRoomUserInfo(
EventConsumer<TikTokRoomUserInfoEvent> event) {
tikTokEventHandler.subscribe(TikTokRoomUserInfoEvent.class, event);
public TikTokLiveClientBuilder onComment(EventConsumer<TikTokCommentEvent> event) {
tikTokEventHandler.subscribe(TikTokCommentEvent.class, event);
return this;
}
public TikTokLiveClientBuilder onComment(EventConsumer<TikTokCommentEvent> event) {
tikTokEventHandler.subscribe(TikTokCommentEvent.class, event);
@Override
public LiveClientBuilder onHttpResponse(EventConsumer<TikTokHttpResponseEvent> action) {
tikTokEventHandler.subscribe(TikTokHttpResponseEvent.class, action);
return this;
}
@@ -431,11 +552,4 @@ public class TikTokLiveClientBuilder implements LiveClientBuilder {
tikTokEventHandler.subscribe(TikTokReconnectingEvent.class, event);
return this;
}
}
}

View File

@@ -22,28 +22,52 @@
*/
package io.github.jwdeveloper.tiktok;
import io.github.jwdeveloper.tiktok.models.ConnectionState;
import io.github.jwdeveloper.tiktok.data.models.RankingUser;
import io.github.jwdeveloper.tiktok.data.models.users.User;
import io.github.jwdeveloper.tiktok.live.LiveRoomInfo;
import io.github.jwdeveloper.tiktok.models.ConnectionState;
import lombok.Data;
import java.util.LinkedList;
import java.util.List;
@Data
public class TikTokRoomInfo implements LiveRoomInfo
{
public class TikTokRoomInfo implements LiveRoomInfo {
private String roomId;
private int likesCount;
private int viewersCount;
private String roomId;
private int totalViewersCount;
private long startTime;
private boolean ageRestricted;
private User host;
private List<RankingUser> usersRanking = new LinkedList<>();
private String hostName;
private String title;
private String language = "en";
private ConnectionState connectionState = ConnectionState.DISCONNECTED;
public boolean hasConnectionState(ConnectionState state)
{
public boolean hasConnectionState(ConnectionState state) {
return connectionState == state;
}
}
@Override
public User getHostUser() {
return host;
}
public void updateRanking(List<RankingUser> rankingUsers) {
usersRanking.clear();
usersRanking.addAll(rankingUsers);
}
}

View File

@@ -28,18 +28,22 @@ import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
import io.github.jwdeveloper.tiktok.live.GiftManager;
import sun.misc.Unsafe;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.*;
import java.util.logging.Logger;
public class TikTokGiftManager implements GiftManager {
private final Map<Integer, Gift> indexById;
private final Map<String, Gift> indexByName;
private final Logger logger;
public TikTokGiftManager() {
public TikTokGiftManager(Logger logger)
{
indexById = new HashMap<>();
indexByName = new HashMap<>();
this.logger = logger;
init();
}
@@ -66,6 +70,7 @@ public class TikTokGiftManager implements GiftManager {
field.set(enumInstance, name);
// EnumSet
field = Gift.class.getDeclaredField("diamondCost");
field.setAccessible(true);
field.set(enumInstance, diamondCost);

View File

@@ -23,47 +23,30 @@
package io.github.jwdeveloper.tiktok.handlers;
import io.github.jwdeveloper.tiktok.data.dto.MessageMetaData;
import io.github.jwdeveloper.tiktok.data.events.TikTokErrorEvent;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.data.events.websocket.TikTokWebsocketMessageEvent;
import io.github.jwdeveloper.tiktok.data.events.websocket.TikTokWebsocketResponseEvent;
import io.github.jwdeveloper.tiktok.data.events.websocket.TikTokWebsocketUnhandledMessageEvent;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveMessageException;
import io.github.jwdeveloper.tiktok.live.LiveClient;
import io.github.jwdeveloper.tiktok.mappers.TikTokGenericEventMapper;
import io.github.jwdeveloper.tiktok.mappers.TikTokLiveMapper;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
import io.github.jwdeveloper.tiktok.utils.Stopwatch;
import java.time.Duration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
public abstract class TikTokMessageHandler {
public class TikTokMessageHandler {
private final Map<String, io.github.jwdeveloper.tiktok.handler.TikTokMessageHandler> handlers;
private final TikTokEventObserver tikTokEventHandler;
protected final TikTokGenericEventMapper mapper;
private final TikTokLiveMapper mapper;
public TikTokMessageHandler(TikTokEventObserver tikTokEventHandler, TikTokGenericEventMapper mapper) {
handlers = new HashMap<>();
public TikTokMessageHandler(TikTokEventObserver tikTokEventHandler, TikTokLiveMapper mapper) {
this.tikTokEventHandler = tikTokEventHandler;
this.mapper = mapper;
}
public void registerMapping(Class<?> clazz, Function<byte[], TikTokEvent> func) {
handlers.put(clazz.getSimpleName(), messagePayload -> List.of(func.apply(messagePayload)));
}
public void registerMappings(Class<?> clazz, Function<byte[], List<TikTokEvent>> func) {
handlers.put(clazz.getSimpleName(), func::apply);
}
public void registerMapping(Class<?> input, Class<?> output) {
registerMapping(input, (e) -> mapper.mapToEvent(input, output, e));
}
public void handle(LiveClient client, WebcastResponse webcastResponse) {
tikTokEventHandler.publish(client, new TikTokWebsocketResponseEvent(webcastResponse));
@@ -79,19 +62,18 @@ public abstract class TikTokMessageHandler {
public void handleSingleMessage(LiveClient client, WebcastResponse.Message message) throws Exception {
var messageClassName = message.getMethod();
if (!handlers.containsKey(messageClassName)) {
if (!mapper.isRegistered(messageClassName)) {
tikTokEventHandler.publish(client, new TikTokWebsocketUnhandledMessageEvent(message));
return;
}
var handler = handlers.get(messageClassName);
var stopwatch = new Stopwatch();
stopwatch.start();
var events = handler.handle(message.getPayload().toByteArray());
var events = mapper.handleMapping(messageClassName, message.getPayload().toByteArray());
var handlingTimeInMs = stopwatch.stop();
var metadata = new TikTokWebsocketMessageEvent.MetaData(Duration.ofNanos(handlingTimeInMs));
var metadata = new MessageMetaData(Duration.ofNanos(handlingTimeInMs));
for (var event : events) {
tikTokEventHandler.publish(client, new TikTokWebsocketMessageEvent(event, message, metadata));
tikTokEventHandler.publish(client, new TikTokWebsocketMessageEvent(message, event, metadata));
tikTokEventHandler.publish(client, event);
}
}

View File

@@ -1,191 +0,0 @@
/*
* 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;
import io.github.jwdeveloper.tiktok.TikTokRoomInfo;
import io.github.jwdeveloper.tiktok.data.events.*;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.data.events.poll.TikTokPollEndEvent;
import io.github.jwdeveloper.tiktok.data.events.poll.TikTokPollEvent;
import io.github.jwdeveloper.tiktok.data.events.poll.TikTokPollStartEvent;
import io.github.jwdeveloper.tiktok.data.events.poll.TikTokPollUpdateEvent;
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomEvent;
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomPinEvent;
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomUserInfoEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokFollowEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokJoinEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokLikeEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokShareEvent;
import io.github.jwdeveloper.tiktok.data.models.Text;
import io.github.jwdeveloper.tiktok.handlers.events.TikTokGiftEventHandler;
import io.github.jwdeveloper.tiktok.mappers.TikTokGenericEventMapper;
import io.github.jwdeveloper.tiktok.messages.webcast.*;
import io.github.jwdeveloper.tiktok.models.SocialTypes;
import lombok.SneakyThrows;
import java.util.regex.Pattern;
public class TikTokMessageHandlerRegistration extends TikTokMessageHandler {
private final TikTokRoomInfo roomInfo;
private final TikTokGiftEventHandler giftHandler;
private final Pattern socialMediaPattern = Pattern.compile("pm_mt_guidance_viewer_([0-9]+)_share");
public TikTokMessageHandlerRegistration(TikTokEventObserver tikTokEventHandler,
TikTokRoomInfo roomInfo,
TikTokGenericEventMapper genericTikTokEventMapper,
TikTokGiftEventHandler tikTokGiftEventHandler) {
super(tikTokEventHandler, genericTikTokEventMapper);
this.giftHandler = tikTokGiftEventHandler;
this.roomInfo = roomInfo;
init();
}
public void init() {
//ConnectionEvents events
registerMapping(WebcastControlMessage.class, this::handleWebcastControlMessage);
registerMapping(WebcastSystemMessage.class, TikTokRoomEvent.class);
//Room status events
registerMapping(WebcastLiveIntroMessage.class, TikTokRoomEvent.class);
registerMapping(WebcastRoomUserSeqMessage.class, this::handleRoomUserSeqMessage);
registerMapping(RoomMessage.class, TikTokRoomEvent.class);
registerMapping(WebcastRoomMessage.class, TikTokRoomEvent.class);
registerMapping(WebcastCaptionMessage.class, TikTokCaptionEvent.class);
//User Interactions events
registerMapping(WebcastChatMessage.class, TikTokCommentEvent.class);
registerMapping(WebcastLikeMessage.class, this::handleLike);
registerMappings(WebcastGiftMessage.class, giftHandler::handleGift);
registerMapping(WebcastSocialMessage.class, this::handleSocialMedia);
registerMapping(WebcastMemberMessage.class, this::handleMemberMessage);
//Host Interaction events
registerMapping(WebcastPollMessage.class, this::handlePollEvent);
registerMapping(WebcastRoomPinMessage.class, this::handlePinMessage);
registerMapping(WebcastGoalUpdateMessage.class, TikTokGoalUpdateEvent.class);
//LinkMic events
registerMapping(WebcastLinkMicBattle.class, TikTokLinkMicBattleEvent.class);
registerMapping(WebcastLinkMicArmies.class, TikTokLinkMicArmiesEvent.class);
registerMapping(WebcastLinkMicMethod.class, TikTokLinkMicMethodEvent.class);
registerMapping(WebcastLinkMicFanTicketMethod.class, TikTokLinkMicFanTicketEvent.class);
//Rank events
registerMapping(WebcastRankTextMessage.class, TikTokRankTextEvent.class);
registerMapping(WebcastRankUpdateMessage.class, TikTokRankUpdateEvent.class);
registerMapping(WebcastHourlyRankMessage.class, TikTokRankUpdateEvent.class);
//Others events
registerMapping(WebcastInRoomBannerMessage.class, TikTokInRoomBannerEvent.class);
registerMapping(WebcastMsgDetectMessage.class, TikTokDetectEvent.class);
registerMapping(WebcastBarrageMessage.class, TikTokBarrageEvent.class);
registerMapping(WebcastUnauthorizedMemberMessage.class, TikTokUnauthorizedMemberEvent.class);
registerMapping(WebcastOecLiveShoppingMessage.class, TikTokShopEvent.class);
registerMapping(WebcastImDeleteMessage.class, TikTokIMDeleteEvent.class);
registerMapping(WebcastQuestionNewMessage.class, TikTokQuestionEvent.class);
registerMapping(WebcastEnvelopeMessage.class, TikTokEnvelopeEvent.class);
registerMapping(WebcastSubNotifyMessage.class, TikTokSubNotifyEvent.class);
registerMapping(WebcastEmoteChatMessage.class, TikTokEmoteEvent.class);
}
@SneakyThrows
private TikTokEvent handleWebcastControlMessage(byte[] msg) {
var message = WebcastControlMessage.parseFrom(msg);
return switch (message.getAction()) {
case STREAM_PAUSED -> new TikTokLivePausedEvent();
case STREAM_ENDED -> new TikTokLiveEndedEvent();
default -> new TikTokUnhandledControlEvent(message);
};
}
@SneakyThrows
private TikTokEvent handleSocialMedia(byte[] msg) {
var message = WebcastSocialMessage.parseFrom(msg);
var socialType = Text.map(message.getCommon().getDisplayText()).getKey();
var matcher = socialMediaPattern.matcher(socialType);
if (matcher.find()) {
var value = matcher.group(1);
var number = Integer.parseInt(value);
return new TikTokShareEvent(message, number);
}
return switch (socialType) {
case SocialTypes.LikeType -> new TikTokLikeEvent(message, roomInfo.getLikesCount());
case SocialTypes.FollowType -> new TikTokFollowEvent(message);
case SocialTypes.ShareType -> new TikTokShareEvent(message);
case SocialTypes.JoinType -> new TikTokJoinEvent(message, roomInfo.getViewersCount());
default -> new TikTokUnhandledSocialEvent(message);
};
}
@SneakyThrows
private TikTokEvent handleMemberMessage(byte[] msg) {
var message = WebcastMemberMessage.parseFrom(msg);
return switch (message.getAction()) {
case JOINED -> new TikTokJoinEvent(message);
case SUBSCRIBED -> new TikTokSubscribeEvent(message);
default -> new TikTokUnhandledMemberEvent(message);
};
}
private TikTokEvent handleRoomUserSeqMessage(byte[] msg) {
var event = (TikTokRoomUserInfoEvent) mapper.mapToEvent(WebcastRoomUserSeqMessage.class, TikTokRoomUserInfoEvent.class, msg);
roomInfo.setViewersCount(event.getTotalUsers());
return event;
}
private TikTokEvent handleLike(byte[] msg) {
var event = (TikTokLikeEvent) mapper.mapToEvent(WebcastLikeMessage.class, TikTokLikeEvent.class, msg);
roomInfo.setLikesCount(event.getTotalLikes());
return event;
}
@SneakyThrows
private TikTokEvent handlePinMessage(byte[] msg) {
var pinMessage = WebcastRoomPinMessage.parseFrom(msg);
var chatMessage = WebcastChatMessage.parseFrom(pinMessage.getPinnedMessage());
var chatEvent = new TikTokCommentEvent(chatMessage);
return new TikTokRoomPinEvent(pinMessage, chatEvent);
}
//TODO Probably not working
@SneakyThrows
private TikTokEvent handlePollEvent(byte[] msg) {
var poolMessage = WebcastPollMessage.parseFrom(msg);
return switch (poolMessage.getMessageType()) {
case 0 -> new TikTokPollStartEvent(poolMessage);
case 1 -> new TikTokPollEndEvent(poolMessage);
case 2 -> new TikTokPollUpdateEvent(poolMessage);
default -> new TikTokPollEvent(poolMessage);
};
}
}

View File

@@ -22,58 +22,30 @@
*/
package io.github.jwdeveloper.tiktok.http;
import lombok.SneakyThrows;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.stream.Collectors;
public class HttpUtils
{
public static String parseParameters(String url, Map<String,Object> parameters)
{
var parameterString = "";
if (!parameters.isEmpty()) {
var builder = new StringBuilder();
builder.append("?");
var first = false;
for (var param : parameters.entrySet()) {
if (parameters.isEmpty())
return url;
if (first) {
builder.append("&");
}
builder.append(param.getKey()).append("=").append(param.getValue());
first = true;
}
parameterString = builder.toString();
}
return url+parameterString;
return url+ "?" + parameters.entrySet().stream().map(entry -> entry.getKey()+"="+entry.getValue()).collect(Collectors.joining("&"));
}
@SneakyThrows
public static String parseParametersEncode(String url, Map<String,Object> parameters)
{
if (parameters.isEmpty())
return url;
var parameterString = "";
if (!parameters.isEmpty()) {
var builder = new StringBuilder();
builder.append("?");
var first = false;
for (var param : parameters.entrySet()) {
if (first) {
builder.append("&");
}
final String encodedKey = URLEncoder.encode(param.getKey(), StandardCharsets.UTF_8);
final String encodedValue = URLEncoder.encode(param.getValue().toString(), StandardCharsets.UTF_8);
builder.append(encodedKey).append("=").append(encodedValue);
first = true;
}
parameterString = builder.toString();
}
return url+parameterString;
return url+ "?" + parameters.entrySet().stream().map(entry -> {
String encodedKey = URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8);
String encodedValue = URLEncoder.encode(entry.getValue().toString(), StandardCharsets.UTF_8);
return encodedKey+"="+encodedValue;
}).collect(Collectors.joining("&"));
}
}
}

View File

@@ -22,18 +22,16 @@
*/
package io.github.jwdeveloper.tiktok.http;
import com.google.gson.*;
import io.github.jwdeveloper.tiktok.ClientSettings;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveOfflineHostException;
import io.github.jwdeveloper.tiktok.data.dto.TikTokUserInfo;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveRequestException;
import io.github.jwdeveloper.tiktok.live.LiveRoomMeta;
import io.github.jwdeveloper.tiktok.mappers.LiveRoomMetaMapper;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
import javax.script.ScriptEngineManager;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.regex.Pattern;
public class TikTokApiService {
private final TikTokHttpClient tiktokHttpClient;
@@ -46,89 +44,82 @@ public class TikTokApiService {
this.clientSettings = clientSettings;
}
public void updateSessionId()
{
if(clientSettings.getSessionId() == null)
{
public void updateSessionId() {
if (clientSettings.getSessionId() == null) {
return;
}
if(clientSettings.getSessionId().isEmpty())
{
return;
if (clientSettings.getSessionId().isEmpty()) {
return;
}
tiktokHttpClient.setSessionId(clientSettings.getSessionId());
}
public boolean sendMessage(String message, String sessionId) {
if (sessionId.isEmpty()) {
throw new TikTokLiveException("Session ID must not be Empty");
}
var roomId = clientSettings.getClientParameters().get("room_id");
if (roomId == null) {
throw new TikTokLiveException("Room ID must not be Empty");
}
logger.info("Sending message to chat");
try {
var params = new HashMap<String, Object>(clientSettings.getClientParameters());
params.put("content", message);
params.put("channel", "tiktok_web");
params.remove("cursor");
tiktokHttpClient.setSessionId(sessionId);
tiktokHttpClient.postMessageToChat(params);
return true;
} catch (Exception e) {
throw new TikTokLiveRequestException("Failed to fetch room id from WebCast, see stacktrace for more info.", e);
}
public void updateRoomId(String roomId)
{
clientSettings.getClientParameters().put("room_id", roomId);
}
public String fetchRoomId(String userName) {
logger.info("Fetching room ID");
String html;
public TikTokUserInfo fetchUserInfoFromTikTokApi(String userName) {
var params = new HashMap<>(clientSettings.getClientParameters());
params.put("uniqueId", userName);
params.put("sourceType", 54);
JsonObject roomData;
try {
html = tiktokHttpClient.getLivestreamPage(userName);
}
catch (Exception e)
{
throw new TikTokLiveRequestException("Failed to fetch room id from WebCast, see stacktrace for more info.", e);
roomData = tiktokHttpClient.getJsonFromTikTokApi("api-live/user/room/", params);
} catch (Exception e) {
throw new TikTokLiveRequestException("Failed to fetch pre connection room information, it happens when TikTok temporary blocks you. Try to connect again in few minutes");
}
var firstPattern = Pattern.compile("room_id=([0-9]*)");
var firstMatcher = firstPattern.matcher(html);
var id = "";
var message = roomData.get("message").getAsString();
if (firstMatcher.find()) {
id = firstMatcher.group(1);
} else {
var secondPattern = Pattern.compile("\"roomId\":\"([0-9]*)\"");
var secondMatcher = secondPattern.matcher(html);
if (secondMatcher.find()) {
id = secondMatcher.group(1);
}
if (message.equals("params_error")) {
throw new TikTokLiveRequestException("fetchRoomIdFromTiktokApi -> Unable to fetch roomID, contact the developer");
}
if (id.isEmpty()) {
throw new TikTokLiveOfflineHostException("Unable to fetch room ID, live host could be offline or name is misspelled");
if (message.equals("user_not_found")) {
return new TikTokUserInfo(TikTokUserInfo.UserStatus.NotFound, "", -1);
}
//live -> status 2
//live paused -> 3
//not live -> status 4
var element = roomData.get("data");
if (element.isJsonNull()) {
return new TikTokUserInfo(TikTokUserInfo.UserStatus.NotFound, "", -1);
}
var data = element.getAsJsonObject();
var user = data.getAsJsonObject("user");
var roomId = user.get("roomId").getAsString();
var status = user.get("status").getAsInt();
clientSettings.getClientParameters().put("room_id", id);
logger.info("RoomID -> " + id);
return id;
var liveRoom = data.getAsJsonObject("liveRoom");
long startTime = liveRoom.get("startTime").getAsLong();
var statusEnum = switch (status) {
case 2 -> TikTokUserInfo.UserStatus.Live;
case 3 -> TikTokUserInfo.UserStatus.LivePaused;
case 4 -> TikTokUserInfo.UserStatus.Offline;
default -> TikTokUserInfo.UserStatus.NotFound;
};
return new TikTokUserInfo(statusEnum, roomId, startTime);
}
public LiveRoomMeta fetchRoomInfo() {
logger.info("Fetching RoomInfo");
try {
var response = tiktokHttpClient.getJObjectFromWebcastAPI("room/info/", clientSettings.getClientParameters());
var response = tiktokHttpClient.getJsonFromWebcastApi("room/info/", clientSettings.getClientParameters());
if (!response.has("data")) {
var gson = new GsonBuilder().setPrettyPrinting().create();
var json = gson.toJson(response);
throw new TikTokLiveRequestException("room info response does not contains data field: \n"+ json);
}
var mapper = new LiveRoomMetaMapper();
var liveRoomMeta = mapper.map(response);
logger.info("RoomInfo status -> " + liveRoomMeta.getStatus());
return liveRoomMeta;
} catch (Exception e)
{
throw new TikTokLiveRequestException("Failed to fetch room info from WebCast, see stacktrace for more info.", e);
} catch (Exception e) {
throw new TikTokLiveRequestException("Failed to fetch room info from WebCast server, see stacktrace for more info.", e);
}
}
@@ -136,12 +127,12 @@ public class TikTokApiService {
logger.info("Fetching ClientData");
try {
var response = tiktokHttpClient.getSigningServerMessage("im/fetch/", clientSettings.getClientParameters());
var response = tiktokHttpClient.getSigningServerResponse("im/fetch/", clientSettings.getClientParameters());
clientSettings.getClientParameters().put("cursor", response.getCursor());
clientSettings.getClientParameters().put("internal_ext", response.getInternalExt());
return response;
} catch (Exception e) {
throw new TikTokLiveRequestException("Failed to fetch client data", e);
throw new TikTokLiveRequestException("Failed to fetch live websocket connection data", e);
}
}
}
}

View File

@@ -22,9 +22,8 @@
*/
package io.github.jwdeveloper.tiktok.http;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
public class TikTokCookieJar {
private final Map<String, String> cookies;
@@ -40,13 +39,10 @@ public class TikTokCookieJar {
cookies.put(key, value);
}
public String parseCookies()
{
var sb = new StringBuilder();
for(var entry : cookies.entrySet())
{
sb.append(entry.getKey()).append("=").append(entry.getValue()).append(";");
}
return sb.toString();
public String parseCookies() {
return cookies.entrySet()
.stream()
.map(entry -> entry.getKey()+"="+entry.getValue()+";")
.collect(Collectors.joining());
}
}
}

View File

@@ -0,0 +1,66 @@
/*
* 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.http;
import io.github.jwdeveloper.tiktok.ClientSettings;
import io.github.jwdeveloper.tiktok.Constants;
import io.github.jwdeveloper.tiktok.data.dto.TikTokUserInfo;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveRequestException;
import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Logger;
import java.util.regex.Pattern;
public class TikTokDataChecker {
public CompletableFuture<Boolean> isOnlineAsync(String hostName) {
return CompletableFuture.supplyAsync(() -> isOnline(hostName));
}
public CompletableFuture<Boolean> isHostNameValidAsync(String hostName) {
return CompletableFuture.supplyAsync(() -> isOnline(hostName));
}
public boolean isOnline(String hostName) {
var data = getApiService().fetchUserInfoFromTikTokApi(hostName);
return data.getUserStatus() == TikTokUserInfo.UserStatus.Live ||
data.getUserStatus() == TikTokUserInfo.UserStatus.LivePaused;
}
public boolean isHostNameValid(String hostName) {
var data = getApiService().fetchUserInfoFromTikTokApi(hostName);
return data.getUserStatus() != TikTokUserInfo.UserStatus.NotFound;
}
public TikTokApiService getApiService() {
var jar = new TikTokCookieJar();
var factory = new TikTokHttpRequestFactory(jar,new TikTokEventObserver());
var client = new TikTokHttpClient(jar, factory);
var settings = new ClientSettings();
settings.setClientParameters(Constants.DefaultClientParams());
var apiService = new TikTokApiService(client, Logger.getGlobal(), settings);
return apiService;
}
}

View File

@@ -45,8 +45,7 @@ public class TikTokHttpClient {
this.tikTokCookieJar = tikTokCookieJar;
}
public void setSessionId(String sessionId)
{
public void setSessionId(String sessionId) {
tikTokCookieJar.set("sessionid", sessionId);
tikTokCookieJar.set("sessionid_ss", sessionId);
tikTokCookieJar.set("sid_tt", sessionId);
@@ -54,26 +53,27 @@ public class TikTokHttpClient {
public String getLivestreamPage(String userName) {
var url = Constants.TIKTOK_URL_WEB + "@" + userName + "/live/";
var get = getRequest(url, null);
return get;
}
public String postMessageToChat(Map<String,Object> parameters)
{
var get = postRequest(Constants.TIKTOK_URL_WEBCAST + "room/chat/", parameters);
return get;
}
public JsonObject getJObjectFromWebcastAPI(String path, Map<String, Object> parameters) {
var get = getRequest(Constants.TIKTOK_URL_WEBCAST + path, parameters);
public JsonObject getJsonFromTikTokApi(String path, Map<String,Object> params) {
var get = getRequest(Constants.TIKTOK_URL_WEB + path, params);
var json = JsonParser.parseString(get);
var jsonObject = json.getAsJsonObject();
return jsonObject;
}
public WebcastResponse getSigningServerMessage(String path, Map<String, Object> parameters) {
public JsonObject getJsonFromWebcastApi(String path, Map<String, Object> parameters) {
var get = getRequest(Constants.TIKTOK_URL_WEBCAST + path, parameters);
var json = JsonParser.parseString(get);
var jsonObject = json.getAsJsonObject();
return jsonObject;
}
public WebcastResponse getSigningServerResponse(String path, Map<String, Object> parameters) {
var bytes = getSignRequest(Constants.TIKTOK_URL_WEBCAST + path, parameters);
try {
return WebcastResponse.parseFrom(bytes);
@@ -88,7 +88,6 @@ public class TikTokHttpClient {
if (parameters == null) {
parameters = new HashMap<>();
}
System.out.println("RomMID: "+parameters.get("room_id"));
var request = requestFactory.setQueries(parameters);
return request.post(url);
}
@@ -115,7 +114,6 @@ public class TikTokHttpClient {
{
var split = cookie.split(";")[0].split("=");
var key = split[0];
var value = split[1];
tikTokCookieJar.set(key, value);
@@ -131,7 +129,6 @@ public class TikTokHttpClient {
private String getSignedUrl(String url, Map<String, Object> parameters) {
var fullUrl = HttpUtils.parseParameters(url,parameters);
var signParams = new TreeMap<String,Object>();
signParams.put("client", "ttlive-java");
@@ -141,7 +138,6 @@ public class TikTokHttpClient {
var request = requestFactory.setQueries(signParams);
var content = request.get(Constants.TIKTOK_SIGN_API);
try {
var json = JsonParser.parseString(content);
var jsonObject = json.getAsJsonObject();
@@ -155,4 +151,4 @@ public class TikTokHttpClient {
}
}
}
}

View File

@@ -24,7 +24,10 @@ package io.github.jwdeveloper.tiktok.http;
import io.github.jwdeveloper.tiktok.Constants;
import io.github.jwdeveloper.tiktok.data.events.http.TikTokHttpResponseEvent;
import io.github.jwdeveloper.tiktok.data.models.http.HttpData;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveRequestException;
import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
import lombok.SneakyThrows;
import java.net.CookieManager;
@@ -39,57 +42,62 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.stream.Collectors;
public class TikTokHttpRequestFactory implements TikTokHttpRequest {
private final CookieManager cookieManager;
private final Map<String, String> defaultHeaders;
private final TikTokCookieJar tikTokCookieJar;
private final HttpClient client;
private final TikTokEventObserver eventHandler;
private String query;
public TikTokHttpRequestFactory(TikTokCookieJar tikTokCookieJar) {
public TikTokHttpRequestFactory(TikTokCookieJar tikTokCookieJar, TikTokEventObserver eventHandler) {
this.tikTokCookieJar = tikTokCookieJar;
this.cookieManager = new CookieManager();
this.eventHandler = eventHandler;
defaultHeaders = Constants.DefaultRequestHeaders();
client = HttpClient.newBuilder()
.cookieHandler(cookieManager)
.connectTimeout(Duration.ofSeconds(2))
.build();
}
@SneakyThrows
public String get(String url) {
var uri = URI.create(url);
var request = HttpRequest.newBuilder().GET();
for (var header : defaultHeaders.entrySet())
{
if(header.getKey().equals("Connection") || header.getKey().equals("Accept-Encoding"))
{
var requestBuilder = HttpRequest.newBuilder().GET();
for (var header : defaultHeaders.entrySet()) {
if (header.getKey().equals("Connection") || header.getKey().equals("Accept-Encoding")) {
continue;
}
request.setHeader(header.getKey(), header.getValue());
requestBuilder.setHeader(header.getKey(), header.getValue());
}
if (query != null) {
var baseUri = uri.toString();
var requestUri = URI.create(baseUri + "?" + query);
request.uri(requestUri);
requestBuilder.uri(requestUri);
} else {
requestBuilder.uri(uri);
}
return getContent(request.build());
var result = requestBuilder.build();
return getContent(result);
}
@SneakyThrows
public String post(String url) {
var uri = URI.create(url);
var request = HttpRequest.newBuilder().POST(HttpRequest.BodyPublishers.ofString(""));
for (var header : defaultHeaders.entrySet())
{
if(header.getKey().equals("Connection"))
{
for (var header : defaultHeaders.entrySet()) {
if (header.getKey().equals("Connection")) {
continue;
}
request.setHeader(header.getKey(), header.getValue());
}
request.setHeader("Content-type","application/x-www-form-urlencoded; charset=UTF-8");
request.setHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
request.setHeader("Cookie", tikTokCookieJar.parseCookies());
@@ -97,11 +105,8 @@ public class TikTokHttpRequestFactory implements TikTokHttpRequest {
var baseUri = uri.toString();
var requestUri = URI.create(baseUri + "?" + query);
request.uri(requestUri);
System.out.println(requestUri.toString());
}
return getContent(request.build());
}
@@ -118,24 +123,25 @@ public class TikTokHttpRequestFactory implements TikTokHttpRequest {
public TikTokHttpRequest setQueries(Map<String, Object> queries) {
if (queries == null)
return this;
var testMap = new TreeMap<String,Object>(queries);
query = String.join("&", testMap.entrySet().stream().map(x ->
{
var testMap = new TreeMap<>(queries);
query = testMap.entrySet().stream().map(x -> {
var key = x.getKey();
var value = "";
try {
value = URLEncoder.encode(x.getValue().toString(), StandardCharsets.UTF_8);
return key+"="+URLEncoder.encode(x.getValue().toString(), StandardCharsets.UTF_8);
} catch (Exception e) {
e.printStackTrace();
return key + "=";
}
return key + "=" + value;
}).toList());
}).collect(Collectors.joining("&"));
return this;
}
private String getContent(HttpRequest request) throws Exception {
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
var event = new TikTokHttpResponseEvent(response.uri().toString(), HttpData.map(response), HttpData.map(request));
eventHandler.publish(null, event);
if (response.statusCode() == 404) {
throw new TikTokLiveRequestException("Request responded with 404 NOT_FOUND");
}
@@ -148,8 +154,6 @@ public class TikTokHttpRequestFactory implements TikTokHttpRequest {
for (var cookie : cookies) {
var split = cookie.split(";")[0].split("=");
var uri = request.uri();
var key = split[0];
var value = split[1];
tikTokCookieJar.set(key, value);
@@ -157,10 +161,7 @@ public class TikTokHttpRequestFactory implements TikTokHttpRequest {
var map = new HashMap<String, List<String>>();
map.put(key, List.of(value));
cookieManager.put(uri, map);
}
return response.body();
}
}
}

View File

@@ -23,11 +23,10 @@
package io.github.jwdeveloper.tiktok.listener;
import io.github.jwdeveloper.tiktok.annotations.TikTokEventHandler;
import io.github.jwdeveloper.tiktok.annotations.TikTokEventObserver;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.exceptions.TikTokEventListenerMethodException;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
import io.github.jwdeveloper.tiktok.live.LiveClient;
import io.github.jwdeveloper.tiktok.live.builder.EventConsumer;
@@ -37,10 +36,10 @@ import java.util.HashMap;
import java.util.List;
public class TikTokListenersManager implements ListenersManager {
private final TikTokEventObserver eventObserver;
private final io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver eventObserver;
private final List<ListenerBindingModel> bindingModels;
public TikTokListenersManager(List<TikTokEventListener> listeners, TikTokEventObserver tikTokEventHandler) {
public TikTokListenersManager(List<TikTokEventListener> listeners, io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver tikTokEventHandler) {
this.eventObserver = tikTokEventHandler;
this.bindingModels = new ArrayList<>(listeners.size());
for (var listener : listeners) {
@@ -93,7 +92,7 @@ public class TikTokListenersManager implements ListenersManager {
var clazz = listener.getClass();
var methods = Arrays.stream(clazz.getDeclaredMethods()).filter(m ->
m.getParameterCount() == 2 &&
m.isAnnotationPresent(TikTokEventHandler.class)).toList();
m.isAnnotationPresent(TikTokEventObserver.class)).toList();
var eventsMap = new HashMap<Class<?>, List<EventConsumer<?>>>();
for (var method : methods) {
var eventClazz = method.getParameterTypes()[1];
@@ -116,8 +115,8 @@ public class TikTokListenersManager implements ListenersManager {
throw new TikTokEventListenerMethodException(e);
}
};
eventsMap.computeIfAbsent(eventClazz, (a) -> new ArrayList<EventConsumer<?>>()).add(eventMethodRef);
eventsMap.computeIfAbsent(eventClazz, (a) -> new ArrayList<>()).add(eventMethodRef);
}
return new ListenerBindingModel(listener, eventsMap);
}
}
}

View File

@@ -23,8 +23,13 @@
package io.github.jwdeveloper.tiktok.mappers;
import com.google.gson.JsonObject;
import io.github.jwdeveloper.tiktok.data.models.Picture;
import io.github.jwdeveloper.tiktok.data.models.users.User;
import io.github.jwdeveloper.tiktok.data.models.users.UserAttribute;
import io.github.jwdeveloper.tiktok.live.LiveRoomMeta;
import java.util.ArrayList;
public class LiveRoomMetaMapper {
/**
* 0 - Unknown
@@ -46,15 +51,12 @@ public class LiveRoomMetaMapper {
var status = data.get("status");
var statusId = status.getAsInt();
var statusValue = switch (statusId) {
case 0 -> LiveRoomMeta.LiveRoomStatus.HostNotFound;
case 2 -> LiveRoomMeta.LiveRoomStatus.HostOnline;
case 4 -> LiveRoomMeta.LiveRoomStatus.HostOffline;
default-> LiveRoomMeta.LiveRoomStatus.HostNotFound;
default -> LiveRoomMeta.LiveRoomStatus.HostNotFound;
};
liveRoomMeta.setStatus(statusValue);
}
else
{
} else {
liveRoomMeta.setStatus(LiveRoomMeta.LiveRoomStatus.HostNotFound);
}
@@ -63,6 +65,61 @@ public class LiveRoomMetaMapper {
var restricted = element.get("restricted").getAsBoolean();
liveRoomMeta.setAgeRestricted(restricted);
}
if (data.has("title")) {
var element = data.get("title");
var title = element.getAsString();
liveRoomMeta.setTitie(title);
}
if (data.has("stats")) {
var statsElement = data.getAsJsonObject("stats");
var likeElement = statsElement.get("like_count");
var likes = likeElement.getAsInt();
var titalUsersElement = statsElement.get("total_user");
var totalUsers = titalUsersElement.getAsInt();
liveRoomMeta.setLikeCount(likes);
liveRoomMeta.setTotalViewers(totalUsers);
}
if(data.has("user_count"))
{
var element = data.get("user_count");
var viewers = element.getAsInt();
liveRoomMeta.setViewers(viewers);
}
if(data.has("owner"))
{
var element = data.getAsJsonObject("owner");
var user = getUser(element);
liveRoomMeta.setHost(user);
}
return liveRoomMeta;
}
}
public User getUser(JsonObject jsonElement)
{
var id = jsonElement.get("id").getAsLong();
var name = jsonElement.get("display_id").getAsString();
var profileName = jsonElement.get("nickname").getAsString();
var followElement =jsonElement.getAsJsonObject("follow_info");
var followers = followElement.get("follower_count").getAsInt();
var followingCount = followElement.get("following_count").getAsInt();
var pictureElement =jsonElement.getAsJsonObject("avatar_large");
var link = pictureElement.getAsJsonArray("url_list").get(1).getAsString();
var picture = new Picture(link);
var user = new User(id,name,profileName,picture,followers,followingCount,new ArrayList<>());
user.addAttribute(UserAttribute.LiveHost);
return user;
}
}

View File

@@ -74,7 +74,7 @@ public class TikTokGenericEventMapper {
}
}
private Method getParsingMethod(Class<?> input) throws NoSuchMethodException {
public Method getParsingMethod(Class<?> input) throws NoSuchMethodException {
if (methodCache.containsKey(input)) {
return methodCache.get(input);
}

View File

@@ -0,0 +1,116 @@
/*
* 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;
import com.google.protobuf.GeneratedMessageV3;
import io.github.jwdeveloper.tiktok.TikTokLive;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.mappers.data.MappingAction;
import io.github.jwdeveloper.tiktok.mappers.data.MappingResult;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
public class TikTokLiveMapper implements TikTokMapper {
private final Map<String, TikTokLiveMapperModel> mappers;
private final TikTokMapperHelper mapperUtils;
private final TikTokLiveMapperModel globalMapperModel;
public TikTokLiveMapper(TikTokMapperHelper mapperUtils) {
this.mappers = new HashMap<>();
this.mapperUtils = mapperUtils;
this.globalMapperModel = new TikTokLiveMapperModel("any message");
}
@Override
public TikTokMapperModel forMessage(String messageName) {
if (!isRegistered(messageName)) {
var model = new TikTokLiveMapperModel(messageName);
mappers.put(messageName, model);
}
return mappers.get(messageName);
}
@Override
public TikTokMapperModel forMessage(Class<? extends GeneratedMessageV3> mapperName) {
return forMessage(mapperName.getSimpleName());
}
@Override
public TikTokMapperModel forMessage(String mapperName, MappingAction<MappingResult> onMapping) {
var model = forMessage(mapperName);
model.onMapping(onMapping);
return model;
}
@Override
public TikTokMapperModel forMessage(Class<? extends GeneratedMessageV3> mapperName, MappingAction<MappingResult> onMapping) {
var model = forMessage(mapperName);
model.onMapping(onMapping);
return model;
}
@Override
public TikTokMapperModel forMessage(Class<? extends GeneratedMessageV3> mapperName, Function<byte[], TikTokEvent> onMapping) {
return forMessage(mapperName, (inputBytes, messageName, mapperHelper) -> MappingResult.of(inputBytes, onMapping.apply(inputBytes)));
}
@Override
public TikTokMapperModel forAnyMessage() {
return globalMapperModel;
}
public boolean isRegistered(String mapperName) {
return mappers.containsKey(mapperName);
}
public <T extends GeneratedMessageV3> boolean isRegistered(Class<T> mapperName) {
return mappers.containsKey(mapperName.getSimpleName());
}
public List<TikTokEvent> handleMapping(String messageName, byte[] bytes) {
if (!isRegistered(messageName)) {
return List.of();
}
var mapperModel = mappers.get(messageName);
var inputBytes = mapperModel.getOnBeforeMapping().onMapping(bytes, messageName, mapperUtils);
var globalInputBytes = globalMapperModel.getOnBeforeMapping().onMapping(inputBytes, messageName, mapperUtils);
var mappingResult = mapperModel.getOnMapping().onMapping(globalInputBytes, messageName, mapperUtils);
if (mappingResult == null) {
mappingResult = globalMapperModel.getOnMapping().onMapping(globalInputBytes, messageName, mapperUtils);
}
var afterMappingResult = mapperModel.getOnAfterMapping().apply(mappingResult);
var globalAfterMappingResult = globalMapperModel.getOnAfterMapping().apply(MappingResult.of(mappingResult.getSource(), afterMappingResult));
return globalAfterMappingResult;
}
}

View File

@@ -0,0 +1,82 @@
/*
* 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;
import com.google.protobuf.GeneratedMessageV3;
import io.github.jwdeveloper.tiktok.exceptions.TikTokMessageMappingException;
import io.github.jwdeveloper.tiktok.utils.JsonUtil;
import io.github.jwdeveloper.tiktok.utils.ProtoBufferObject;
import io.github.jwdeveloper.tiktok.utils.ProtocolUtils;
public class TikTokLiveMapperHelper implements TikTokMapperHelper {
private final TikTokGenericEventMapper genericMapper;
public TikTokLiveMapperHelper(TikTokGenericEventMapper genericMapper) {
this.genericMapper = genericMapper;
}
@Override
public <T extends GeneratedMessageV3> T bytesToWebcastObject(byte[] bytes, Class<T> messageClass) {
try {
var parsingMethod = genericMapper.getParsingMethod(messageClass);
var sourceObject = parsingMethod.invoke(null, bytes);
return (T) sourceObject;
} catch (Exception e) {
throw new TikTokMessageMappingException(messageClass, "can't find parsing method", e);
}
}
@Override
public Object bytesToWebcastObject(byte[] bytes, String messageName) {
try {
var packageName = "io.github.jwdeveloper.tiktok.messages.webcast." + messageName;
var clazz = Class.forName(packageName);
return bytesToWebcastObject(bytes, (Class<? extends GeneratedMessageV3>) clazz);
} catch (Exception e) {
throw new TikTokMessageMappingException(messageName, e);
}
}
@Override
public boolean isMessageHasProtoClass(String messageName) {
try {
var packageName = "io.github.jwdeveloper.tiktok.messages.webcast." + messageName;
Class.forName(packageName);
return true;
} catch (Exception e) {
return false;
}
}
@Override
public ProtoBufferObject bytesToProtoBufferStructure(byte[] bytes) {
return ProtocolUtils.getProtocolBufferStructure(bytes);
}
@Override
public String toJson(Object obj) {
return JsonUtil.toJson(obj);
}
}

View File

@@ -0,0 +1,79 @@
/*
* 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;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.mappers.data.MappingAction;
import io.github.jwdeveloper.tiktok.mappers.data.MappingResult;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.function.Function;
@Getter
@Setter
public class TikTokLiveMapperModel implements TikTokMapperModel {
@Getter
private String sourceMessageName;
private MappingAction<byte[]> onBeforeMapping;
private MappingAction<MappingResult> onMapping;
private Function<MappingResult, List<TikTokEvent>> onAfterMapping;
public TikTokLiveMapperModel(String sourceMessageName, MappingAction onMapping) {
this.sourceMessageName = sourceMessageName;
this.onBeforeMapping = (inputBytes, mesasgeName, mapperHelper) -> inputBytes;
this.onMapping = onMapping;
this.onAfterMapping = MappingResult::getEvents;
}
public TikTokLiveMapperModel(String sourceMessageName) {
this.sourceMessageName = sourceMessageName;
this.onBeforeMapping = (inputBytes, mesasgeName, mapperHelper) -> inputBytes;
this.onMapping = (inputBytes, mesasgeName, mapperHelper) -> MappingResult.of(inputBytes, List.of());
this.onAfterMapping = MappingResult::getEvents;
}
@Override
public TikTokMapperModel onBeforeMapping(MappingAction<byte[]> action) {
this.onBeforeMapping = action;
return this;
}
@Override
public TikTokMapperModel onMapping(MappingAction<MappingResult> action) {
this.onMapping = action;
return this;
}
@Override
public TikTokMapperModel onAfterMapping(Function<MappingResult, List<TikTokEvent>> action) {
this.onAfterMapping = action;
return this;
}
}

View File

@@ -0,0 +1,26 @@
/*
* 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.handlers;
public class TikTokChestEventHandler {
}

View File

@@ -0,0 +1,88 @@
/*
* 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.handlers;
import io.github.jwdeveloper.tiktok.data.events.*;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.data.events.envelop.TikTokChestEvent;
import io.github.jwdeveloper.tiktok.data.events.poll.TikTokPollEndEvent;
import io.github.jwdeveloper.tiktok.data.events.poll.TikTokPollEvent;
import io.github.jwdeveloper.tiktok.data.events.poll.TikTokPollStartEvent;
import io.github.jwdeveloper.tiktok.data.events.poll.TikTokPollUpdateEvent;
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomPinEvent;
import io.github.jwdeveloper.tiktok.data.models.chest.Chest;
import io.github.jwdeveloper.tiktok.messages.enums.EnvelopeDisplay;
import io.github.jwdeveloper.tiktok.messages.webcast.*;
import lombok.SneakyThrows;
import java.util.Collections;
import java.util.List;
public class TikTokCommonEventHandler
{
@SneakyThrows
public TikTokEvent handleWebcastControlMessage(byte[] msg) {
var message = WebcastControlMessage.parseFrom(msg);
return switch (message.getAction()) {
case STREAM_PAUSED -> new TikTokLivePausedEvent();
case STREAM_ENDED -> new TikTokLiveEndedEvent();
case STREAM_UNPAUSED -> new TikTokLiveUnpausedEvent();
default -> new TikTokUnhandledControlEvent(message);
};
}
@SneakyThrows
public TikTokEvent handlePinMessage(byte[] msg) {
var pinMessage = WebcastRoomPinMessage.parseFrom(msg);
var chatMessage = WebcastChatMessage.parseFrom(pinMessage.getPinnedMessage());
var chatEvent = new TikTokCommentEvent(chatMessage);
return new TikTokRoomPinEvent(pinMessage, chatEvent);
}
//TODO Probably not working
@SneakyThrows
public TikTokEvent handlePollEvent(byte[] msg) {
var poolMessage = WebcastPollMessage.parseFrom(msg);
return switch (poolMessage.getMessageType()) {
case MESSAGETYPE_SUBSUCCESS -> new TikTokPollStartEvent(poolMessage);
case MESSAGETYPE_ANCHORREMINDER -> new TikTokPollEndEvent(poolMessage);
case MESSAGETYPE_ENTERROOMEXPIRESOON -> new TikTokPollUpdateEvent(poolMessage);
default -> new TikTokPollEvent(poolMessage);
};
}
@SneakyThrows
public List<TikTokEvent> handleEnvelop(byte[] data) {
var msg = WebcastEnvelopeMessage.parseFrom(data);
if (msg.getDisplay() != EnvelopeDisplay.EnvelopeDisplayNew) {
return Collections.emptyList();
}
var totalDiamonds = msg.getEnvelopeInfo().getDiamondCount();
var totalUsers = msg.getEnvelopeInfo().getPeopleCount();
var chest = new Chest(totalDiamonds, totalUsers);
return List.of(new TikTokChestEvent(chest, msg));
}
}

View File

@@ -20,8 +20,9 @@
* 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.mappers.handlers;
import io.github.jwdeveloper.tiktok.TikTokRoomInfo;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftComboEvent;
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftEvent;
@@ -30,6 +31,8 @@ import io.github.jwdeveloper.tiktok.data.models.gifts.Gift;
import io.github.jwdeveloper.tiktok.data.models.gifts.GiftSendType;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
import io.github.jwdeveloper.tiktok.live.GiftManager;
import io.github.jwdeveloper.tiktok.mappers.TikTokMapperHelper;
import io.github.jwdeveloper.tiktok.mappers.data.MappingResult;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
import lombok.SneakyThrows;
import sun.misc.Unsafe;
@@ -41,18 +44,34 @@ import java.util.Map;
public class TikTokGiftEventHandler {
private final GiftManager giftManager;
private final Map<Long, WebcastGiftMessage> giftsMessages;
private final TikTokRoomInfo tikTokRoomInfo;
public TikTokGiftEventHandler(GiftManager giftManager) {
public TikTokGiftEventHandler(GiftManager giftManager, TikTokRoomInfo tikTokRoomInfo) {
this.giftManager = giftManager;
giftsMessages = new HashMap<>();
this.tikTokRoomInfo = tikTokRoomInfo;
}
public List<TikTokEvent> handleGift(WebcastGiftMessage currentMessage)
{
@SneakyThrows
public MappingResult handleGifts(byte[] msg, String name, TikTokMapperHelper helper) {
var currentMessage = WebcastGiftMessage.parseFrom(msg);
var gifts = handleGift(currentMessage);
return MappingResult.of(currentMessage, gifts);
}
public List<TikTokEvent> handleGift(WebcastGiftMessage currentMessage) {
var userId = currentMessage.getUser().getId();
var currentType = GiftSendType.fromNumber(currentMessage.getSendType());
var containsPreviousMessage = giftsMessages.containsKey(userId);
//If gift is not streakable just return onGift event
if (currentMessage.getGift().getType() != 1) {
var comboEvent = getGiftComboEvent(currentMessage, GiftSendType.Finished);
var giftEvent = getGiftEvent(currentMessage);
return List.of(comboEvent, giftEvent);
}
if (!containsPreviousMessage) {
if (currentType == GiftSendType.Finished) {
return List.of(getGiftEvent(currentMessage));
@@ -81,32 +100,27 @@ public class TikTokGiftEventHandler {
return List.of();
}
@SneakyThrows
public List<TikTokEvent> handleGift(byte[] msg) {
var currentMessage = WebcastGiftMessage.parseFrom(msg);
return handleGift(currentMessage);
}
private TikTokGiftEvent getGiftEvent(WebcastGiftMessage message) {
var gift = getGiftObject(message);
return new TikTokGiftEvent(gift, message);
return new TikTokGiftEvent(gift, tikTokRoomInfo.getHost(), message);
}
private TikTokGiftEvent getGiftComboEvent(WebcastGiftMessage message, GiftSendType state) {
var gift = getGiftObject(message);
return new TikTokGiftComboEvent(gift, message, state);
return new TikTokGiftComboEvent(gift, tikTokRoomInfo.getHost(), message, state);
}
private Gift getGiftObject(WebcastGiftMessage giftMessage) {
var gift = giftManager.findById((int) giftMessage.getGiftId());
var giftId = (int) giftMessage.getGiftId();
var gift = giftManager.findById(giftId);
if (gift == Gift.UNDEFINED) {
gift = giftManager.findByName(giftMessage.getGift().getName());
}
if (gift == Gift.UNDEFINED) {
gift = giftManager.registerGift(
(int) giftMessage.getGift().getId(),
giftId,
giftMessage.getGift().getName(),
giftMessage.getGift().getDiamondCount(),
Picture.map(giftMessage.getGift().getImage()));

View File

@@ -0,0 +1,115 @@
/*
* 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.handlers;
import io.github.jwdeveloper.tiktok.TikTokRoomInfo;
import io.github.jwdeveloper.tiktok.data.events.TikTokSubscribeEvent;
import io.github.jwdeveloper.tiktok.data.events.TikTokUnhandledMemberEvent;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomInfoEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokJoinEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokLikeEvent;
import io.github.jwdeveloper.tiktok.data.models.RankingUser;
import io.github.jwdeveloper.tiktok.data.models.users.User;
import io.github.jwdeveloper.tiktok.mappers.TikTokMapperHelper;
import io.github.jwdeveloper.tiktok.mappers.data.MappingResult;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLikeMessage;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLiveIntroMessage;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastMemberMessage;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastRoomUserSeqMessage;
import lombok.SneakyThrows;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
public class TikTokRoomInfoEventHandler {
private final TikTokRoomInfo roomInfo;
public TikTokRoomInfoEventHandler(TikTokRoomInfo roomInfo) {
this.roomInfo = roomInfo;
}
public TikTokEvent handleRoomInfo(Consumer<TikTokRoomInfo> consumer) {
consumer.accept(roomInfo);
return new TikTokRoomInfoEvent(roomInfo);
}
@SneakyThrows
public TikTokEvent handleUserRanking(byte[] msg) {
var message = WebcastRoomUserSeqMessage.parseFrom(msg);
var totalUsers = message.getTotalUser();
var userRanking = message.getRanksListList().stream().map(RankingUser::new)
.sorted((ru1, ru2) -> Integer.compare(ru2.getScore(), ru1.getScore()))
.collect(Collectors.toList());
return handleRoomInfo(tikTokRoomInfo ->
{
tikTokRoomInfo.setTotalViewersCount(totalUsers);
tikTokRoomInfo.updateRanking(userRanking);
});
}
@SneakyThrows
public TikTokEvent handleIntro(byte[] msg) {
var message = WebcastLiveIntroMessage.parseFrom(msg);
var hostUser = User.map(message.getHost());
var language = message.getLanguage();
return handleRoomInfo(tikTokRoomInfo ->
{
if (tikTokRoomInfo.getHost() == null) {
tikTokRoomInfo.setHost(hostUser);
}
tikTokRoomInfo.setLanguage(language);
});
}
@SneakyThrows
public MappingResult handleMemberMessage(byte[] msg, String name, TikTokMapperHelper helper) {
var message = WebcastMemberMessage.parseFrom(msg);
var event = switch (message.getAction()) {
case JOINED -> new TikTokJoinEvent(message);
case SUBSCRIBED -> new TikTokSubscribeEvent(message);
default -> new TikTokUnhandledMemberEvent(message);
};
var roomInfoEvent = this.handleRoomInfo(tikTokRoomInfo ->
{
tikTokRoomInfo.setViewersCount(message.getMemberCount());
});
return MappingResult.of(message, List.of(event, roomInfoEvent));
}
@SneakyThrows
public MappingResult handleLike(byte[] msg, String name, TikTokMapperHelper helper) {
var message = WebcastLikeMessage.parseFrom(msg);
var event = new TikTokLikeEvent(message);
var roomInfoEvent = this.handleRoomInfo(tikTokRoomInfo ->
{
tikTokRoomInfo.setLikesCount(event.getTotalLikes());
});
return MappingResult.of(message, List.of(event, roomInfoEvent));
}
}

View File

@@ -0,0 +1,71 @@
/*
* 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.handlers;
import io.github.jwdeveloper.tiktok.TikTokRoomInfo;
import io.github.jwdeveloper.tiktok.data.events.TikTokUnhandledSocialEvent;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokFollowEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokJoinEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokLikeEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokShareEvent;
import io.github.jwdeveloper.tiktok.data.models.Text;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastSocialMessage;
import io.github.jwdeveloper.tiktok.models.SocialTypes;
import lombok.SneakyThrows;
import java.util.regex.Pattern;
public class TikTokSocialMediaEventHandler
{
private final TikTokRoomInfo roomInfo;
private final Pattern socialMediaPattern = Pattern.compile("pm_mt_guidance_viewer_([0-9]+)_share");
public TikTokSocialMediaEventHandler(TikTokRoomInfo roomInfo) {
this.roomInfo = roomInfo;
}
@SneakyThrows
public TikTokEvent handle(byte[] msg)
{
var message = WebcastSocialMessage.parseFrom(msg);
var socialType = Text.map(message.getCommon().getDisplayText()).getKey();
var matcher = socialMediaPattern.matcher(socialType);
if (matcher.find()) {
var value = matcher.group(1);
var number = Integer.parseInt(value);
return new TikTokShareEvent(message, number);
}
return switch (socialType) {
case SocialTypes.LikeType -> new TikTokLikeEvent(message, roomInfo.getLikesCount());
case SocialTypes.FollowType -> new TikTokFollowEvent(message);
case SocialTypes.ShareType -> new TikTokShareEvent(message);
case SocialTypes.JoinType -> new TikTokJoinEvent(message, roomInfo.getViewersCount());
default -> new TikTokUnhandledSocialEvent(message);
};
}
}

View File

@@ -24,11 +24,9 @@ package io.github.jwdeveloper.tiktok.websocket;
import io.github.jwdeveloper.tiktok.ClientSettings;
import io.github.jwdeveloper.tiktok.Constants;
import io.github.jwdeveloper.tiktok.TikTokLiveClient;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
import io.github.jwdeveloper.tiktok.handlers.TikTokMessageHandlerRegistration;
import io.github.jwdeveloper.tiktok.handlers.TikTokMessageHandler;
import io.github.jwdeveloper.tiktok.http.HttpUtils;
import io.github.jwdeveloper.tiktok.http.TikTokCookieJar;
import io.github.jwdeveloper.tiktok.live.LiveClient;
@@ -41,24 +39,22 @@ import java.util.TreeMap;
import java.util.logging.Logger;
public class TikTokWebSocketClient implements SocketClient {
private final Logger logger;
private final ClientSettings clientSettings;
private final TikTokCookieJar tikTokCookieJar;
private final TikTokMessageHandlerRegistration webResponseHandler;
private final TikTokMessageHandler messageHandler;
private final TikTokEventObserver tikTokEventHandler;
private WebSocketClient webSocketClient;
private TikTokWebSocketPingingTask pingingTask;
private boolean isConnected;
public TikTokWebSocketClient(Logger logger,
public TikTokWebSocketClient(
TikTokCookieJar tikTokCookieJar,
ClientSettings clientSettings,
TikTokMessageHandlerRegistration webResponseHandler,
TikTokMessageHandler messageHandler,
TikTokEventObserver tikTokEventHandler) {
this.logger = logger;
this.tikTokCookieJar = tikTokCookieJar;
this.clientSettings = clientSettings;
this.webResponseHandler = webResponseHandler;
this.messageHandler = messageHandler;
this.tikTokEventHandler = tikTokEventHandler;
isConnected = false;
}
@@ -74,10 +70,7 @@ public class TikTokWebSocketClient implements SocketClient {
}
try {
if (clientSettings.isHandleExistingEvents()) {
logger.info("Handling existing events");
webResponseHandler.handle(tikTokLiveClient, webcastResponse);
}
messageHandler.handle(tikTokLiveClient, webcastResponse);
var url = getWebSocketUrl(webcastResponse);
webSocketClient = startWebSocket(url, tikTokLiveClient);
webSocketClient.connect();
@@ -85,7 +78,8 @@ public class TikTokWebSocketClient implements SocketClient {
pingingTask = new TikTokWebSocketPingingTask();
pingingTask.run(webSocketClient);
isConnected = true;
} catch (Exception e) {
} catch (Exception e)
{
isConnected = false;
throw new TikTokLiveException("Failed to connect to the websocket", e);
}
@@ -109,7 +103,7 @@ public class TikTokWebSocketClient implements SocketClient {
return new TikTokWebSocketListener(url,
headers,
3000,
webResponseHandler,
messageHandler,
tikTokEventHandler,
liveClient);
}

View File

@@ -28,7 +28,7 @@ import io.github.jwdeveloper.tiktok.data.events.TikTokDisconnectedEvent;
import io.github.jwdeveloper.tiktok.data.events.TikTokErrorEvent;
import io.github.jwdeveloper.tiktok.exceptions.TikTokProtocolBufferException;
import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
import io.github.jwdeveloper.tiktok.handlers.TikTokMessageHandlerRegistration;
import io.github.jwdeveloper.tiktok.handlers.TikTokMessageHandler;
import io.github.jwdeveloper.tiktok.live.LiveClient;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastPushFrame;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
@@ -44,33 +44,22 @@ import java.util.Optional;
public class TikTokWebSocketListener extends WebSocketClient {
private final TikTokMessageHandlerRegistration webResponseHandler;
private final TikTokMessageHandler messageHandler;
private final TikTokEventObserver tikTokEventHandler;
private final LiveClient tikTokLiveClient;
public TikTokWebSocketListener(URI serverUri,
Map<String, String> httpHeaders,
int connectTimeout,
TikTokMessageHandlerRegistration webResponseHandler,
TikTokMessageHandler messageHandler,
TikTokEventObserver tikTokEventHandler,
LiveClient tikTokLiveClient) {
super(serverUri, new Draft_6455(), httpHeaders,connectTimeout);
this.webResponseHandler = webResponseHandler;
this.messageHandler = messageHandler;
this.tikTokEventHandler = tikTokEventHandler;
this.tikTokLiveClient = tikTokLiveClient;
}
@Override
public void onOpen(ServerHandshake serverHandshake) {
tikTokEventHandler.publish(tikTokLiveClient,new TikTokConnectedEvent());
if(isNotClosing())
{
sendPing();
}
}
@Override
public void onMessage(ByteBuffer bytes)
{
@@ -85,6 +74,19 @@ public class TikTokWebSocketListener extends WebSocketClient {
}
}
@Override
public void onOpen(ServerHandshake serverHandshake) {
tikTokEventHandler.publish(tikTokLiveClient,new TikTokConnectedEvent());
if(isNotClosing())
{
sendPing();
}
}
@Override
public void onClose(int i, String s, boolean b) {
tikTokEventHandler.publish(tikTokLiveClient,new TikTokDisconnectedEvent());
@@ -114,7 +116,7 @@ public class TikTokWebSocketListener extends WebSocketClient {
// sendAckId(webResponse.getFetchInterval());
}
webResponseHandler.handle(tikTokLiveClient, webResponse);
messageHandler.handle(tikTokLiveClient, webResponse);
}
private Optional<WebcastPushFrame> getWebcastWebsocketMessage(byte[] buffer) {

View File

@@ -46,6 +46,7 @@ public class TikTokGiftManagerTest {
var gifts = giftManager.getGifts();
var optional = gifts.stream().filter(r -> r == fakeGift).findFirst();
Assertions.assertTrue(optional.isPresent());
// Assertions.assertNotNull(optional.get().name());
}
@Test
@@ -68,4 +69,7 @@ public class TikTokGiftManagerTest {
}
}

View File

@@ -1,8 +1,34 @@
/*
* 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;
import io.github.jwdeveloper.tiktok.TikTokRoomInfo;
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftComboEvent;
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftEvent;
import io.github.jwdeveloper.tiktok.data.models.Picture;
import io.github.jwdeveloper.tiktok.data.models.gifts.GiftSendType;
import io.github.jwdeveloper.tiktok.gifts.TikTokGiftManager;
import io.github.jwdeveloper.tiktok.mappers.handlers.TikTokGiftEventHandler;
import io.github.jwdeveloper.tiktok.messages.data.GiftStruct;
import io.github.jwdeveloper.tiktok.messages.data.Image;
import io.github.jwdeveloper.tiktok.messages.data.User;
@@ -12,6 +38,8 @@ import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import java.util.logging.Logger;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class TikTokGiftEventHandlerTest {
@@ -21,22 +49,58 @@ class TikTokGiftEventHandlerTest {
@BeforeAll
public void before() {
var manager = new TikTokGiftManager();
var manager = new TikTokGiftManager(Logger.getLogger("x"));
var info = new TikTokRoomInfo();
info.setHost(new io.github.jwdeveloper.tiktok.data.models.users.User(123L, "test", new Picture("")));
manager.registerGift(123, "example", 123, new Picture("image.webp"));
handler = new TikTokGiftEventHandler(manager);
handler = new TikTokGiftEventHandler(manager, info);
}
@Test
void shouldHandleGifts() {
var message = getGiftMessage("example-new-name", 123, "image-new.png", 0, 1);
var message = getGiftMessage("example-new-name", 123, "image-new.png", 0, 1, false);
var result = handler.handleGift(message);
Assertions.assertEquals(2, result.size());
var event = (TikTokGiftEvent) result.get(0);
var gift = event.getGift();
Assertions.assertEquals("image-new.png", gift.getPicture().getLink());
Assertions.assertEquals(123, gift.getId());
}
@Test
void shouldHandleStrakableGift() {
var message = getGiftMessage("example-new-name", 123, "image-new.png", 0, 1, true);
var result = handler.handleGift(message);
Assertions.assertEquals(1, result.size());
var event = (TikTokGiftEvent) result.get(0);
var gift = event.getGift();
Assertions.assertEquals("image-new.png",gift.getPicture().getLink());
Assertions.assertEquals(123,gift.getId());
Assertions.assertEquals("image-new.png", gift.getPicture().getLink());
Assertions.assertEquals(123, gift.getId());
}
@Test
void shouldHandleStrike() {
var message1 = getGiftMessage("example-new-name", 123, "image-new.png", 1, 1, true);
var message2 = getGiftMessage("example-new-name", 123, "image-new.png", 2, 1, true);
var message3 = getGiftMessage("example-new-name", 123, "image-new.png", 0, 1, true);
var result1 = handler.handleGift(message1);
var result2 = handler.handleGift(message2);
var result3 = handler.handleGift(message3);
var event1 = (TikTokGiftComboEvent) result1.get(0);
var event2 = (TikTokGiftComboEvent) result2.get(0);
Assertions.assertEquals(2, result3.size());
var event3 = (TikTokGiftComboEvent) result3.get(0);
Assertions.assertEquals(GiftSendType.Begin, event1.getComboState());
Assertions.assertEquals(GiftSendType.Active, event2.getComboState());
Assertions.assertEquals(GiftSendType.Finished, event3.getComboState());
}
@@ -44,7 +108,8 @@ class TikTokGiftEventHandlerTest {
int giftId,
String giftImage,
int sendType,
int userId) {
int userId,
boolean streakable) {
var builder = WebcastGiftMessage.newBuilder();
var giftBuilder = GiftStruct.newBuilder();
var userBuilder = User.newBuilder();
@@ -53,6 +118,7 @@ class TikTokGiftEventHandlerTest {
giftBuilder.setId(giftId);
giftBuilder.setName(giftName);
giftBuilder.setImage(Image.newBuilder().addUrlList(giftImage).build());
giftBuilder.setType(streakable ? 1 : 0);
userBuilder.setId(userId);
builder.setGiftId(giftId);
@@ -62,4 +128,5 @@ class TikTokGiftEventHandlerTest {
return builder.build();
}
}

View File

@@ -0,0 +1,47 @@
package io.github.jwdeveloper.tiktok.http;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import java.util.*;
public class HttpUtilsTest
{
@Test
public void parseParameters_EmptyParameters_ShouldHaveNoParameters()
{
String parsed = HttpUtils.parseParameters("https://webcast.tiktok.com/webcast/im/fetch/", new HashMap<>());
Assertions.assertEquals("https://webcast.tiktok.com/webcast/im/fetch/", parsed);
}
@Test
public void parseParameters_ValidParameters_ShouldConstructValidURL()
{
LinkedHashMap<String, Object> testMap = new LinkedHashMap<>();
testMap.put("room_id", 1);
testMap.put("uniqueId", "randomName");
String parsed = HttpUtils.parseParameters("https://webcast.tiktok.com/webcast/im/fetch/", testMap);
Assertions.assertEquals("https://webcast.tiktok.com/webcast/im/fetch/?room_id=1&uniqueId=randomName", parsed);
}
@Test
public void parseParametersEncode_EmptyParameters_ShouldHaveNoParameters()
{
String parsed = HttpUtils.parseParametersEncode("https://webcast.tiktok.com/webcast/im/fetch/", new HashMap<>());
Assertions.assertEquals("https://webcast.tiktok.com/webcast/im/fetch/", parsed);
}
@Test
public void parseParametersEncode_ValidParameters_ShouldConstructValidURL()
{
LinkedHashMap<String, Object> testMap = new LinkedHashMap<>();
testMap.put("room_id", 1);
testMap.put("root_referer", "https://www.tiktok.com/");
String parsed = HttpUtils.parseParametersEncode("https://webcast.tiktok.com/webcast/im/fetch/", testMap);
Assertions.assertEquals("https://webcast.tiktok.com/webcast/im/fetch/?room_id=1&root_referer=https%3A%2F%2Fwww.tiktok.com%2F", parsed);
}
}

View File

@@ -24,7 +24,6 @@ package io.github.jwdeveloper.tiktok.http;
import com.google.gson.JsonObject;
import io.github.jwdeveloper.tiktok.ClientSettings;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveRequestException;
import io.github.jwdeveloper.tiktok.live.LiveRoomMeta;
import io.github.jwdeveloper.tiktok.mappers.LiveRoomMetaMapper;
@@ -84,51 +83,14 @@ public class TikTokApiServiceTest
verify(tiktokHttpClient, times(1)).setSessionId("validSessionId");
}
@Test
void sendMessage_EmptySessionId_ThrowsException() {
assertThrows(TikTokLiveException.class, () -> {
tikTokApiService.sendMessage("some message", "");
});
}
@Test
void sendMessage_NullRoomId_ThrowsException() {
when(clientSettings.getClientParameters()).thenReturn(new HashMap<>());
assertThrows(TikTokLiveException.class, () -> {
tikTokApiService.sendMessage("some message", "someSessionId");
});
}
@Test
void fetchRoomId_ValidResponse_ReturnsRoomId() throws Exception {
String expectedRoomId = "123456";
String htmlResponse = "room_id=" + expectedRoomId ;
when(tiktokHttpClient.getLivestreamPage(anyString())).thenReturn(htmlResponse);
String roomId = tikTokApiService.fetchRoomId("username");
assertEquals(expectedRoomId, roomId);
verify(clientSettings.getClientParameters()).put("room_id", expectedRoomId);
}
@Test
void fetchRoomId_ExceptionThrown_ThrowsTikTokLiveRequestException() throws Exception {
when(tiktokHttpClient.getLivestreamPage(anyString())).thenThrow(new Exception("some exception"));
assertThrows(TikTokLiveRequestException.class, () -> {
tikTokApiService.fetchRoomId("username");
});
}
@Test
//@Test
void fetchRoomInfo_ValidResponse_ReturnsLiveRoomMeta() throws Exception {
HashMap<String, Object> clientParameters = new HashMap<>();
var mockResponse = new JsonObject(); // Assume JsonObject is from the Gson library
var expectedLiveRoomMeta = new LiveRoomMeta(); // Assume LiveRoomMeta is a simple POJO
when(clientSettings.getClientParameters()).thenReturn(clientParameters);
when(tiktokHttpClient.getJObjectFromWebcastAPI(anyString(), any())).thenReturn(mockResponse);
when(tiktokHttpClient.getJsonFromWebcastApi(anyString(), any())).thenReturn(mockResponse);
when(new LiveRoomMetaMapper().map(mockResponse)).thenReturn(expectedLiveRoomMeta); // Assuming LiveRoomMetaMapper is a simple mapper class
LiveRoomMeta liveRoomMeta = tikTokApiService.fetchRoomInfo();
@@ -136,9 +98,9 @@ public class TikTokApiServiceTest
assertEquals(expectedLiveRoomMeta, liveRoomMeta);
}
@Test
// @Test
void fetchRoomInfo_ExceptionThrown_ThrowsTikTokLiveRequestException() throws Exception {
when(tiktokHttpClient.getJObjectFromWebcastAPI(anyString(), any())).thenThrow(new Exception("some exception"));
when(tiktokHttpClient.getJsonFromWebcastApi(anyString(), any())).thenThrow(new Exception("some exception"));
assertThrows(TikTokLiveRequestException.class, () -> {
tikTokApiService.fetchRoomInfo();

View File

@@ -0,0 +1,103 @@
/*
* 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.http;
import io.github.jwdeveloper.tiktok.TikTokLive;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.Random;
public class TikTokLiveOnlineCheckerTest {
public boolean enableTests = false;
@Test
public void shouldTestOnline() {
if(!enableTests)
{
return;
}
var TARGET_USER = "bangbetmenygy";
var sut = new TikTokDataChecker();
var result = sut.isOnline(TARGET_USER);
Assertions.assertTrue(result);
}
@Test
public void shouldBeOffline() {
var TARGET_USER = "karacomparetto";
var sut = new TikTokDataChecker();
var result = sut.isOnline(TARGET_USER);
Assertions.assertFalse(result);
}
@Test
public void shouldBeValid() throws InterruptedException {
var TARGET_USER = "dostawcavideo";
var sut = new TikTokDataChecker();
var result = sut.isHostNameValid(TARGET_USER);
TikTokLive.newClient("asdasd")
.onWebsocketResponse((liveClient, event) ->
{
for(var message : event.getResponse().getMessagesList())
{
if(message.getMethod().equals("WebcastGiftMessage"))
{
try
{
var bytes = message.getMethodBytes();
var rawMessage = WebcastGiftMessage.parseFrom(bytes);
var giftName =rawMessage.getGift().getName();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
});
Assertions.assertTrue(result);
}
@Test
public void shouldNotBeValid() {
var TARGET_USER = "dqagdagda , asdaaasd";
var sut = new TikTokDataChecker();
var result = sut.isHostNameValid(TARGET_USER);
Assertions.assertFalse(result);
}
}

View File

@@ -22,12 +22,11 @@
*/
package io.github.jwdeveloper.tiktok.listener;
import io.github.jwdeveloper.tiktok.annotations.TikTokEventHandler;
import io.github.jwdeveloper.tiktok.annotations.TikTokEventObserver;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftEvent;
import io.github.jwdeveloper.tiktok.data.events.social.TikTokJoinEvent;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
import io.github.jwdeveloper.tiktok.live.LiveClient;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -42,12 +41,12 @@ import static org.mockito.Mockito.verify;
class TikTokListenersManagerTest {
private TikTokEventObserver eventObserver;
private io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver eventObserver;
private TikTokListenersManager tikTokListenersManager;
@BeforeEach
void setUp() {
eventObserver = Mockito.mock(TikTokEventObserver.class);
eventObserver = Mockito.mock(io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver.class);
List<TikTokEventListener> listeners = new ArrayList<>();
tikTokListenersManager = new TikTokListenersManager(listeners, eventObserver);
}
@@ -93,19 +92,19 @@ class TikTokListenersManagerTest {
public static class TikTokEventListenerTest implements TikTokEventListener
{
@TikTokEventHandler
@TikTokEventObserver
public void onJoin(LiveClient client, TikTokJoinEvent joinEvent)
{
}
@TikTokEventHandler
@TikTokEventObserver
public void onGift(LiveClient client, TikTokGiftEvent giftMessageEvent)
{
}
@TikTokEventHandler
@TikTokEventObserver
public void onEvent(LiveClient client, TikTokEvent event)
{

View File

@@ -41,7 +41,7 @@
<parent>
<artifactId>TikTokLiveJava</artifactId>
<groupId>io.github.jwdeveloper.tiktok</groupId>
<version>1.0.0-Release</version>
<version>1.0.13-Release</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -0,0 +1,62 @@
/*
* 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.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.data.models.Picture;
import io.github.jwdeveloper.tiktok.data.models.gifts.Gift;
import io.github.jwdeveloper.tiktok.live.GiftManager;
import io.github.jwdeveloper.tiktok.live.LiveClient;
import lombok.AllArgsConstructor;
public class CustomEventExample {
@AllArgsConstructor
public static class CheapGiftEvent extends TikTokEvent {
Gift gift;
}
@AllArgsConstructor
public static class ExpensiveGiftEvent extends TikTokEvent {
Gift gift;
}
public static void main(String[] args) {
TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME)
.onGift((liveClient, event) ->
{
if (event.getGift().getDiamondCost() > 100)
liveClient.publishEvent(new ExpensiveGiftEvent(event.getGift()));
else
liveClient.publishEvent(new CheapGiftEvent(event.getGift()));
})
.onEvent(CheapGiftEvent.class,(liveClient, event) ->
{
System.out.println("Thanks for cheap gift");
})
.onEvent(ExpensiveGiftEvent.class,(liveClient, event) ->
{
System.out.println("Thanks for expensive gift!");
})
.build();
}
}

View File

@@ -0,0 +1,73 @@
/*
* 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.data.models.Picture;
import io.github.jwdeveloper.tiktok.live.GiftManager;
import io.github.jwdeveloper.tiktok.live.LiveClient;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
public class CustomGiftExample {
/**
* If you can't find your wanted Gift inside Gift enum register it manually
*/
public static void main(String[] args) {
LiveClient client = TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME)
.onConnected((liveClient, event) ->
{
liveClient.disconnect();
})
.onWebsocketResponse((liveClient, event) ->
{
var packets =event.getResponse().getMessagesList();
for(var packet : packets)
{
var name = packet.getMethod();
var data = packet.getPayload();
if(name.equals("WebcastGiftMessage"))
{
// var message = WebcastGiftMessage.parseFrom(data);
}
}
})
.onGift((liveClient, event) ->
{
liveClient.getLogger().info(event.getGift().getName());
}).build();
GiftManager giftManager = client.getGiftManager();
//If you can't find your wanted Gift inside Gift enum register it manually
giftManager.registerGift(123, "my custom gift", 69, new Picture("https://as2.ftcdn.net/v2/jpg/03/03/62/45/1000_F_303624505_u0bFT1Rnoj8CMUSs8wMCwoKlnWlh5Jiq.jpg"));
//You can also override existing gift, for example Rose has Id 5655
//We can make our custom gift appear in the event instead of rose
giftManager.registerGift(5655, "custom-rose", 999, new Picture("https://as2.ftcdn.net/v2/jpg/03/03/62/45/1000_F_303624505_u0bFT1Rnoj8CMUSs8wMCwoKlnWlh5Jiq.jpg"));
client.connect();
}
}

View File

@@ -0,0 +1,119 @@
/*
* 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.data.events.common.TikTokEvent;
import io.github.jwdeveloper.tiktok.mappers.data.MappingResult;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastChatMessage;
public class CustomMappingExample {
public static void main(String[] args) {
TikTokLive.newClient("saszareznikow")
.onMapping(mapper ->
{
mapper.forMessage(WebcastChatMessage.class)
.onBeforeMapping((inputBytes, messageName, mapperHelper) ->
{
System.out.println("===============================");
System.out.println("OnBefore mapping: " + messageName);
return inputBytes;
})
.onMapping((inputBytes, messageName, mapperHelper) ->
{
System.out.println("onMapping mapping: " + messageName);
var message = mapperHelper.bytesToWebcastObject(inputBytes, WebcastChatMessage.class);
var language = message.getContentLanguage();
var userName = message.getUser().getNickname();
var content = message.getContent();
var event = new CustomChatEvent(language, userName, content);
return MappingResult.of(message, event);
})
.onAfterMapping(mappingResult ->
{
var source = mappingResult.getSource();
var events = mappingResult.getEvents();
System.out.println("onAfter mapping, " + source.getClass().getSimpleName() + " was mapped to " + events.size() + " events");
return events;
});
/*
There might be cast that we don't have Webcast class for incoming message from TikTok
`mapperHelper.bytesToProtoBufferStructure` but you can still investigate message structure
by using helper methods
*/
mapper.forMessage("WebcastMemberMessage")
.onBeforeMapping((inputBytes, messageName, mapperHelper) ->
{
if (mapperHelper.isMessageHasProtoClass(messageName)) {
var messageObject = mapperHelper.bytesToWebcastObject(inputBytes, messageName);
// System.out.println(mapperHelper.toJson(messageObject));
} else {
var structure = mapperHelper.bytesToProtoBufferStructure(inputBytes);
// System.out.println(structure.toJson());
}
return inputBytes;
});
})
.onError((liveClient, event) ->
{
event.getException().printStackTrace();
})
.buildAndConnect();
}
public static class CustomChatEvent extends TikTokEvent {
private final String langauge;
private final String userName;
private final String message;
public CustomChatEvent(String language, String userName, String message) {
this.langauge = language;
this.userName = userName;
this.message = message;
}
public String getLangauge() {
return langauge;
}
public String getUserName() {
return userName;
}
public String getMessage() {
return message;
}
@Override
public String toString() {
return "CustomChatEvent{" +
"language='" + langauge + '\'' +
", userName='" + userName + '\'' +
", message='" + message + '\'' +
'}';
}
}
}

View File

@@ -22,7 +22,7 @@
*/
package io.github.jwdeveloper.tiktok;
import io.github.jwdeveloper.tiktok.annotations.TikTokEventHandler;
import io.github.jwdeveloper.tiktok.annotations.TikTokEventObserver;
import io.github.jwdeveloper.tiktok.data.events.TikTokCommentEvent;
import io.github.jwdeveloper.tiktok.data.events.TikTokErrorEvent;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
@@ -65,24 +65,24 @@ public class ListenerExample
public static class CustomListener implements TikTokEventListener {
@TikTokEventHandler
@TikTokEventObserver
public void onLike(LiveClient liveClient, TikTokLikeEvent event) {
System.out.println(event.toString());
}
@TikTokEventHandler
@TikTokEventObserver
public void onError(LiveClient liveClient, TikTokErrorEvent event) {
// event.getException().printStackTrace();
}
@TikTokEventHandler
@TikTokEventObserver
public void onComment(LiveClient liveClient, TikTokCommentEvent event) {
var userName = event.getUser().getName();
var text = event.getText();
liveClient.getLogger().info(userName + ": " + text);
}
@TikTokEventHandler
@TikTokEventObserver
public void onGift(LiveClient liveClient, TikTokGiftEvent event) {
var message = switch (event.getGift()) {
case ROSE -> "Thanks :)";
@@ -95,7 +95,7 @@ public class ListenerExample
liveClient.getLogger().info(message);
}
@TikTokEventHandler
@TikTokEventObserver
public void onAnyEvent(LiveClient liveClient, TikTokEvent event) {
liveClient.getLogger().info(event.getClass().getSimpleName());
}

View File

@@ -22,19 +22,67 @@
*/
package io.github.jwdeveloper.tiktok;
import io.github.jwdeveloper.tiktok.data.events.TikTokSubNotifyEvent;
import io.github.jwdeveloper.tiktok.data.events.TikTokSubscribeEvent;
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftEvent;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveOfflineHostException;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
import io.github.jwdeveloper.tiktok.utils.ConsoleColors;
import io.github.jwdeveloper.tiktok.utils.JsonUtil;
import java.io.IOException;
import java.time.Duration;
import java.util.HashMap;
import java.util.logging.Level;
public class SimpleExample
{
public static String TIKTOK_HOSTNAME = "szwagierkaqueen";
public class SimpleExample {
public static String TIKTOK_HOSTNAME = "bangbetmenygy";
public static void main(String[] args) throws IOException {
showLogo();
// set tiktok username
/*
//Optional checking if host name is correct
if(TikTokLive.isHostNameValid(TIKTOK_HOSTNAME))
{
System.out.println("user name exists!");
}
*/
// Optional checking if live is online
if (TikTokLive.isLiveOnline(TIKTOK_HOSTNAME)) {
System.out.println("Live is online!");
}
TikTokLive.newClient("test")
.onWebsocketResponse((liveClient, event) ->
{
var response = event.getResponse();
for (var message : response.getMessagesList()) {
var name = message.getMethod();
var binaryData = message.getPayload();
System.out.println("Event name: " + name);
if (name.equals("WebcastGiftEvent")) {
try {
WebcastGiftMessage giftMessage = WebcastGiftMessage.parseFrom(binaryData);
var giftName = giftMessage.getGift().getName();
var giftId = giftMessage.getGiftId();
var userName = giftMessage.getUser().getNickname();
System.out.println("Gift: "+giftName+" id: "+giftId+" from user: "+userName);
} catch (Exception e) {
throw new RuntimeException("Mapping error", e);
}
}
}
}).buildAndConnect();
TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME)
.configure(clientSettings ->
{
@@ -43,7 +91,6 @@ public class SimpleExample
clientSettings.setTimeout(Duration.ofSeconds(2)); // Connection timeout
clientSettings.setLogLevel(Level.ALL); // Log level
clientSettings.setPrintToConsole(true); // Printing all logs to console even if log level is Level.OFF
clientSettings.setHandleExistingEvents(true); // Invokes all TikTok events that had occurred before connection
clientSettings.setRetryOnConnectionFailure(true); // Reconnecting if TikTok user is offline
clientSettings.setRetryConnectionTimeout(Duration.ofSeconds(1)); // Timeout before next reconnection
@@ -58,18 +105,42 @@ public class SimpleExample
//clientSettings.setRoomId("XXXXXXXXXXXXXXXXX");
})
.onConnected((liveClient, event) ->
{
for (var gift : liveClient.getGiftManager().getGifts()) {
gift.getPicture().downloadImageAsync().thenAccept(image ->
{
});
}
})
.onWebsocketMessage((liveClient, event) ->
{
var tiktokLiveEvent = event.getEvent();
if (tiktokLiveEvent instanceof TikTokSubNotifyEvent e) {
System.out.println("it was subscrible event");
}
})
.onWebsocketResponse((liveClient, event) ->
{
event.getResponse();
})
.onGift((liveClient, event) ->
{
switch (event.getGift()) {
case ROSE -> print(ConsoleColors.RED, "Rose!");
case GG -> print(ConsoleColors.YELLOW, " GOOD GAME!");
case TIKTOK -> print(ConsoleColors.CYAN,"Thanks for TikTok");
default -> print(ConsoleColors.GREEN, "[Thanks for gift] ", ConsoleColors.YELLOW, event.getGift().getName(), "x", event.getCombo());
case TIKTOK -> print(ConsoleColors.CYAN, "Thanks for TikTok");
default ->
print(ConsoleColors.GREEN, "[Thanks for gift] ", ConsoleColors.YELLOW, event.getGift().getName(), "x", event.getCombo());
}
})
.onGiftCombo((liveClient, event) ->
{
print(ConsoleColors.RED,"GIFT COMBO",event.getGift().getName(),event.getCombo());
print(ConsoleColors.RED, "GIFT COMBO", event.getGift().getName(), event.getCombo());
})
.onConnected((client, event) ->
{
@@ -77,7 +148,11 @@ public class SimpleExample
})
.onDisconnected((liveClient, event) ->
{
print(ConsoleColors.RED,"[Disconnected]");
print(ConsoleColors.RED, "[Disconnected]");
})
.onRoomInfo((liveClient, event) ->
{
var info = event.getRoomInfo();
})
.onFollow((liveClient, event) ->
{
@@ -111,9 +186,8 @@ public class SimpleExample
System.out.println(sb);
}
private static void showLogo()
{
System.out.println(ConsoleColors.GREEN+"""
private static void showLogo() {
System.out.println(ConsoleColors.GREEN + """
_____ _ _ _____ _ _ _ \s
|_ _(_) | _|_ _|__ | | _| | (_)_ _____\s

708
README.md
View File

@@ -1,9 +1,7 @@
<div align="center" >
<a target="blank" >
<img src="https://github.com/jwdeveloper/TikTokLiveJava/assets/79764581/1f9951b4-a270-4535-bf38-a6f41cdf8f43" width="15%" >
</img>
<img src="https://raw.githubusercontent.com/jwdeveloper/TikTokLiveJava/develop-1_0_0/Tools-ReadmeGenerator/src/main/resources/logo.svg" width="15%" >
</a>
</div>
<div align="center" >
<h1>TikTok Live Java</h1>
@@ -13,30 +11,26 @@
<div align="center" >
<a href="https://jitpack.io/#jwdeveloper/TikTok-Live-Java" target="blank" >
<img src="https://jitpack.io/v/jwdeveloper/TikTok-Live-Java.svg" width="20%" >
</img>
</a>
<a href="https://discord.gg/e2XwPNTBBr" target="blank" >
<img src="https://img.shields.io/badge/Discord-%235865F2.svg?style=for-the-badge&logo=discord&logoColor=white" >
</img>
</a>
<a target="blank" >
<img src="https://img.shields.io/badge/java-%23ED8B00.svg?style=for-the-badge&logo=openjdk&logoColor=white" >
</img>
</a>
</div>
</div>
# 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.
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.
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.
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.
# Contributors
[Library documentation for contributors](https://github.com/jwdeveloper/TikTokLiveJava/wiki)
<div align="center">
<a href="https://www.youtube.com/watch?v=eerWGgUKc6c" align="right" target="blank"><img src="https://img.youtube.com/vi/eerWGgUKc6c/hqdefault.jpg" alt="IMAGE ALT TEXT" width="38%" align="right"></a>
@@ -52,23 +46,17 @@ Do you prefer other programming languages?
**NOTE:** This is not an official API. It's a reverse engineering project.
#### Overview
- [Getting started](#getting-started)
- [Events](#events)
- [Listeners](#listeners)
- [Contributing](#contributing)
## Getting started
1. Install the package via Maven
1. Install the package
Maven
```xml
<repositories>
<repository>
@@ -81,12 +69,27 @@ Do you prefer other programming languages?
<dependency>
<groupId>com.github.jwdeveloper.TikTok-Live-Java</groupId>
<artifactId>Client</artifactId>
<version>1.0.0-Release</version>
<version>1.0.12-Release</version>
<scope>compile</scope>
</dependency>
</dependencies>
```
Gradle
```gradle
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.jwdeveloper.TikTok-Live-Java:Client:1.0.12-Release'
}
```
2. Create your first chat connection
```java
@@ -107,6 +110,13 @@ TikTokLive.newClient("bangbetmenygy")
{
System.out.println(event.getComboState()+ " " + event.getCombo() + " " + event.getGift().getName());
})
.onRoomInfo((liveClient, event) ->
{
var roomInfo = event.getRoomInfo();
System.out.println("Room Id: "+roomInfo.getRoomId());
System.out.println("Likes: "+roomInfo.getLikesCount());
System.out.println("Viewers: "+roomInfo.getViewersCount());
})
.onJoin((liveClient, event) ->
{
System.out.println(event.getUser().getProfileName() + "Hello on my stream! ");
@@ -134,7 +144,6 @@ TikTokLive.newClient("bangbetmenygy")
settings.setTimeout(Duration.ofSeconds(2)); // Connection timeout
settings.setLogLevel(Level.ALL); // Log level
settings.setPrintToConsole(true); // Printing all logs to console even if log level is Level.OFF
settings.setHandleExistingEvents(true); // Invokes all TikTok events that had occurred before connection
settings.setRetryOnConnectionFailure(true); // Reconnecting if TikTok user is offline
settings.setRetryConnectionTimeout(Duration.ofSeconds(1)); // Timeout before next reconnection
@@ -156,36 +165,35 @@ TikTokLive.newClient("bangbetmenygy")
**Control**:
**Control**:
- [onConnected](#onconnected-tiktokconnectedevent)
- [onReconnecting](#onreconnecting-tiktokreconnectingevent)
- [onDisconnected](#ondisconnected-tiktokdisconnectedevent)
- [onReconnecting](#onreconnecting-tiktokreconnectingevent)
- [onError](#onerror-tiktokerrorevent)
**Message**:
**Message**:
- [onEvent](#onevent-tiktokevent)
- [onShare](#onshare-tiktokshareevent)
- [onLivePaused](#onlivepaused-tiktoklivepausedevent)
- [onRoom](#onroom-tiktokroomevent)
- [onGiftCombo](#ongiftcombo-tiktokgiftcomboevent)
- [onJoin](#onjoin-tiktokjoinevent)
- [onRoomUserInfo](#onroomuserinfo-tiktokroomuserinfoevent)
- [onComment](#oncomment-tiktokcommentevent)
- [onGift](#ongift-tiktokgiftevent)
- [onLike](#onlike-tiktoklikeevent)
- [onSubscribe](#onsubscribe-tiktoksubscribeevent)
- [onQuestion](#onquestion-tiktokquestionevent)
- [onEmote](#onemote-tiktokemoteevent)
- [onLiveEnded](#onliveended-tiktokliveendedevent)
- [onFollow](#onfollow-tiktokfollowevent)
- [onUnhandledSocial](#onunhandledsocial-tiktokunhandledsocialevent)
- [onLike](#onlike-tiktoklikeevent)
- [onLiveEnded](#onliveended-tiktokliveendedevent)
- [onRoomInfo](#onroominfo-tiktokroominfoevent)
- [onShare](#onshare-tiktokshareevent)
- [onGiftCombo](#ongiftcombo-tiktokgiftcomboevent)
- [onEmote](#onemote-tiktokemoteevent)
- [onGift](#ongift-tiktokgiftevent)
- [onComment](#oncomment-tiktokcommentevent)
- [onLivePaused](#onlivepaused-tiktoklivepausedevent)
- [onLiveUnpaused](#onliveunpaused-tiktokliveunpausedevent)
- [onJoin](#onjoin-tiktokjoinevent)
**Debug**:
**Debug**:
- [onWebsocketResponse](#onwebsocketresponse-tiktokwebsocketresponseevent)
- [onWebsocketUnhandledMessage](#onwebsocketunhandledmessage-tiktokwebsocketunhandledmessageevent)
- [onWebsocketResponse](#onwebsocketresponse-tiktokwebsocketresponseevent)
- [onWebsocketMessage](#onwebsocketmessage-tiktokwebsocketmessageevent)
# Examples
<br>
@@ -193,8 +201,8 @@ TikTokLive.newClient("bangbetmenygy")
## onConnected [TikTokConnectedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokConnectedEvent.java)
Triggered when the connection is successfully established.
Triggered when the connection is successfully established.
```java
TikTokLive.newClient("host-name")
@@ -207,6 +215,26 @@ TikTokLive.newClient("host-name")
<br>
## onDisconnected [TikTokDisconnectedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokDisconnectedEvent.java)
Triggered when the connection gets disconnected. In that case you can call connect() again to have a reconnect logic.
Note that you should wait a little bit before attempting a reconnect to to avoid being rate-limited.
```java
TikTokLive.newClient("host-name")
.onDisconnected((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onReconnecting [TikTokReconnectingEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokReconnectingEvent.java)
@@ -224,33 +252,13 @@ TikTokLive.newClient("host-name")
<br>
## onDisconnected [TikTokDisconnectedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokDisconnectedEvent.java)
Triggered when the connection gets disconnected. In that case you can call connect() again to have a reconnect logic.
Note that you should wait a little bit before attempting a reconnect to to avoid being rate-limited.
```java
TikTokLive.newClient("host-name")
.onDisconnected((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onError [TikTokErrorEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokErrorEvent.java)
General error event. You should handle this.
General error event. You should handle this.
```java
TikTokLive.newClient("host-name")
@@ -268,8 +276,8 @@ TikTokLive.newClient("host-name")
## onEvent [TikTokEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/common/TikTokEvent.java)
Base class for all events
Base class for all events
```java
TikTokLive.newClient("host-name")
@@ -282,13 +290,125 @@ TikTokLive.newClient("host-name")
<br>
## onSubscribe [TikTokSubscribeEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokSubscribeEvent.java)
Triggers when a user creates a subscription.
```java
TikTokLive.newClient("host-name")
.onSubscribe((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onQuestion [TikTokQuestionEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokQuestionEvent.java)
Triggered every time someone asks a new question via the question feature.
```java
TikTokLive.newClient("host-name")
.onQuestion((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onFollow [TikTokFollowEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokFollowEvent.java)
Triggers when a user follows the streamer. Based on social event.
```java
TikTokLive.newClient("host-name")
.onFollow((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onLike [TikTokLikeEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokLikeEvent.java)
Triggered when a viewer sends likes to the streamer. For streams with many viewers, this event is not always triggered by TikTok.
```java
TikTokLive.newClient("host-name")
.onLike((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onLiveEnded [TikTokLiveEndedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokLiveEndedEvent.java)
Triggered when the live stream gets terminated by the host. Will also trigger the TikTokDisconnectedEvent event.
```java
TikTokLive.newClient("host-name")
.onLiveEnded((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onRoomInfo [TikTokRoomInfoEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/room/TikTokRoomInfoEvent.java)
```java
TikTokLive.newClient("host-name")
.onRoomInfo((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onShare [TikTokShareEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokShareEvent.java)
Triggers when a user shares the stream. Based on social event.
Triggers when a user shares the stream. Based on social event.
```java
TikTokLive.newClient("host-name")
@@ -301,6 +421,94 @@ TikTokLive.newClient("host-name")
<br>
## onGiftCombo [TikTokGiftComboEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/gift/TikTokGiftComboEvent.java)
Triggered every time gift is sent
@see GiftSendType it has 3 states
<p>Example when user sends gift with combo</p>
<p>>Combo: 1 -> comboState = GiftSendType.Begin</p>
<p>Combo: 4 -> comboState = GiftSendType.Active</p>
<p>Combo: 8 -> comboState = GiftSendType.Active</p>
<p>Combo: 12 -> comboState = GiftSendType.Finished</p>
Remember if comboState is Finished both TikTokGiftComboEvent and TikTokGiftEvent event gets triggered
```java
TikTokLive.newClient("host-name")
.onGiftCombo((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onEmote [TikTokEmoteEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokEmoteEvent.java)
Triggered every time a subscriber sends an emote (sticker).
```java
TikTokLive.newClient("host-name")
.onEmote((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onGift [TikTokGiftEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/gift/TikTokGiftEvent.java)
Triggered when user sends gifts that has
no combo (most of expensive gifts)
or if combo has finished
```java
TikTokLive.newClient("host-name")
.onGift((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onComment [TikTokCommentEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokCommentEvent.java)
Triggered every time a new chat comment arrives.
```java
TikTokLive.newClient("host-name")
.onComment((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onLivePaused [TikTokLivePausedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokLivePausedEvent.java)
@@ -320,42 +528,13 @@ TikTokLive.newClient("host-name")
<br>
## onRoom [TikTokRoomEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/room/TikTokRoomEvent.java)
## onLiveUnpaused [TikTokLiveUnpausedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokLiveUnpausedEvent.java)
```java
TikTokLive.newClient("host-name")
.onRoom((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onGiftCombo [TikTokGiftComboEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/gift/TikTokGiftComboEvent.java)
Triggered every time gift is sent
@see GiftSendType it has 3 states
<p>Example when user sends gift with combo</p>
<p>>Combo: 1 -> comboState = GiftSendType.Begin</p>
<p>Combo: 4 -> comboState = GiftSendType.Active</p>
<p>Combo: 8 -> comboState = GiftSendType.Active</p>
<p>Combo: 12 -> comboState = GiftSendType.Finsihed</p>
Remember if comboState is Finsihed both TikTokGiftComboEvent and TikTokGiftEvent event gets triggered
```java
TikTokLive.newClient("host-name")
.onGiftCombo((liveClient, event) ->
.onLiveUnpaused((liveClient, event) ->
{
})
@@ -383,187 +562,15 @@ TikTokLive.newClient("host-name")
<br>
## onRoomUserInfo [TikTokRoomUserInfoEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/room/TikTokRoomUserInfoEvent.java)
## onWebsocketUnhandledMessage [TikTokWebsocketUnhandledMessageEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/websocket/TikTokWebsocketUnhandledMessageEvent.java)
Only top 5 users in ranking has detailed data
rest has only ID
```java
TikTokLive.newClient("host-name")
.onRoomUserInfo((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onComment [TikTokCommentEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokCommentEvent.java)
Triggered every time a new chat comment arrives.
```java
TikTokLive.newClient("host-name")
.onComment((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onGift [TikTokGiftEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/gift/TikTokGiftEvent.java)
Triggered when user sends gifts that has
no combo (most of expensive gifts)
or if combo has finished
```java
TikTokLive.newClient("host-name")
.onGift((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onLike [TikTokLikeEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokLikeEvent.java)
Triggered when a viewer sends likes to the streamer. For streams with many viewers, this event is not always triggered by TikTok.
```java
TikTokLive.newClient("host-name")
.onLike((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onSubscribe [TikTokSubscribeEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokSubscribeEvent.java)
Triggers when a user creates a subscription.
```java
TikTokLive.newClient("host-name")
.onSubscribe((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onQuestion [TikTokQuestionEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokQuestionEvent.java)
Triggered every time someone asks a new question via the question feature.
```java
TikTokLive.newClient("host-name")
.onQuestion((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onEmote [TikTokEmoteEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokEmoteEvent.java)
Triggered every time a subscriber sends an emote (sticker).
```java
TikTokLive.newClient("host-name")
.onEmote((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onLiveEnded [TikTokLiveEndedEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokLiveEndedEvent.java)
Triggered when the live stream gets terminated by the host. Will also trigger the TikTokDisconnectedEvent event.
```java
TikTokLive.newClient("host-name")
.onLiveEnded((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onFollow [TikTokFollowEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/social/TikTokFollowEvent.java)
Triggers when a user follows the streamer. Based on social event.
```java
TikTokLive.newClient("host-name")
.onFollow((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onUnhandledSocial [TikTokUnhandledSocialEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/TikTokUnhandledSocialEvent.java)
Triggered every time a protobuf encoded webcast message arrives. You can deserialize the binary object depending on the use case.
```java
TikTokLive.newClient("host-name")
.onUnhandledSocial((liveClient, event) ->
.onWebsocketUnhandledMessage((liveClient, event) ->
{
})
@@ -580,30 +587,11 @@ TikTokLive.newClient("host-name")
```java
TikTokLive.newClient("host-name")
.onWebsocketResponse((liveClient, event) ->
{
.onWebsocketResponse((liveClient, event) ->
{
})
.buildAndConnect();
```
<br>
## onWebsocketUnhandledMessage [TikTokWebsocketUnhandledMessageEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/websocket/TikTokWebsocketUnhandledMessageEvent.java)
Triggered every time a protobuf encoded webcast message arrives. You can deserialize the binary object depending on the use case.
```java
TikTokLive.newClient("host-name")
.onWebsocketUnhandledMessage((liveClient, event) ->
{
})
.buildAndConnect();
})
.buildAndConnect();
```
@@ -613,16 +601,16 @@ TikTokLive.newClient("host-name")
## onWebsocketMessage [TikTokWebsocketMessageEvent](https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/data/events/websocket/TikTokWebsocketMessageEvent.java)
Triggered every time a protobuf encoded webcast message arrives. You can deserialize the binary object depending on the use case.
Triggered every time a protobuf encoded webcast message arrives. You can deserialize the binary object depending on the use case.
```java
TikTokLive.newClient("host-name")
.onWebsocketMessage((liveClient, event) ->
{
.onWebsocketMessage((liveClient, event) ->
{
})
.buildAndConnect();
})
.buildAndConnect();
```
@@ -635,72 +623,72 @@ TikTokLive.newClient("host-name")
```java
/**
*
* Listeners are an alternative way of handling events.
* I would to suggest to use then when logic of handing event
* is more complex
*
*/
public static void main(String[] args) throws IOException {
/**
*
* Listeners are an alternative way of handling events.
* I would to suggest to use then when logic of handing event
* is more complex
*
*/
public static void main(String[] args) throws IOException {
showLogo();
CustomListener customListener = new CustomListener();
TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME)
.addListener(customListener)
.buildAndConnect();
.addListener(customListener)
.buildAndConnect();
System.in.read();
}
/**
*
* Method in TikTokEventListener should meet 4 requirements to be detected
* - must have @TikTokEventHandler annotation
* - must have 2 parameters
* - first parameter must be LiveClient
* - second must be class that extending TikTokEvent
*/
public static class CustomListener implements TikTokEventListener {
@TikTokEventHandler
public void onLike(LiveClient liveClient, TikTokLikeEvent event) {
System.out.println(event.toString());
}
/**
*
* Method in TikTokEventListener should meet 4 requirements to be detected
* - must have @TikTokEventHandler annotation
* - must have 2 parameters
* - first parameter must be LiveClient
* - second must be class that extending TikTokEvent
*/
public static class CustomListener implements TikTokEventListener {
@TikTokEventHandler
public void onLike(LiveClient liveClient, TikTokLikeEvent event) {
System.out.println(event.toString());
}
@TikTokEventHandler
public void onError(LiveClient liveClient, TikTokErrorEvent event) {
// event.getException().printStackTrace();
}
@TikTokEventHandler
public void onComment(LiveClient liveClient, TikTokCommentEvent event) {
var userName = event.getUser().getName();
var text = event.getText();
liveClient.getLogger().info(userName + ": " + text);
}
@TikTokEventHandler
public void onGift(LiveClient liveClient, TikTokGiftEvent event) {
var message = switch (event.getGift()) {
case ROSE -> "Thanks :)";
case APPETIZERS -> ":OO";
case APRIL -> ":D";
case TIKTOK -> ":P";
case CAP -> ":F";
default -> ":I";
};
liveClient.getLogger().info(message);
}
@TikTokEventHandler
public void onAnyEvent(LiveClient liveClient, TikTokEvent event) {
liveClient.getLogger().info(event.getClass().getSimpleName());
}
@TikTokEventHandler
public void onError(LiveClient liveClient, TikTokErrorEvent event) {
// event.getException().printStackTrace();
}
//
@TikTokEventHandler
public void onComment(LiveClient liveClient, TikTokCommentEvent event) {
var userName = event.getUser().getName();
var text = event.getText();
liveClient.getLogger().info(userName + ": " + text);
}
@TikTokEventHandler
public void onGift(LiveClient liveClient, TikTokGiftEvent event) {
var message = switch (event.getGift()) {
case ROSE -> "Thanks :)";
case APPETIZERS -> ":OO";
case APRIL -> ":D";
case TIKTOK -> ":P";
case CAP -> ":F";
default -> ":I";
};
liveClient.getLogger().info(message);
}
@TikTokEventHandler
public void onAnyEvent(LiveClient liveClient, TikTokEvent event) {
liveClient.getLogger().info(event.getClass().getSimpleName());
}
}
//
```

View File

@@ -5,7 +5,7 @@
<parent>
<artifactId>TikTokLiveJava</artifactId>
<groupId>io.github.jwdeveloper.tiktok</groupId>
<version>1.0.0-Release</version>
<version>1.0.13-Release</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -29,6 +29,11 @@
<artifactId>jdbi3-core</artifactId>
<version>3.23.0</version>
</dependency>
<dependency>
<groupId>com.googlecode.protobuf-java-format</groupId>
<artifactId>protobuf-java-format</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi3-sqlobject</artifactId>

View File

@@ -0,0 +1,65 @@
/*
* 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.tools;
import io.github.jwdeveloper.tiktok.tools.collector.client.TikTokDataCollectorBuilder;
import io.github.jwdeveloper.tiktok.tools.collector.api.DataCollectorBuilder;
import io.github.jwdeveloper.tiktok.tools.tester.TikTokDataTesterBuilder;
import io.github.jwdeveloper.tiktok.tools.tester.api.DataTesterBuilder;
public class TikTokLiveTools
{
/**
*
* @param databaseName dataCollector use sql-lite database to store message
* if database not exits it creates new one
* @return
*/
public static DataCollectorBuilder createCollector(String databaseName)
{
return new TikTokDataCollectorBuilder(databaseName);
}
/**
*
* @param databaseName dataTester will read messages for database
* before using dataTester, use dataCollector to create database
* if database not exits exception will be thrown
* @return
*/
public static DataTesterBuilder createTester(String databaseName)
{
return new TikTokDataTesterBuilder(databaseName);
}
/**
*
* Returns browser application that collects and display Events, Messages, WebcastResponses
* in online web editor so it's easier to read and analyze data structures
* @return
*/
public static void createWebViewer()
{
}
}

View File

@@ -1,83 +0,0 @@
/*
* 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.tools.collector;
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
import io.github.jwdeveloper.tiktok.tools.collector.client.TikTokMessageCollectorClient;
import java.io.IOException;
import java.sql.SQLException;
public class RunCollector {
//https://protobuf-decoder.netlify.app/
//https://streamdps.com/tiktok-widgets/gifts/
//WebcastLinkMicBattleItemCard does streamer win battle?
public static void main(String[] args) throws SQLException, IOException {
TikTokMessageCollectorClient.create("giftsCollector")
.addUser("cbcgod")
// .addUser("mr_cios")
// .addUser("cbcgod")
// .addUser("psychotropnazywo")
// .addUser("accordionistka")
.addEventFilter(WebcastGiftMessage.class)
.addOnBuilder(liveClientBuilder ->
{
liveClientBuilder.onGift((liveClient, event) ->
{
});
liveClientBuilder.onGiftCombo((liveClient, event) ->
{
});
liveClientBuilder.onGift((liveClient, event) ->
{
var sb = new StringBuilder();
sb.append("GIFT User: " + event.getUser().getProfileName()+" ");
sb.append("Name: " + event.getGift().name() + " ");
sb.append("Combo: " + event.getCombo() + " ");
System.out.println(sb.toString());
});
liveClientBuilder.onGiftCombo((liveClient, event) ->
{
var sb = new StringBuilder();
sb.append("COMBO User: " + event.getUser().getProfileName()+" ");
sb.append("Name: " + event.getGift().name() + " ");
sb.append("Combo: " + event.getCombo() + " ");
sb.append("Type: " + event.getComboState().name());
System.out.println(sb.toString());
});
})
.buildAndRun();
System.in.read();
}
}

View File

@@ -0,0 +1,33 @@
/*
* 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.tools.collector.api;
public interface DataCollector {
void connect();
void disconnect();
void disconnect(boolean keepDatabase);
}

View File

@@ -20,41 +20,25 @@
* 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.tools.collector.api;
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
import io.github.jwdeveloper.tiktok.live.builder.LiveClientBuilder;
import io.github.jwdeveloper.tiktok.tools.db.TikTokDatabase;
public class CancelationToken
{
private boolean isCanceled =false;
import java.util.function.Consumer;
public void cancel()
{
isCanceled =true;
}
public interface DataCollectorBuilder extends DataFilters<DataCollectorBuilder> {
DataCollectorBuilder setOutputPath(String path);
DataCollectorBuilder setSessionTag(String sessionTimestamp);
public boolean isCancel()
{
DataCollectorBuilder setDatabase(TikTokDatabase database);
return isCanceled;
}
DataCollectorBuilder configureLiveClient(Consumer<LiveClientBuilder> consumer);
public void throwIfCancel()
{
if(!isCanceled)
{
return;
}
throw new TikTokLiveException("Token requested cancelation");
}
DataCollectorBuilder addUser(String user);
public boolean isNotCancel()
{
return !isCancel();
}
DataCollector buildAndRun();
DataCollector build();
public static CancelationToken create()
{
return new CancelationToken();
}
}

View File

@@ -0,0 +1,35 @@
/*
* 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.tools.collector.api;
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
public interface DataFilters<T> {
T addMessageFilter(Class<? extends com.google.protobuf.GeneratedMessageV3> message);
T addMessageFilter(String message);
T addEventFilter(Class<? extends TikTokEvent> event);
T addEventFilter(String event);
}

View File

@@ -0,0 +1,41 @@
/*
* 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.tools.collector.api;
import io.github.jwdeveloper.tiktok.live.builder.LiveClientBuilder;
import lombok.Data;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
@Data
public class TikTokDataCollectorModel {
private List<String> users;
private String outputPath;
private String outputName;
private Set<String> eventsFilter;
private Set<String> messagesFilter;
private String sessionTag ="";
private Consumer<LiveClientBuilder> onConfigureLiveClient;
}

Some files were not shown because too many files have changed in this diff Show More