Skip to content

Commit 7817aeb

Browse files
authored
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()
2 parents 7886534 + 6d268c4 commit 7817aeb

File tree

53 files changed

+29067
-342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+29067
-342
lines changed

.idea/protoeditor.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

API/src/main/java/io/github/jwdeveloper/tiktok/annotations/EventMeta.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@
3030
{
3131
EventType eventType();
3232
}
33+
34+
35+
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
* Copyright (c) 2023-2023 jwdeveloper [email protected]
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining
5+
* a copy of this software and associated documentation files (the
6+
* "Software"), to deal in the Software without restriction, including
7+
* without limitation the rights to use, copy, modify, merge, publish,
8+
* distribute, sublicense, and/or sell copies of the Software, and to
9+
* permit persons to whom the Software is furnished to do so, subject to
10+
* the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be
13+
* included in all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*/
23+
package io.github.jwdeveloper.tiktok.data.events.envelop;
24+
25+
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
26+
import io.github.jwdeveloper.tiktok.annotations.EventType;
27+
import io.github.jwdeveloper.tiktok.data.events.common.TikTokHeaderEvent;
28+
import io.github.jwdeveloper.tiktok.data.models.Text;
29+
30+
import io.github.jwdeveloper.tiktok.data.models.chest.Chest;
31+
import io.github.jwdeveloper.tiktok.data.models.users.User;
32+
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastEnvelopeMessage;
33+
import lombok.Value;
34+
35+
import java.util.Date;
36+
37+
38+
@EventMeta(eventType = EventType.Message)
39+
@Value
40+
public class TikTokChestEvent extends TikTokHeaderEvent {
41+
42+
/**
43+
* Chest target
44+
*/
45+
Chest chest;
46+
47+
/**
48+
* User that send a chest
49+
*/
50+
User user;
51+
52+
/**
53+
* Time when chest has been open
54+
*/
55+
Date openedAt;
56+
57+
public TikTokChestEvent(Chest chest, WebcastEnvelopeMessage msg) {
58+
super(msg.getCommon());
59+
this.chest = chest;
60+
61+
var text = Text.map(msg.getCommon().getDisplayText());
62+
var userPiece = (Text.UserTextPiece) text.getTextPieces().get(0);
63+
user = userPiece.getUser();
64+
65+
66+
var envelopInfo = msg.getEnvelopeInfo();
67+
68+
openedAt = new Date(envelopInfo.getUnpackAt());
69+
70+
}
71+
}

API/src/main/java/io/github/jwdeveloper/tiktok/data/models/Text.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
import java.util.ArrayList;
3131
import java.util.List;
32+
import java.util.Optional;
3233
import java.util.regex.Pattern;
3334

3435
@Getter
@@ -45,6 +46,12 @@ public Text(String key, String pattern, List<TextPiece> textPieces) {
4546
this.value = computeValue();
4647
}
4748

49+
50+
public <T extends TextPiece> Optional<TextPiece> getTextPiece(Class<T> type)
51+
{
52+
return textPieces.stream().filter(e -> e.getClass().equals(type)).findFirst();
53+
}
54+
4855
public static Text map(io.github.jwdeveloper.tiktok.messages.data.Text input) {
4956
var pieces = input.getPiecesListList().stream().map(Text::mapTextPiece).toList();
5057
return new Text(input.getKey(), input.getDefaultPattern(), pieces);
@@ -98,6 +105,7 @@ public StringTextPiece(String text) {
98105
}
99106
}
100107

108+
@Value
101109
public static class UserTextPiece extends TextPiece {
102110
User user;
103111

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package io.github.jwdeveloper.tiktok.data.models.chest;
2+
3+
4+
import lombok.AllArgsConstructor;
5+
import lombok.Data;
6+
7+
@Data
8+
@AllArgsConstructor
9+
public class Chest {
10+
11+
/**
12+
* Total diamonds inside the chest
13+
*/
14+
int totalDiamonds;
15+
16+
/**
17+
* Total users participated in chest
18+
*/
19+
int totalUsers;
20+
21+
22+
23+
}

API/src/main/java/io/github/jwdeveloper/tiktok/data/models/gifts/Gift.java

Lines changed: 121 additions & 119 deletions
Large diffs are not rendered by default.

API/src/main/java/io/github/jwdeveloper/tiktok/http/TikTokHttpRequest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ public interface TikTokHttpRequest {
3131
String get(String url);
3232

3333
String post(String url);
34+
3435
}

API/src/main/java/io/github/jwdeveloper/tiktok/live/LiveRoomMeta.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@
2828
public class LiveRoomMeta {
2929

3030
private LiveRoomStatus status;
31-
3231
private boolean ageRestricted;
3332

34-
35-
3633
public enum LiveRoomStatus
3734
{
3835
HostNotFound,

API/src/main/java/io/github/jwdeveloper/tiktok/live/builder/EventsBuilder.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import io.github.jwdeveloper.tiktok.data.events.common.TikTokEvent;
2626
import io.github.jwdeveloper.tiktok.data.events.*;
27+
import io.github.jwdeveloper.tiktok.data.events.envelop.TikTokChestEvent;
2728
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftComboEvent;
2829
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftEvent;
2930
import io.github.jwdeveloper.tiktok.data.events.room.TikTokRoomEvent;
@@ -51,6 +52,9 @@ public interface EventsBuilder<T> {
5152

5253
T onWebsocketUnhandledMessage(EventConsumer<TikTokWebsocketUnhandledMessageEvent> event);
5354

55+
56+
57+
5458
T onGiftCombo(EventConsumer<TikTokGiftComboEvent> event);
5559
T onGift(EventConsumer<TikTokGiftEvent> event);
5660

@@ -69,6 +73,8 @@ public interface EventsBuilder<T> {
6973
T onShare(EventConsumer<TikTokShareEvent> event);
7074
T onUnhandledSocial(EventConsumer<TikTokUnhandledSocialEvent> event);
7175

76+
T onChestOpen(EventConsumer<TikTokChestEvent> event);
77+
7278
T onLivePaused(EventConsumer<TikTokLivePausedEvent> event);
7379

7480
T onLiveEnded(EventConsumer<TikTokLiveEndedEvent> event);
@@ -80,10 +86,11 @@ public interface EventsBuilder<T> {
8086
T onDisconnected(EventConsumer<TikTokDisconnectedEvent> event);
8187

8288
T onError(EventConsumer<TikTokErrorEvent> event);
83-
8489
T onEvent(EventConsumer<TikTokEvent> event);
8590

8691

92+
93+
8794
// TODO Figure out how those events works
8895
//T onLinkMicFanTicket(TikTokEventConsumer<TikTokLinkMicFanTicketEvent> event);
8996

API/src/main/proto/enums.proto

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,29 @@ enum BarrageType
110110
FansLevelUpgrade = 10;
111111
FansLevelEntrance = 11;
112112
GamePartnership = 12;
113+
}
114+
115+
enum EnvelopeBusinessType
116+
{
117+
BusinessTypeUnknown = 0;
118+
BusinessTypeUserDiamond = 1;
119+
BusinessTypePlatformDiamond = 2;
120+
BusinessTypePlatformShell = 3;
121+
BusinessTypePortal = 4;
122+
BusinessTypePlatformMerch = 5;
123+
BusinessTypeEoYDiamond = 6;
124+
BusinessTypeFanClubGtM = 7;
125+
}
126+
enum EnvelopeFollowShowStatus
127+
{
128+
EnvelopeFollowShowUnknown = 0;
129+
EnvelopeFollowShow = 1;
130+
EnvelopeFollowNotShow = 2;
131+
}
132+
133+
enum EnvelopeDisplay
134+
{
135+
EnvelopeDisplayUnknown = 0;
136+
EnvelopeDisplayNew = 1;
137+
EnvelopeDisplayHide = 2;
113138
}

0 commit comments

Comments
 (0)