mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-28 09:19:40 -05:00
Breaking changes:
'Gift': changed from class to enum, so now you can handle
incoming gifts in switch
`Events`
- new:
onGiftComboFinished
- Removed:
onGiftBrodcast
- Rename:
onGiftMessage -> onGift
onRoomPinMessage -> onRoomPin
onRoomMessage -> onRoom
onLinkMessage -> onLink
onBarrageMessage -> onBarrage
onPollMessage -> onPoll
onShopMessage -> onShop
onDetectMessage -> onDetect
`GiftManager`
added:
registerGift
findById
findByName
getGifts
removed:
getActiveGifts
This commit is contained in:
@@ -69,13 +69,13 @@ 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;
|
private String hostName;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameters used in requests to Tiktok api
|
* Parameters used in requests to TikTok api
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> clientParameters;
|
private Map<String, Object> clientParameters;
|
||||||
|
|
||||||
|
|||||||
@@ -48,16 +48,11 @@ public class Constants {
|
|||||||
* Default TimeOut for Connections
|
* Default TimeOut for Connections
|
||||||
*/
|
*/
|
||||||
public static final int DEFAULT_TIMEOUT = 20;
|
public static final int DEFAULT_TIMEOUT = 20;
|
||||||
/**
|
|
||||||
* Default Polling-Time for Socket-Connection
|
|
||||||
*/
|
|
||||||
public static final int DEFAULT_POLLTIME = 1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default Settings for Client
|
* Default Settings for Client
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public static ClientSettings DefaultClientSettings() {
|
public static ClientSettings DefaultClientSettings() {
|
||||||
var clientSettings = new ClientSettings();
|
var clientSettings = new ClientSettings();
|
||||||
clientSettings.setTimeout(Duration.ofSeconds(DEFAULT_TIMEOUT));
|
clientSettings.setTimeout(Duration.ofSeconds(DEFAULT_TIMEOUT));
|
||||||
@@ -75,8 +70,6 @@ public class Constants {
|
|||||||
/**
|
/**
|
||||||
* Default Parameters for HTTP-Request
|
* Default Parameters for HTTP-Request
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
public static Map<String, Object> DefaultClientParams() {
|
public static Map<String, Object> DefaultClientParams() {
|
||||||
var clientParams = new TreeMap<String, Object>();
|
var clientParams = new TreeMap<String, Object>();
|
||||||
clientParams.put("aid", 1988);
|
clientParams.put("aid", 1988);
|
||||||
|
|||||||
@@ -23,6 +23,14 @@
|
|||||||
package io.github.jwdeveloper.tiktok.events;
|
package io.github.jwdeveloper.tiktok.events;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.events.messages.*;
|
import io.github.jwdeveloper.tiktok.events.messages.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokConnectedEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokDisconnectedEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokGiftComboFinishedEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokGiftEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokJoinEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokLikeEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokBarrageEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.poll.TikTokPollEvent;
|
||||||
|
|
||||||
|
|
||||||
public interface TikTokEventBuilder<T> {
|
public interface TikTokEventBuilder<T> {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
package io.github.jwdeveloper.tiktok.events.base;
|
package io.github.jwdeveloper.tiktok.events.base;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.*;
|
import io.github.jwdeveloper.tiktok.messages.data.Common;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -36,26 +36,6 @@ public class TikTokHeaderEvent extends TikTokEvent {
|
|||||||
this(header.getMsgId(), header.getRoomId(), header.getCreateTime());
|
this(header.getMsgId(), header.getRoomId(), header.getCreateTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
public TikTokHeaderEvent(MessageHeader header) {
|
|
||||||
this(header.getMessageId(), header.getRoomId(), header.getTimeStamp1());
|
|
||||||
}
|
|
||||||
|
|
||||||
public TikTokHeaderEvent(GiftMessageHeader header) {
|
|
||||||
this(header.getMessageId(), header.getRoomId(), header.getTimeStamp1());
|
|
||||||
}
|
|
||||||
|
|
||||||
public TikTokHeaderEvent(MemberMessageHeader header) {
|
|
||||||
this(header.getMessageId(), header.getRoomId(), header.getTimeStamp1());
|
|
||||||
}
|
|
||||||
|
|
||||||
public TikTokHeaderEvent(SocialMessageHeader header) {
|
|
||||||
this(header.getMessageId(), header.getRoomId(), header.getTimeStamp1());
|
|
||||||
}
|
|
||||||
|
|
||||||
public TikTokHeaderEvent(LikeMessageHeader header) {
|
|
||||||
this(header.getMessageId(), header.getRoomId(), header.getTimeStamp1());
|
|
||||||
}
|
|
||||||
|
|
||||||
public TikTokHeaderEvent(long messageId, long roomId, long timeStamp) {
|
public TikTokHeaderEvent(long messageId, long roomId, long timeStamp) {
|
||||||
this.messageId = messageId;
|
this.messageId = messageId;
|
||||||
this.roomId = roomId;
|
this.roomId = roomId;
|
||||||
|
|||||||
@@ -25,33 +25,40 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.BarrageData;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.barrage.BarrageParam;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastBarrageMessage;
|
import io.github.jwdeveloper.tiktok.events.objects.barrage.FansLevelParam;
|
||||||
import lombok.Value;
|
import io.github.jwdeveloper.tiktok.events.objects.barrage.SubscribeGiftParam;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.objects.barrage.UserGradeParam;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastBarrageMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
@Value
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokBarrageEvent extends TikTokHeaderEvent {
|
public class TikTokBarrageEvent extends TikTokHeaderEvent {
|
||||||
Picture picture;
|
private final Picture icon;
|
||||||
Picture picture2;
|
private final Picture backGround;
|
||||||
Picture picture3;
|
private final Picture rightIcon;
|
||||||
User user;
|
private final String eventName;
|
||||||
BarrageData barrageData;
|
private final int duration;
|
||||||
|
private BarrageParam barrageParam;
|
||||||
|
|
||||||
public TikTokBarrageEvent(WebcastBarrageMessage msg) {
|
public TikTokBarrageEvent(WebcastBarrageMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
picture = Picture.Map(msg.getImage());
|
icon = Picture.Map(msg.getIcon());
|
||||||
picture2 = Picture.Map(msg.getImage2());
|
eventName = msg.getEvent().getEventName();
|
||||||
picture3 = Picture.Map(msg.getImage3());
|
backGround = Picture.Map(msg.getBackground());
|
||||||
user = new User(msg.getUserData().getUser());
|
rightIcon = Picture.Map(msg.getRightIcon());
|
||||||
barrageData = new BarrageData(msg.getMessage().getEventType(),
|
duration = msg.getDuration();
|
||||||
msg.getMessage().getLabel(),
|
switch (msg.getMsgType()) {
|
||||||
msg.getMessage().getData1List().stream().map(e ->
|
case GRADEUSERENTRANCENOTIFICATION:
|
||||||
{
|
barrageParam = new UserGradeParam(msg.getUserGradeParam());
|
||||||
var user = new User(e.getUser().getUser());
|
case FANSLEVELUPGRADE:
|
||||||
return new BarrageData.BarrageUser(user, e.getData2());
|
barrageParam = new FansLevelParam(msg.getFansLevelParam());
|
||||||
}).toList()
|
case SUBSCRIBEGIFT:
|
||||||
);
|
barrageParam = new SubscribeGiftParam(msg.getSubscribeGiftParam());
|
||||||
|
default:
|
||||||
|
barrageParam = new BarrageParam();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastCaptionMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastCaptionMessage;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
@Value
|
@Value
|
||||||
|
|||||||
@@ -27,40 +27,29 @@ import io.github.jwdeveloper.tiktok.annotations.EventType;
|
|||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastChatMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastChatMessage;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastRoomPinMessage;
|
import lombok.Getter;
|
||||||
import lombok.Value;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggered every time a new chat comment arrives.
|
* Triggered every time a new chat comment arrives.
|
||||||
*/
|
*/
|
||||||
@Value
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokCommentEvent extends TikTokHeaderEvent {
|
public class TikTokCommentEvent extends TikTokHeaderEvent {
|
||||||
User user;
|
private final User user;
|
||||||
String text;
|
private final String text;
|
||||||
String language;
|
private final String language;
|
||||||
List<User> mentionedUsers;
|
private final List<User> mentionedUsers;
|
||||||
List<Picture> pictures;
|
private final List<Picture> pictures;
|
||||||
|
|
||||||
public TikTokCommentEvent(WebcastRoomPinMessage.RoomPinMessageData data) {
|
|
||||||
super(data.getDetails().getRoomId(), data.getDetails().getMessageId(), data.getDetails().getServerTime());
|
|
||||||
user = User.MapOrEmpty(data.getSender());
|
|
||||||
text = data.getComment();
|
|
||||||
language = data.getLanguage();
|
|
||||||
mentionedUsers = new ArrayList<>();
|
|
||||||
pictures = new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TikTokCommentEvent(WebcastChatMessage msg) {
|
public TikTokCommentEvent(WebcastChatMessage msg) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
user = User.MapOrEmpty(msg.getUser());
|
user = User.mapOrEmpty(msg.getUser());
|
||||||
text = msg.getContent();
|
text = msg.getContent();
|
||||||
language = msg.getContentLanguage();
|
language = msg.getContentLanguage();
|
||||||
mentionedUsers = List.of(User.MapOrEmpty(msg.getAtUser()));
|
mentionedUsers = List.of(User.mapOrEmpty(msg.getAtUser()));
|
||||||
pictures = msg.getEmotesListList().stream().map(e ->Picture.Map(e.getEmote().getImage())).toList();
|
pictures = msg.getEmotesListList().stream().map(e -> Picture.Map(e.getEmote().getImage())).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,24 +25,19 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastMsgDetectMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastMsgDetectMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokDetectEvent extends TikTokHeaderEvent {
|
public class TikTokDetectEvent extends TikTokHeaderEvent {
|
||||||
String language;
|
String language;
|
||||||
|
|
||||||
List<Number> data;
|
|
||||||
|
|
||||||
List<Number> timings;
|
|
||||||
|
|
||||||
public TikTokDetectEvent(WebcastMsgDetectMessage msg) {
|
public TikTokDetectEvent(WebcastMsgDetectMessage msg) {
|
||||||
super(msg.getHeader());;
|
super(msg.getCommon());
|
||||||
language = msg.getLanguage();
|
language = msg.getFromRegion();
|
||||||
data = List.of(msg.getData2().getData1(), msg.getData2().getData2(), msg.getData2().getData3());
|
|
||||||
timings= List.of(msg.getTimestamps().getTimestamp1(), msg.getTimestamps().getTimestamp2(), msg.getTimestamps().getTimestamp3());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,13 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
import io.github.jwdeveloper.tiktok.events.objects.Emote;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastEmoteChatMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastEmoteChatMessage;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggered every time a subscriber sends an emote (sticker).
|
* Triggered every time a subscriber sends an emote (sticker).
|
||||||
*/
|
*/
|
||||||
@@ -37,13 +39,11 @@ import lombok.Value;
|
|||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokEmoteEvent extends TikTokHeaderEvent {
|
public class TikTokEmoteEvent extends TikTokHeaderEvent {
|
||||||
User user;
|
User user;
|
||||||
String emoteId;
|
List<Emote> emotes;
|
||||||
Picture picture;
|
|
||||||
|
|
||||||
public TikTokEmoteEvent(WebcastEmoteChatMessage msg) {
|
public TikTokEmoteEvent(WebcastEmoteChatMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
user = User.MapOrEmpty(msg.getSender());
|
user = User.mapOrEmpty(msg.getUser());
|
||||||
emoteId = msg.getDetails().getId();
|
emotes = msg.getEmoteListList().stream().map(Emote::map).toList();
|
||||||
picture = new Picture(msg.getDetails().getImage().getUrl());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,11 +24,9 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastEnvelopeMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastEnvelopeMessage;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
|
|
||||||
@@ -40,7 +38,7 @@ import lombok.Value;
|
|||||||
public class TikTokEnvelopeEvent extends TikTokHeaderEvent {
|
public class TikTokEnvelopeEvent extends TikTokHeaderEvent {
|
||||||
User user;
|
User user;
|
||||||
public TikTokEnvelopeEvent(WebcastEnvelopeMessage msg) {
|
public TikTokEnvelopeEvent(WebcastEnvelopeMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
user = new User(msg.getUser().getId(), msg.getUser().getUsername());
|
user = User.map(msg.getEnvelopeInfo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastSocialMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastSocialMessage;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,12 +36,12 @@ import lombok.Value;
|
|||||||
@EventMeta(eventType = EventType.Custom)
|
@EventMeta(eventType = EventType.Custom)
|
||||||
public class TikTokFollowEvent extends TikTokHeaderEvent
|
public class TikTokFollowEvent extends TikTokHeaderEvent
|
||||||
{
|
{
|
||||||
User newFollower;
|
User user;
|
||||||
Long totalFollowers;
|
Long totalFollowers;
|
||||||
|
|
||||||
public TikTokFollowEvent(WebcastSocialMessage msg) {
|
public TikTokFollowEvent(WebcastSocialMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
newFollower = User.MapOrEmpty(msg.getSender());
|
user = User.mapOrEmpty(msg.getUser());
|
||||||
totalFollowers = msg.getTotalFollowers();
|
totalFollowers = msg.getFollowCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.Gift;
|
import io.github.jwdeveloper.tiktok.events.objects.Gift;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastGiftMessage;
|
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@EventMeta(eventType = EventType.Custom)
|
@EventMeta(eventType = EventType.Custom)
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import io.github.jwdeveloper.tiktok.annotations.EventType;
|
|||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.Gift;
|
import io.github.jwdeveloper.tiktok.events.objects.Gift;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastGiftMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGiftMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
|
||||||
@@ -43,14 +43,14 @@ public class TikTokGiftEvent extends TikTokHeaderEvent {
|
|||||||
private final String purchaseId;
|
private final String purchaseId;
|
||||||
private final String receipt;
|
private final String receipt;
|
||||||
private final Long comboCount;
|
private final Long comboCount;
|
||||||
private final Boolean comboFinished;
|
private final boolean comboFinished;
|
||||||
private final Long comboIndex;
|
private final Long comboIndex;
|
||||||
|
|
||||||
public TikTokGiftEvent(Gift gift, WebcastGiftMessage msg) {
|
public TikTokGiftEvent(Gift gift, WebcastGiftMessage msg) {
|
||||||
super(msg.getCommon());
|
super(msg.getCommon());
|
||||||
this.gift = gift;
|
this.gift = gift;
|
||||||
sender = User.MapOrEmpty(msg.getUser());
|
sender = User.mapOrEmpty(msg.getUser());
|
||||||
purchaseId = msg.getLogId();
|
purchaseId = msg.getOrderId();
|
||||||
receipt = msg.getMonitorExtra();
|
receipt = msg.getMonitorExtra();
|
||||||
comboCount = msg.getComboCount();
|
comboCount = msg.getComboCount();
|
||||||
comboFinished = msg.getRepeatEnd() > 0;
|
comboFinished = msg.getRepeatEnd() > 0;
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ import io.github.jwdeveloper.tiktok.annotations.EventType;
|
|||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastGoalUpdateMessage;
|
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastGoalUpdateMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -37,16 +38,18 @@ import java.util.List;
|
|||||||
public class TikTokGoalUpdateEvent extends TikTokHeaderEvent {
|
public class TikTokGoalUpdateEvent extends TikTokHeaderEvent {
|
||||||
private final Long goalId;
|
private final Long goalId;
|
||||||
private final Picture picture;
|
private final Picture picture;
|
||||||
private final String eventType;
|
private final String description;
|
||||||
private final String label;
|
|
||||||
private final List<User> users;
|
private final List<User> users;
|
||||||
|
|
||||||
public TikTokGoalUpdateEvent(WebcastGoalUpdateMessage msg) {
|
public TikTokGoalUpdateEvent(WebcastGoalUpdateMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
picture = Picture.Map(msg.getImage());
|
picture = Picture.Map(msg.getContributorAvatar());
|
||||||
goalId = msg.getId();
|
goalId = msg.getGoal().getId();
|
||||||
eventType = msg.getData().getType();
|
description = msg.getGoal().getDescription();
|
||||||
label = msg.getUpdateData().getLabel();
|
users = msg.getGoal()
|
||||||
users = msg.getUpdateData().getUsersList().stream().map(u -> new User(u.getId(), u.getNickname(), Picture.Map(u.getProfileImage()))).toList();
|
.getContributorsListList()
|
||||||
|
.stream()
|
||||||
|
.map(u -> new User(u.getUserId(), u.getDisplayId(), Picture.Map(u.getAvatar())))
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,18 +24,15 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastImDeleteMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastImDeleteMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokIMDeleteEvent extends TikTokHeaderEvent {
|
public class TikTokIMDeleteEvent extends TikTokHeaderEvent {
|
||||||
private final byte[] data;
|
|
||||||
|
|
||||||
public TikTokIMDeleteEvent(WebcastImDeleteMessage msg) {
|
public TikTokIMDeleteEvent(WebcastImDeleteMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getHeader());
|
||||||
data = msg.getData().toByteArray();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,18 +24,17 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastInRoomBannerMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastInRoomBannerMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokInRoomBannerEvent extends TikTokHeaderEvent {
|
public class TikTokInRoomBannerEvent extends TikTokHeaderEvent {
|
||||||
private final String jSON;
|
private final String json;
|
||||||
|
|
||||||
public TikTokInRoomBannerEvent(WebcastInRoomBannerMessage msg) {
|
public TikTokInRoomBannerEvent(WebcastInRoomBannerMessage msg) {
|
||||||
super(msg.getHeader());;
|
super(msg.getHeader());
|
||||||
jSON = msg.getJson();
|
json = msg.getJson();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,31 +26,25 @@ import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastMemberMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastMemberMessage;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastSocialMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastSocialMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Custom)
|
@EventMeta(eventType = EventType.Custom)
|
||||||
public class TikTokJoinEvent extends TikTokHeaderEvent {
|
public class TikTokJoinEvent extends TikTokHeaderEvent {
|
||||||
private User user;
|
private final User user;
|
||||||
private final Long totalViewers;
|
private final int viewersCount;
|
||||||
|
|
||||||
public TikTokJoinEvent(WebcastSocialMessage msg) {
|
public TikTokJoinEvent(WebcastSocialMessage msg, int viewersCount) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
|
user = User.mapOrEmpty(msg.getUser());
|
||||||
if (msg.hasSender()) {
|
this.viewersCount = viewersCount;
|
||||||
user = new User(msg.getSender());
|
|
||||||
}
|
|
||||||
|
|
||||||
totalViewers = 0L;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TikTokJoinEvent(WebcastMemberMessage msg) {
|
public TikTokJoinEvent(WebcastMemberMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
if (msg.hasUser()) {
|
user = User.mapOrEmpty(msg.getUser());
|
||||||
user = new User(msg.getUser());
|
viewersCount = msg.getMemberCount();
|
||||||
}
|
|
||||||
totalViewers = msg.getTotalViewers();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastLikeMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLikeMessage;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastSocialMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastSocialMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
|
||||||
@@ -38,29 +38,23 @@ import lombok.Getter;
|
|||||||
@EventMeta(eventType = EventType.Custom)
|
@EventMeta(eventType = EventType.Custom)
|
||||||
public class TikTokLikeEvent extends TikTokHeaderEvent
|
public class TikTokLikeEvent extends TikTokHeaderEvent
|
||||||
{
|
{
|
||||||
private User sender;
|
private final User user;
|
||||||
|
|
||||||
private final Integer count;
|
private final Integer count;
|
||||||
|
|
||||||
private final Long totalLikes;
|
private final Integer totalLikes;
|
||||||
|
|
||||||
public TikTokLikeEvent(WebcastSocialMessage msg) {
|
public TikTokLikeEvent(WebcastSocialMessage msg, int totalLikes) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
if (msg.hasSender()) {
|
user = User.mapOrEmpty(msg.getUser());
|
||||||
sender = new User(msg.getSender());
|
|
||||||
}
|
|
||||||
count = 1;
|
count = 1;
|
||||||
totalLikes = 0L;
|
this.totalLikes = totalLikes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TikTokLikeEvent(WebcastLikeMessage msg) {
|
public TikTokLikeEvent(WebcastLikeMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
|
user = User.mapOrEmpty(msg.getUser());
|
||||||
if (msg.hasSender()) {
|
|
||||||
sender = new User(msg.getSender());
|
|
||||||
}
|
|
||||||
|
|
||||||
count = msg.getCount();
|
count = msg.getCount();
|
||||||
totalLikes = msg.getTotalLikes();
|
totalLikes = msg.getTotal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastLinkMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -41,7 +41,7 @@ public class TikTokLinkEvent extends TikTokHeaderEvent {
|
|||||||
private final List<User> otherUsers;
|
private final List<User> otherUsers;
|
||||||
|
|
||||||
public TikTokLinkEvent(WebcastLinkMessage msg) {
|
public TikTokLinkEvent(WebcastLinkMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
token = msg.getToken();
|
token = msg.getToken();
|
||||||
if (msg.getUser().getUser().hasUser()) {
|
if (msg.getUser().getUser().hasUser()) {
|
||||||
user = new User(msg.getUser().getUser().getUser());
|
user = new User(msg.getUser().getUser().getUser());
|
||||||
|
|||||||
@@ -25,28 +25,20 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastLinkLayerMessage;
|
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkLayerMessage;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokLinkLayerEvent extends TikTokHeaderEvent {
|
public class TikTokLinkLayerEvent extends TikTokHeaderEvent {
|
||||||
private final Long linkId;
|
|
||||||
private final LinkData link1;
|
|
||||||
private final LinkData link2;
|
|
||||||
|
|
||||||
public TikTokLinkLayerEvent(WebcastLinkLayerMessage msg) {
|
public TikTokLinkLayerEvent(WebcastLinkLayerMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
linkId = msg.getId();
|
|
||||||
link1 = new LinkData(msg.getIdContainer1().getIds().getId1(), msg.getIdContainer1().getIds().getId2());
|
|
||||||
link2 = new LinkData(msg.getIdContainer2().getIds().getId1(), msg.getIdContainer2().getIds().getId2());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
private class LinkData {
|
|
||||||
private final Long id1;
|
|
||||||
private final Long id2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,11 +24,10 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.LinkMicArmy;
|
import io.github.jwdeveloper.tiktok.events.objects.LinkMicArmy;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastLinkMicArmies;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMicArmies;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -49,7 +48,7 @@ public class TikTokLinkMicArmiesEvent extends TikTokHeaderEvent {
|
|||||||
private final List<LinkMicArmy> armies;
|
private final List<LinkMicArmy> armies;
|
||||||
|
|
||||||
public TikTokLinkMicArmiesEvent(WebcastLinkMicArmies msg) {
|
public TikTokLinkMicArmiesEvent(WebcastLinkMicArmies msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
battleId = msg.getId();
|
battleId = msg.getId();
|
||||||
armies = msg.getBattleItemsList().stream().map(LinkMicArmy::new).toList();
|
armies = msg.getBattleItemsList().stream().map(LinkMicArmy::new).toList();
|
||||||
picture = Picture.Map(msg.getImage());
|
picture = Picture.Map(msg.getImage());
|
||||||
|
|||||||
@@ -24,10 +24,9 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.LinkMicBattleTeam;
|
import io.github.jwdeveloper.tiktok.events.objects.LinkMicBattleTeam;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastLinkMicBattle;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMicBattle;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -43,7 +42,7 @@ public class TikTokLinkMicBattleEvent extends TikTokHeaderEvent {
|
|||||||
private final List<LinkMicBattleTeam> team2;
|
private final List<LinkMicBattleTeam> team2;
|
||||||
|
|
||||||
public TikTokLinkMicBattleEvent(WebcastLinkMicBattle msg) {
|
public TikTokLinkMicBattleEvent(WebcastLinkMicBattle msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
battleId = msg.getId();
|
battleId = msg.getId();
|
||||||
team1 = msg.getTeams1List().stream().map(LinkMicBattleTeam::new).toList();
|
team1 = msg.getTeams1List().stream().map(LinkMicBattleTeam::new).toList();
|
||||||
team2 = msg.getTeams2List().stream().map(LinkMicBattleTeam::new).toList();
|
team2 = msg.getTeams2List().stream().map(LinkMicBattleTeam::new).toList();
|
||||||
|
|||||||
@@ -24,22 +24,16 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastLinkMicFanTicketMethod;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMicFanTicketMethod;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokLinkMicFanTicketEvent extends TikTokHeaderEvent {
|
public class TikTokLinkMicFanTicketEvent extends TikTokHeaderEvent {
|
||||||
private final Long id;
|
|
||||||
private final Integer data1;
|
|
||||||
private final Integer data2;
|
|
||||||
|
|
||||||
public TikTokLinkMicFanTicketEvent(WebcastLinkMicFanTicketMethod msg) {
|
public TikTokLinkMicFanTicketEvent(WebcastLinkMicFanTicketMethod msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
id = msg.getData().getDetails().getId();
|
|
||||||
data1 = msg.getData().getData1();
|
|
||||||
data2 = msg.getData().getDetails().getData();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,24 +24,18 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.LinkMicMethod;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMicMethod;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastLinkMicMethod;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokLinkMicMethodEvent extends TikTokHeaderEvent {
|
public class TikTokLinkMicMethodEvent extends TikTokHeaderEvent {
|
||||||
private final String jSON;
|
|
||||||
|
|
||||||
public TikTokLinkMicMethodEvent(WebcastLinkMicMethod msg) {
|
public TikTokLinkMicMethodEvent(WebcastLinkMicMethod msg) {
|
||||||
super(msg.getHeader());;
|
super(msg.getCommon());
|
||||||
jSON = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TikTokLinkMicMethodEvent(LinkMicMethod msg) {
|
|
||||||
super(msg.getHeader());;
|
|
||||||
jSON = msg.getJson();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastQuestionNewMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastQuestionNewMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -45,7 +45,7 @@ public class TikTokQuestionEvent extends TikTokHeaderEvent {
|
|||||||
|
|
||||||
|
|
||||||
public TikTokQuestionEvent(WebcastQuestionNewMessage msg) {
|
public TikTokQuestionEvent(WebcastQuestionNewMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
var data = msg.getDetails();
|
var data = msg.getDetails();
|
||||||
questionId = data.getId();
|
questionId = data.getId();
|
||||||
text = data.getText();
|
text = data.getText();
|
||||||
|
|||||||
@@ -24,9 +24,9 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastRankTextMessage;
|
import io.github.jwdeveloper.tiktok.events.objects.Text;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastRankTextMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -36,11 +36,11 @@ public class TikTokRankTextEvent extends TikTokHeaderEvent {
|
|||||||
|
|
||||||
private final String label;
|
private final String label;
|
||||||
|
|
||||||
|
|
||||||
public TikTokRankTextEvent(WebcastRankTextMessage msg) {
|
public TikTokRankTextEvent(WebcastRankTextMessage msg) {
|
||||||
super(0,0,0);//TODO passing info
|
super(msg.getCommon());
|
||||||
eventType = msg.getDetails().getType();
|
var text = Text.map(msg.getSelfGetBadgeMsg());
|
||||||
label =msg.getDetails().getLabel();
|
label = text.getPattern();
|
||||||
|
eventType = text.getKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,53 +24,22 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastHourlyRankMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastHourlyRankMessage;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastRankUpdateMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastRankUpdateMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokRankUpdateEvent extends TikTokHeaderEvent {
|
public class TikTokRankUpdateEvent extends TikTokHeaderEvent {
|
||||||
private final String eventType;
|
|
||||||
|
|
||||||
private final String label;
|
|
||||||
|
|
||||||
private final String rank;
|
|
||||||
|
|
||||||
private final String color;
|
|
||||||
|
|
||||||
public TikTokRankUpdateEvent(WebcastHourlyRankMessage msg) {
|
public TikTokRankUpdateEvent(WebcastHourlyRankMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
var rankData = msg.getData().getRankings();
|
|
||||||
eventType = rankData.getType();
|
|
||||||
label = rankData.getLabel();
|
|
||||||
if(rankData.getDetailsList().isEmpty())
|
|
||||||
{
|
|
||||||
rank = "";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rank = rankData.getDetails(0).getLabel();
|
|
||||||
}
|
|
||||||
color = rankData.getColor().getColor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public TikTokRankUpdateEvent(WebcastRankUpdateMessage msg) {
|
public TikTokRankUpdateEvent(WebcastRankUpdateMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
var rankData = msg.getData().getRankData();
|
|
||||||
eventType = rankData.getType();
|
|
||||||
label = rankData.getLabel();
|
|
||||||
if(rankData.getDetailsList().isEmpty())
|
|
||||||
{
|
|
||||||
rank = "";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rank = rankData.getDetails(0).getLabel();
|
|
||||||
}
|
|
||||||
color = rankData.getColor().getColor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,10 +26,9 @@ import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.RoomMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLiveIntroMessage;
|
||||||
import io.github.jwdeveloper.tiktok.messages.SystemMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastRoomMessage;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastLiveIntroMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastSystemMessage;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastRoomMessage;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -40,26 +39,19 @@ public class TikTokRoomEvent extends TikTokHeaderEvent {
|
|||||||
private final String message;
|
private final String message;
|
||||||
|
|
||||||
public TikTokRoomEvent(WebcastRoomMessage msg) {
|
public TikTokRoomEvent(WebcastRoomMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
message = msg.getData();
|
message = msg.getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TikTokRoomEvent(SystemMessage msg) {
|
public TikTokRoomEvent(WebcastSystemMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
message = msg.getMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TikTokRoomEvent(RoomMessage msg) {
|
|
||||||
super(msg.getHeader());
|
|
||||||
message = msg.getMessage();
|
message = msg.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TikTokRoomEvent(WebcastLiveIntroMessage msg) {
|
public TikTokRoomEvent(WebcastLiveIntroMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
if (msg.hasHost()) {
|
host = User.mapOrEmpty(msg.getHost());
|
||||||
host = new User(msg.getHost());
|
message = msg.getContent();
|
||||||
}
|
|
||||||
message = msg.getDescription();
|
|
||||||
hostLanguage = msg.getLanguage();
|
hostLanguage = msg.getLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,19 +25,22 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastRoomPinMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastRoomPinMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokRoomPinEvent extends TikTokHeaderEvent {
|
public class TikTokRoomPinEvent extends TikTokHeaderEvent
|
||||||
private final Long pinTimeStamp;
|
{
|
||||||
private final TikTokCommentEvent comment;
|
|
||||||
|
|
||||||
public TikTokRoomPinEvent(WebcastRoomPinMessage msg) {
|
private TikTokCommentEvent pinnedMessage;
|
||||||
super(msg.getHeader());
|
private long timestamp;
|
||||||
this.pinTimeStamp = msg.getTimestamp();
|
|
||||||
this.comment = new TikTokCommentEvent(msg.getPinData1());
|
public TikTokRoomPinEvent(WebcastRoomPinMessage msg, TikTokCommentEvent commentEvent)
|
||||||
|
{
|
||||||
|
super(msg.getCommon());
|
||||||
|
this.timestamp = msg.getTimestamp();
|
||||||
|
this.pinnedMessage = commentEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,9 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.TopViewer;
|
import io.github.jwdeveloper.tiktok.events.objects.TopViewer;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastRoomUserSeqMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastRoomUserSeqMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -35,15 +34,14 @@ import java.util.List;
|
|||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokRoomViewerDataEvent extends TikTokHeaderEvent {
|
public class TikTokRoomViewerDataEvent extends TikTokHeaderEvent {
|
||||||
private final Integer viewerCount;
|
private final Integer viewerCount;
|
||||||
private final List<TopViewer> topViewers;
|
private final List<TopViewer> topViewers;
|
||||||
|
|
||||||
public TikTokRoomViewerDataEvent(WebcastRoomUserSeqMessage msg) {
|
public TikTokRoomViewerDataEvent(WebcastRoomUserSeqMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
|
//TODO sorting by rank TopViewers = msg?.TopViewers?.Select(t => new Objects.TopViewer(t))?.OrderBy(t => t.Rank)?
|
||||||
//TODO sorting by rank TopViewers = msg?.TopViewers?.Select(t => new Objects.TopViewer(t))?.OrderBy(t => t.Rank)?
|
viewerCount = (int) msg.getTotalUser();
|
||||||
viewerCount = msg.getViewerCount();
|
topViewers = msg.getRanksListList().stream().map(TopViewer::new).toList();
|
||||||
topViewers = msg.getTopViewersList().stream().map(TopViewer::new).toList();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,9 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastSocialMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastSocialMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,14 +39,14 @@ public class TikTokShareEvent extends TikTokHeaderEvent {
|
|||||||
private final Integer amount;
|
private final Integer amount;
|
||||||
|
|
||||||
public TikTokShareEvent(WebcastSocialMessage msg, Integer amount) {
|
public TikTokShareEvent(WebcastSocialMessage msg, Integer amount) {
|
||||||
super(msg.getHeader());;
|
super(msg.getCommon());
|
||||||
user = User.MapOrEmpty(msg.getSender());
|
user = User.mapOrEmpty(msg.getUser());
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TikTokShareEvent(WebcastSocialMessage msg) {
|
public TikTokShareEvent(WebcastSocialMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
user = User.MapOrEmpty(msg.getSender());
|
user = User.mapOrEmpty(msg.getUser());
|
||||||
amount = 1;
|
amount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastOecLiveShoppingMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastOecLiveShoppingMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -43,7 +43,7 @@ public class TikTokShopEvent extends TikTokHeaderEvent {
|
|||||||
private final String shopName;
|
private final String shopName;
|
||||||
|
|
||||||
public TikTokShopEvent(WebcastOecLiveShoppingMessage msg) {
|
public TikTokShopEvent(WebcastOecLiveShoppingMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
var data = msg.getShopData();
|
var data = msg.getShopData();
|
||||||
title = data.getTitle();
|
title = data.getTitle();
|
||||||
price = data.getPriceString();
|
price = data.getPriceString();
|
||||||
|
|||||||
@@ -24,24 +24,19 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastSubNotifyMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastSubNotifyMessage;
|
||||||
import lombok.Getter;
|
import lombok.Value;
|
||||||
|
|
||||||
@Getter
|
@Value
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokSubNotifyEvent extends TikTokHeaderEvent {
|
public class TikTokSubNotifyEvent extends TikTokHeaderEvent {
|
||||||
private User user;
|
User user;
|
||||||
|
|
||||||
public TikTokSubNotifyEvent(WebcastSubNotifyMessage msg) {
|
public TikTokSubNotifyEvent(WebcastSubNotifyMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
|
user = User.mapOrEmpty(msg.getUser());
|
||||||
if (msg.hasSender()) {
|
|
||||||
user = new User(msg.getSender());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,9 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastMemberMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastMemberMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -39,7 +38,7 @@ public class TikTokSubscribeEvent extends TikTokHeaderEvent {
|
|||||||
private User newSubscriber;
|
private User newSubscriber;
|
||||||
|
|
||||||
public TikTokSubscribeEvent(WebcastMemberMessage msg) {
|
public TikTokSubscribeEvent(WebcastMemberMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
|
|
||||||
if(msg.hasUser())
|
if(msg.hasUser())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,36 +24,18 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastUnauthorizedMemberMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastUnauthorizedMemberMessage;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokUnauthorizedMemberEvent extends TikTokHeaderEvent {
|
public class TikTokUnauthorizedMemberEvent extends TikTokHeaderEvent {
|
||||||
private final String data;
|
private final String userNickName;
|
||||||
|
|
||||||
private final UnauthorizedMemberData event;
|
|
||||||
|
|
||||||
private final UnauthorizedMemberData underlying;
|
|
||||||
|
|
||||||
public TikTokUnauthorizedMemberEvent(WebcastUnauthorizedMemberMessage msg) {
|
public TikTokUnauthorizedMemberEvent(WebcastUnauthorizedMemberMessage msg) {
|
||||||
super(msg.getHeader());
|
super(msg.getCommon());
|
||||||
|
|
||||||
data = msg.getData2();
|
userNickName = msg.getNickName();
|
||||||
event = new UnauthorizedMemberData(msg.getDetails1().getType(), msg.getDetails1().getLabel());
|
|
||||||
underlying = new UnauthorizedMemberData(msg.getDetails2().getType(), msg.getDetails2().getLabel());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class UnauthorizedMemberData {
|
|
||||||
private final String data1;
|
|
||||||
|
|
||||||
private final String data2;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,10 +24,8 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokUnhandledEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokUnhandledEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastControlMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastControlMessage;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@@ -24,10 +24,8 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokUnhandledEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokUnhandledEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastMemberMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastMemberMessage;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@@ -24,11 +24,8 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokUnhandledEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokUnhandledEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastMemberMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastSocialMessage;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastSocialMessage;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
|||||||
@@ -24,13 +24,14 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokUnhandledEvent;
|
import io.github.jwdeveloper.tiktok.events.base.TikTokUnhandledEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastResponse;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggered every time a protobuf encoded webcast message arrives. You can deserialize the binary object depending on the use case.
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Message)
|
||||||
public class TikTokUnhandledWebsocketMessageEvent extends TikTokUnhandledEvent<WebcastResponse.Message>
|
public class TikTokUnhandledWebsocketMessageEvent extends TikTokUnhandledEvent<WebcastResponse.Message>
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ package io.github.jwdeveloper.tiktok.events.messages;
|
|||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastResponse;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* 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.events.messages.poll;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.objects.PollOption;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastPollMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@EventMeta(eventType = EventType.Custom)
|
||||||
|
@Getter
|
||||||
|
public class TikTokPollEndEvent extends TikTokPollEvent
|
||||||
|
{
|
||||||
|
private final User operator;
|
||||||
|
private final List<PollOption> options;
|
||||||
|
public TikTokPollEndEvent(WebcastPollMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
var end = msg.getEndContent();
|
||||||
|
operator = User.mapOrEmpty(end.getOperator());
|
||||||
|
options = end.getOptionListList().stream().map(PollOption::map).toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,25 +20,22 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.events.objects;
|
package io.github.jwdeveloper.tiktok.events.messages.poll;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastGiftMessage;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastPollMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class TikTokGift {
|
@EventMeta(eventType = EventType.Message)
|
||||||
private final Gift gift;
|
public class TikTokPollEvent extends TikTokHeaderEvent {
|
||||||
private final User sender;
|
private final Long pollId;
|
||||||
@Setter
|
|
||||||
private long amount;
|
|
||||||
@Setter
|
|
||||||
private boolean streakFinished;
|
|
||||||
|
|
||||||
public TikTokGift(Gift gift, WebcastGiftMessage message) {
|
public TikTokPollEvent(WebcastPollMessage msg)
|
||||||
this.gift = gift;
|
{
|
||||||
sender = User.MapOrEmpty(message.getUser());
|
super(msg.getCommon());
|
||||||
amount = message.getComboCount();
|
pollId = msg.getPollId();
|
||||||
streakFinished = message.getRepeatEnd() > 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,34 +20,31 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.events.messages;
|
package io.github.jwdeveloper.tiktok.events.messages.poll;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
import io.github.jwdeveloper.tiktok.events.base.TikTokHeaderEvent;
|
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.PollOption;
|
import io.github.jwdeveloper.tiktok.events.objects.PollOption;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.User;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastPollMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastPollMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EventMeta(eventType = EventType.Message)
|
@EventMeta(eventType = EventType.Custom)
|
||||||
public class TikTokPollEvent extends TikTokHeaderEvent {
|
public class TikTokPollStartEvent extends TikTokPollEvent {
|
||||||
private final Long id;
|
|
||||||
|
|
||||||
private final PollOption option1;
|
private final List<PollOption> options;
|
||||||
|
private final String title;
|
||||||
|
private final User operator;
|
||||||
|
|
||||||
private final PollOption option2;
|
public TikTokPollStartEvent(WebcastPollMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
var startContent = msg.getStartContent();
|
||||||
|
|
||||||
private final List<PollOption.Option> options;
|
title = startContent.getTitle();
|
||||||
|
operator = User.mapOrEmpty(startContent.getOperator());
|
||||||
public TikTokPollEvent(WebcastPollMessage msg) {
|
options = startContent.getOptionListList().stream().map(PollOption::map).toList();
|
||||||
super(msg.getHeader());
|
|
||||||
id = msg.getId();
|
|
||||||
options = msg.getPollData().getOptionsList().stream().map(e -> new PollOption.Option(e.getLabel(), e.getCurrentTotal())).toList();
|
|
||||||
option1 = new PollOption(new User(msg.getOptions1().getUser()), msg.getOptions1().getOptionsList().stream().map(e -> new PollOption.Option(e.getLabel(), e.getCurrentTotal())).toList());
|
|
||||||
option2 = new PollOption(new User(msg.getOptions2().getUser()), msg.getOptions2().getOptionsList().stream().map(e -> new PollOption.Option(e.getLabel(), e.getCurrentTotal())).toList());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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.events.messages.poll;
|
||||||
|
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.EventMeta;
|
||||||
|
import io.github.jwdeveloper.tiktok.annotations.EventType;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.objects.PollOption;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastPollMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@EventMeta(eventType = EventType.Custom)
|
||||||
|
@Getter
|
||||||
|
public class TikTokPollUpdateEvent extends TikTokPollEvent {
|
||||||
|
private final List<PollOption> options;
|
||||||
|
public TikTokPollUpdateEvent(WebcastPollMessage msg) {
|
||||||
|
super(msg);
|
||||||
|
options = msg.getUpdateContent().getOptionListList().stream().map(PollOption::map).toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.events.objects;
|
package io.github.jwdeveloper.tiktok.events.objects;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.messages.BadgeStruct;
|
import io.github.jwdeveloper.tiktok.messages.data.BadgeStruct;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -40,7 +40,7 @@ public class Badge {
|
|||||||
this.imageBadges = imageBadges;
|
this.imageBadges = imageBadges;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Badge(io.github.jwdeveloper.tiktok.messages.BadgeStruct badge)
|
public Badge(io.github.jwdeveloper.tiktok.messages.data.BadgeStruct badge)
|
||||||
{
|
{
|
||||||
comboBadges = ComboBadge.map(badge.getCombine());
|
comboBadges = ComboBadge.map(badge.getCombine());
|
||||||
textBadges = TextBadge.mapAll(badge.getTextList());
|
textBadges = TextBadge.mapAll(badge.getTextList());
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ public class BarrageData {
|
|||||||
this.users = users;
|
this.users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Value
|
@Value
|
||||||
public static class BarrageUser
|
public static class BarrageUser
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,28 +20,20 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.models.gifts;
|
package io.github.jwdeveloper.tiktok.events.objects;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Value;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Value
|
||||||
|
public class Emote {
|
||||||
|
String emoteId;
|
||||||
|
Picture picture;
|
||||||
|
UUID uuid;
|
||||||
|
|
||||||
|
public static Emote map(io.github.jwdeveloper.tiktok.messages.data.Emote input) {
|
||||||
|
return new Emote(input.getEmoteId(), Picture.Map(input.getImage()), UUID.fromString(input.getUuid()));
|
||||||
|
}
|
||||||
|
|
||||||
@Data
|
|
||||||
public class LeftIcon {
|
|
||||||
private String avg_color;
|
|
||||||
private int height;
|
|
||||||
private int image_type;
|
|
||||||
private boolean is_animated;
|
|
||||||
private String open_web_url;
|
|
||||||
private String uri;
|
|
||||||
private List<String> url_list;
|
|
||||||
private int width;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.events.objects;
|
package io.github.jwdeveloper.tiktok.events.objects;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.messages.LinkMicArmiesItems;
|
import io.github.jwdeveloper.tiktok.messages.data.LinkMicArmiesItems;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -36,9 +36,7 @@ public class LinkMicArmy {
|
|||||||
armyId = army.getHostUserId();
|
armyId = army.getHostUserId();
|
||||||
armies = army.getBattleGroupsList()
|
armies = army.getBattleGroupsList()
|
||||||
.stream()
|
.stream()
|
||||||
.map(x -> new Army(x.getUsersList().stream().map(User::MapOrEmpty).toList(), x.getPoints()))
|
.map(x -> new Army(x.getUsersList().stream().map(User::mapOrEmpty).toList(), x.getPoints()))
|
||||||
|
|
||||||
|
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
package io.github.jwdeveloper.tiktok.events.objects;
|
package io.github.jwdeveloper.tiktok.events.objects;
|
||||||
|
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastLinkMicBattle;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastLinkMicBattle;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
|
|||||||
@@ -22,38 +22,92 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.events.objects;
|
package io.github.jwdeveloper.tiktok.events.objects;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class Picture {
|
public class Picture {
|
||||||
|
|
||||||
private final String link;
|
@Getter
|
||||||
private boolean downloaded;
|
private final String link;
|
||||||
private boolean downloading;
|
|
||||||
|
|
||||||
|
|
||||||
public Picture(String link)
|
private Image image;
|
||||||
{
|
|
||||||
this.link = link;
|
|
||||||
downloaded= false;
|
|
||||||
downloading =false;
|
|
||||||
}
|
|
||||||
public static Picture Map(io.github.jwdeveloper.tiktok.messages.Image profilePicture)
|
|
||||||
{
|
|
||||||
return new Picture(profilePicture.getUri());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Picture Empty()
|
public Picture(String link) {
|
||||||
{
|
this.link = link;
|
||||||
return new Picture("");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Picture> EmptyList()
|
public static Picture Map(io.github.jwdeveloper.tiktok.messages.data.Image profilePicture) {
|
||||||
{
|
|
||||||
return new ArrayList<Picture>();
|
var index = profilePicture.getUrlListCount() - 1;
|
||||||
}
|
if (index <= 0) {
|
||||||
|
return new Picture("");
|
||||||
|
}
|
||||||
|
var url = profilePicture.getUrlList(index);
|
||||||
|
return new Picture(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDownloaded() {
|
||||||
|
return image != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Image downloadImage() {
|
||||||
|
if (isDownloaded()) {
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
if (link.equalsIgnoreCase("")) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
image = download(link);
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Future<Image> downloadImageAsync() {
|
||||||
|
var executor = Executors.newSingleThreadExecutor();
|
||||||
|
var future = executor.submit(this::downloadImage);
|
||||||
|
executor.shutdown();
|
||||||
|
return future;
|
||||||
|
}
|
||||||
|
|
||||||
|
private BufferedImage download(String urlString) {
|
||||||
|
var baos = new ByteArrayOutputStream();
|
||||||
|
try (var is = new URL(urlString).openStream()) {
|
||||||
|
var byteChunk = new byte[4096];
|
||||||
|
int n;
|
||||||
|
|
||||||
|
while ((n = is.read(byteChunk)) > 0) {
|
||||||
|
baos.write(byteChunk, 0, n);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new TikTokLiveException("Unable map downloaded image", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
var bais = new ByteArrayInputStream(baos.toByteArray());
|
||||||
|
try {
|
||||||
|
return ImageIO.read(bais);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new TikTokLiveException("Unable map downloaded image bytes to Image", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Picture Empty() {
|
||||||
|
return new Picture("");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Picture> EmptyList() {
|
||||||
|
return new ArrayList<Picture>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.events.objects;
|
package io.github.jwdeveloper.tiktok.events.objects;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import io.github.jwdeveloper.tiktok.messages.data.PollOptionInfo;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Value;
|
import lombok.Value;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -31,13 +30,18 @@ import java.util.List;
|
|||||||
@Value
|
@Value
|
||||||
public class PollOption {
|
public class PollOption {
|
||||||
|
|
||||||
private final User user;
|
int optionId;
|
||||||
private final List<Option> options;
|
String content;
|
||||||
|
int votes;
|
||||||
|
List<User> users;
|
||||||
|
|
||||||
@Value
|
public static PollOption map(PollOptionInfo pollOptionInfo) {
|
||||||
public static final class Option {
|
|
||||||
private final String label;
|
|
||||||
|
|
||||||
private final Integer total;
|
var users = pollOptionInfo.getVoteUserListList().stream().map(User::mapOrEmpty).toList();
|
||||||
|
return new PollOption(
|
||||||
|
pollOptionInfo.getOptionIdx(),
|
||||||
|
pollOptionInfo.getDisplayContent(),
|
||||||
|
pollOptionInfo.getVotes(),
|
||||||
|
users);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* 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.events.objects;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class Text {
|
||||||
|
String key;
|
||||||
|
String pattern;
|
||||||
|
List<TextPiece> textPieces;
|
||||||
|
|
||||||
|
public Text(String key, String pattern, List<TextPiece> textPieces) {
|
||||||
|
this.key = key;
|
||||||
|
this.pattern = pattern;
|
||||||
|
this.textPieces = textPieces;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static TextPiece mapTextPiece(io.github.jwdeveloper.tiktok.messages.data.Text.TextPiece input)
|
||||||
|
{
|
||||||
|
return switch (input.getType())
|
||||||
|
{
|
||||||
|
case 0 -> {
|
||||||
|
var user = User.mapOrEmpty(input.getUserValue().getUser());
|
||||||
|
yield new UserTextPiece(input.getStringValue(), user);
|
||||||
|
}
|
||||||
|
case 1 -> new GiftTextPiece(input.getStringValue());
|
||||||
|
default -> throw new TikTokLiveException("Unknown text piece");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class TextPiece {
|
||||||
|
String value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class UserTextPiece extends TextPiece {
|
||||||
|
User user;
|
||||||
|
|
||||||
|
public UserTextPiece(String value, User user) {
|
||||||
|
super(value);
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class GiftTextPiece extends TextPiece {
|
||||||
|
Gift gift;
|
||||||
|
|
||||||
|
public GiftTextPiece(String value) {
|
||||||
|
super(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,10 +31,10 @@ public class TopViewer {
|
|||||||
|
|
||||||
Integer coinsGiven;
|
Integer coinsGiven;
|
||||||
|
|
||||||
public TopViewer(io.github.jwdeveloper.tiktok.messages.TopViewer viewer)
|
public TopViewer(io.github.jwdeveloper.tiktok.messages.webcast.WebcastRoomUserSeqMessage.Contributor viewer)
|
||||||
{
|
{
|
||||||
rank = viewer.getRank();
|
rank = (int)viewer.getRank();
|
||||||
user = User.MapOrEmpty(viewer.getUser());
|
user = User.mapOrEmpty(viewer.getUser());
|
||||||
coinsGiven = viewer.getCoinsGiven();
|
coinsGiven = (int)viewer.getScore();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,33 +22,21 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.events.objects;
|
package io.github.jwdeveloper.tiktok.events.objects;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastEnvelopeMessage;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class User {
|
public class User {
|
||||||
private Long userId;
|
private Long userId;
|
||||||
private String uniqueId;
|
private String uniqueId;
|
||||||
|
|
||||||
private final String nickName;
|
private final String nickName;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
private Picture picture;
|
||||||
private Picture profilePicture;
|
|
||||||
|
|
||||||
private Picture picture720;
|
|
||||||
|
|
||||||
private Picture picture1080;
|
|
||||||
|
|
||||||
private long following;
|
private long following;
|
||||||
|
|
||||||
private long followers;
|
private long followers;
|
||||||
|
|
||||||
private long followsHost;
|
private long followsHost;
|
||||||
private List<Picture> additionalPictures;
|
|
||||||
|
|
||||||
private List<Badge> badges;
|
private List<Badge> badges;
|
||||||
|
|
||||||
public User(Long userId,
|
public User(Long userId,
|
||||||
@@ -56,9 +44,6 @@ public class User {
|
|||||||
String nickName,
|
String nickName,
|
||||||
String description,
|
String description,
|
||||||
Picture profilePicture,
|
Picture profilePicture,
|
||||||
Picture picture720,
|
|
||||||
Picture picture1080,
|
|
||||||
List<Picture> additionalPictures,
|
|
||||||
Integer following,
|
Integer following,
|
||||||
Integer followers,
|
Integer followers,
|
||||||
Integer followsHost,
|
Integer followsHost,
|
||||||
@@ -67,10 +52,7 @@ public class User {
|
|||||||
this.uniqueId = uniqueId;
|
this.uniqueId = uniqueId;
|
||||||
this.nickName = nickName;
|
this.nickName = nickName;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.profilePicture = profilePicture;
|
this.picture = profilePicture;
|
||||||
this.picture720 = picture720;
|
|
||||||
this.picture1080 = picture1080;
|
|
||||||
this.additionalPictures = additionalPictures;
|
|
||||||
this.following = following;
|
this.following = following;
|
||||||
this.followers = followers;
|
this.followers = followers;
|
||||||
this.followsHost = followsHost;
|
this.followsHost = followsHost;
|
||||||
@@ -88,42 +70,53 @@ public class User {
|
|||||||
Picture picture) {
|
Picture picture) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.nickName = nickName;
|
this.nickName = nickName;
|
||||||
this.profilePicture = picture;
|
this.picture = picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User(io.github.jwdeveloper.tiktok.messages.User user) {
|
public User(io.github.jwdeveloper.tiktok.messages.data.User user) {
|
||||||
assert user != null;
|
assert user != null;
|
||||||
userId = user.getId();
|
userId = user.getId();
|
||||||
uniqueId = user.getSpecialId();
|
uniqueId = user.getSpecialId();
|
||||||
nickName = user.getNickname();
|
nickName = user.getNickname();
|
||||||
description = user.getBioDescription();
|
description = user.getBioDescription();
|
||||||
profilePicture = Picture.Map(user.getAvatarThumb());
|
picture = Picture.Map(user.getAvatarThumb());
|
||||||
picture720 = Picture.Map(user.getAvatarMedium());
|
|
||||||
picture1080 = Picture.Map(user.getAvatarLarge());
|
|
||||||
following = user.getFollowInfo().getFollowingCount();
|
following = user.getFollowInfo().getFollowingCount();
|
||||||
followers = user.getFollowInfo().getFollowerCount();
|
followers = user.getFollowInfo().getFollowerCount();
|
||||||
followsHost = user.getFollowInfo().getFollowStatus();
|
followsHost = user.getFollowInfo().getFollowStatus();
|
||||||
badges = user.getBadgeListList().stream().map(Badge::new).toList();
|
badges = user.getBadgeListList().stream().map(Badge::new).toList();
|
||||||
additionalPictures = new ArrayList<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static User MapOrEmpty(io.github.jwdeveloper.tiktok.messages.User user) {
|
public static User EMPTY = new User(0L,
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
Picture.Empty(),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
Badge.EmptyList());
|
||||||
|
|
||||||
|
public static User mapOrEmpty(io.github.jwdeveloper.tiktok.messages.data.User user) {
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
return new User(user);
|
return new User(user);
|
||||||
}
|
}
|
||||||
|
return EMPTY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static User mapOrEmpty(io.github.jwdeveloper.tiktok.messages.data.VoteUser user) {
|
||||||
|
return new User(user.getUserId()+"",user.getNickName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static User map(WebcastEnvelopeMessage.EnvelopeInfo envelopeInfo) {
|
||||||
return new User(0L,
|
return new User(0L,
|
||||||
|
envelopeInfo.getSendUserId(),
|
||||||
|
envelopeInfo.getSendUserName(),
|
||||||
"",
|
"",
|
||||||
"",
|
Picture.Map(envelopeInfo.getSendUserAvatar()),
|
||||||
"",
|
|
||||||
Picture.Empty(),
|
|
||||||
Picture.Empty(),
|
|
||||||
Picture.Empty(),
|
|
||||||
Picture.EmptyList(),
|
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
Badge.EmptyList());
|
Badge.EmptyList());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,9 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.models.gifts;
|
package io.github.jwdeveloper.tiktok.events.objects.barrage;
|
||||||
|
|
||||||
|
public class BarrageParam
|
||||||
|
{
|
||||||
|
|
||||||
public class TrackerParams {
|
|
||||||
}
|
}
|
||||||
@@ -20,12 +20,18 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.models.gifts;
|
package io.github.jwdeveloper.tiktok.events.objects.barrage;
|
||||||
|
|
||||||
import lombok.Data;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastBarrageMessage;
|
||||||
|
|
||||||
@Data
|
public class FansLevelParam extends BarrageParam
|
||||||
public class LockInfo
|
|
||||||
{
|
{
|
||||||
private int lock_type;
|
int currentGrade;
|
||||||
|
User user;
|
||||||
|
public FansLevelParam(WebcastBarrageMessage.BarrageTypeFansLevelParam param)
|
||||||
|
{
|
||||||
|
this.currentGrade = param.getCurrentGrade();
|
||||||
|
this.user = User.mapOrEmpty(param.getUser());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -20,14 +20,14 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok;
|
package io.github.jwdeveloper.tiktok.events.objects.barrage;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastBarrageMessage;
|
||||||
|
|
||||||
public class Main {
|
public class SubscribeGiftParam extends BarrageParam
|
||||||
public static void main(String[] args)
|
{
|
||||||
|
public SubscribeGiftParam(WebcastBarrageMessage.BarrageTypeSubscribeGiftParam param)
|
||||||
{
|
{
|
||||||
var generator = new ReadmeGenerator();
|
|
||||||
generator.generate();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,20 +20,16 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.models.gifts;
|
package io.github.jwdeveloper.tiktok.events.objects.barrage;
|
||||||
|
|
||||||
import lombok.Data;
|
import io.github.jwdeveloper.tiktok.events.objects.User;
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastBarrageMessage;
|
||||||
|
|
||||||
import java.util.List;
|
public class UserGradeParam extends BarrageParam {
|
||||||
|
int currentGrade;
|
||||||
@Data
|
User user;
|
||||||
public class Image {
|
public UserGradeParam(WebcastBarrageMessage.BarrageTypeUserGradeParam param) {
|
||||||
private String avg_color;
|
this.currentGrade = param.getCurrentGrade();
|
||||||
private int height;
|
this.user = User.mapOrEmpty(param.getUser());
|
||||||
private int image_type;
|
}
|
||||||
private boolean is_animated;
|
|
||||||
private String open_web_url;
|
|
||||||
private String uri;
|
|
||||||
private List<String> url_list;
|
|
||||||
private int width;
|
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.exceptions;
|
package io.github.jwdeveloper.tiktok.exceptions;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastResponse;
|
|
||||||
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
@@ -38,19 +39,19 @@ public class TikTokLiveMessageException extends TikTokLiveException {
|
|||||||
public TikTokLiveMessageException(WebcastResponse.Message message,
|
public TikTokLiveMessageException(WebcastResponse.Message message,
|
||||||
WebcastResponse webcastResponse,
|
WebcastResponse webcastResponse,
|
||||||
Throwable cause) {
|
Throwable cause) {
|
||||||
super("Error while handling Message: " + message.getType() + ": \n", cause);
|
super("Error while handling Message: " + message.getMethod() + ": \n", cause);
|
||||||
this.webcastMessage = message;
|
this.webcastMessage = message;
|
||||||
this.webcastResponse = webcastResponse;
|
this.webcastResponse = webcastResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String messageName()
|
public String messageMethod()
|
||||||
{
|
{
|
||||||
return webcastMessage.getType();
|
return webcastMessage.getMethod();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String messageToBase64()
|
public String messageToBase64()
|
||||||
{
|
{
|
||||||
return Base64.getEncoder().encodeToString(webcastMessage.getBinary().toByteArray());
|
return Base64.getEncoder().encodeToString(webcastMessage.getPayload().toByteArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String webcastResponseToBase64()
|
public String webcastResponseToBase64()
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ package io.github.jwdeveloper.tiktok.handler;
|
|||||||
|
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastResponse;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
|
||||||
|
|
||||||
|
|
||||||
public interface TikTokMessageHandler
|
public interface TikTokMessageHandler
|
||||||
|
|||||||
@@ -23,19 +23,12 @@
|
|||||||
package io.github.jwdeveloper.tiktok.live;
|
package io.github.jwdeveloper.tiktok.live;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.Gift;
|
import io.github.jwdeveloper.tiktok.events.objects.Gift;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.TikTokGift;
|
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||||
import io.github.jwdeveloper.tiktok.models.GiftId;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public interface GiftManager {
|
public interface GiftManager {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Map<GiftId, TikTokGift> getActiveGifts();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In case you can't find your gift in Gift enum. You can register gift
|
* In case you can't find your gift in Gift enum. You can register gift
|
||||||
* manually here to make it detected while TikTokGiftEvent
|
* manually here to make it detected while TikTokGiftEvent
|
||||||
@@ -45,7 +38,7 @@ public interface GiftManager {
|
|||||||
* @param diamondCost diamond cost
|
* @param diamondCost diamond cost
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Gift registerGift(int id, String name, int diamondCost);
|
Gift registerGift(int id, String name, int diamondCost, Picture picture);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,9 +22,12 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.live;
|
package io.github.jwdeveloper.tiktok.live;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.models.ConnectionState;
|
||||||
|
|
||||||
public interface LiveRoomInfo
|
public interface LiveRoomInfo
|
||||||
{
|
{
|
||||||
int getViewersCount();
|
int getViewersCount();
|
||||||
|
int getLikesCount();
|
||||||
boolean isAgeRestricted();
|
boolean isAgeRestricted();
|
||||||
String getRoomId();
|
String getRoomId();
|
||||||
String getUserName();
|
String getUserName();
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.live;
|
package io.github.jwdeveloper.tiktok.models;
|
||||||
|
|
||||||
public enum ConnectionState
|
public enum ConnectionState
|
||||||
{
|
{
|
||||||
@@ -1,35 +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.models;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class GiftId
|
|
||||||
{
|
|
||||||
private long giftId;
|
|
||||||
|
|
||||||
private String userName;
|
|
||||||
}
|
|
||||||
@@ -1,37 +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.models.gifts;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class DefaultFormat {
|
|
||||||
private boolean bold;
|
|
||||||
private String color;
|
|
||||||
private int font_size;
|
|
||||||
private boolean italic;
|
|
||||||
private int italic_angle;
|
|
||||||
private boolean use_highlight_color;
|
|
||||||
private boolean use_remote_color;
|
|
||||||
private int weight;
|
|
||||||
}
|
|
||||||
@@ -1,39 +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.models.gifts;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class GiftLabelIcon {
|
|
||||||
private String avg_color;
|
|
||||||
private int height;
|
|
||||||
private int image_type;
|
|
||||||
private boolean is_animated;
|
|
||||||
private String open_web_url;
|
|
||||||
private String uri;
|
|
||||||
private List<String> url_list;
|
|
||||||
private int width;
|
|
||||||
}
|
|
||||||
@@ -1,36 +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.models.gifts;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class GiftPanelBanner {
|
|
||||||
private List<Object> bg_color_values;
|
|
||||||
private DisplayText display_text;
|
|
||||||
private LeftIcon left_icon;
|
|
||||||
private String schema_url;
|
|
||||||
}
|
|
||||||
@@ -1,26 +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.models.gifts;
|
|
||||||
|
|
||||||
public class SpecialEffects {
|
|
||||||
}
|
|
||||||
@@ -1,72 +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.models.gifts;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class TikTokGiftInfo
|
|
||||||
{
|
|
||||||
private int action_type;
|
|
||||||
private int app_id;
|
|
||||||
private String business_text;
|
|
||||||
private boolean can_put_in_gift_box;
|
|
||||||
private List<Object> color_infos;
|
|
||||||
private boolean combo;
|
|
||||||
private String describe;
|
|
||||||
private int diamond_count;
|
|
||||||
private int duration;
|
|
||||||
private String event_name;
|
|
||||||
private boolean for_custom;
|
|
||||||
private boolean for_linkmic;
|
|
||||||
private GiftLabelIcon gift_label_icon;
|
|
||||||
private GiftPanelBanner gift_panel_banner;
|
|
||||||
private String gift_rank_recommend_info;
|
|
||||||
private int gift_scene;
|
|
||||||
private String gold_effect;
|
|
||||||
private String gray_scheme_url;
|
|
||||||
private String guide_url;
|
|
||||||
private Icon icon;
|
|
||||||
private int id;
|
|
||||||
private Image image;
|
|
||||||
private boolean is_box_gift;
|
|
||||||
private boolean is_broadcast_gift;
|
|
||||||
private boolean is_displayed_on_panel;
|
|
||||||
private boolean is_effect_befview;
|
|
||||||
private boolean is_gray;
|
|
||||||
private boolean is_random_gift;
|
|
||||||
private int item_type;
|
|
||||||
private LockInfo lock_info;
|
|
||||||
private String manual;
|
|
||||||
private String name;
|
|
||||||
private boolean notify;
|
|
||||||
private int primary_effect_id;
|
|
||||||
private String region;
|
|
||||||
private String scheme_url;
|
|
||||||
private SpecialEffects special_effects;
|
|
||||||
private TrackerParams tracker_params;
|
|
||||||
private List<Object> trigger_words;
|
|
||||||
private int type;
|
|
||||||
}
|
|
||||||
1043
API/src/main/proto/data.proto
Normal file
1043
API/src/main/proto/data.proto
Normal file
File diff suppressed because it is too large
Load Diff
117
API/src/main/proto/enums.proto
Normal file
117
API/src/main/proto/enums.proto
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package TikTok;
|
||||||
|
|
||||||
|
option java_package = "io.github.jwdeveloper.tiktok.messages.enums";
|
||||||
|
option java_multiple_files = true;
|
||||||
|
|
||||||
|
enum AuditStatus {
|
||||||
|
AUDITSTATUSUNKNOWN = 0;
|
||||||
|
AUDITSTATUSPASS = 1;
|
||||||
|
AUDITSTATUSFAILED = 2;
|
||||||
|
AUDITSTATUSREVIEWING = 3;
|
||||||
|
AUDITSTATUSFORBIDDEN = 4;
|
||||||
|
}
|
||||||
|
enum EmoteType {
|
||||||
|
EMOTETYPENORMAL = 0;
|
||||||
|
EMOTETYPEWITHSTICKER = 1;
|
||||||
|
}
|
||||||
|
enum ContentSource {
|
||||||
|
CONTENTSOURCEUNKNOWN = 0;
|
||||||
|
CONTENTSOURCENORMAL = 1;
|
||||||
|
CONTENTSOURCECAMERA = 2;
|
||||||
|
}
|
||||||
|
enum EmotePrivateType {
|
||||||
|
EMOTE_PRIVATE_TYPE_NORMAL = 0;
|
||||||
|
EMOTE_PRIVATE_TYPE_SUB_WAVE = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ExhibitionType {
|
||||||
|
EXHIBITIONTYPE_DEFAULT = 0;
|
||||||
|
EXHIBITIONTYPE_FOLD = 1;
|
||||||
|
EXHIBITIONTYPE_PUBLICSCREEN = 2;
|
||||||
|
}
|
||||||
|
enum SubscribeType {
|
||||||
|
SUBSCRIBETYPE_ONCE = 0;
|
||||||
|
SUBSCRIBETYPE_AUTO = 1;
|
||||||
|
SUBSCRIBETYPE_DEFAULT = 100;
|
||||||
|
}
|
||||||
|
enum OldSubscribeStatus {
|
||||||
|
OLDSUBSCRIBESTATUS_FIRST = 0;
|
||||||
|
OLDSUBSCRIBESTATUS_RESUB = 1;
|
||||||
|
OLDSUBSCRIBESTATUS_SUBINGRACEPERIOD = 2;
|
||||||
|
OLDSUBSCRIBESTATUS_SUBNOTINGRACEPERIOD = 3;
|
||||||
|
OLDSUBSCRIBESTATUS_DEFAULT = 100;
|
||||||
|
}
|
||||||
|
enum SubscribingStatus {
|
||||||
|
SUBSCRIBINGSTATUS_UNKNOWN = 0;
|
||||||
|
SUBSCRIBINGSTATUS_ONCE = 1;
|
||||||
|
SUBSCRIBINGSTATUS_CIRCLE = 2;
|
||||||
|
SUBSCRIBINGSTATUS_CIRCLECANCEL = 3;
|
||||||
|
SUBSCRIBINGSTATUS_REFUND = 4;
|
||||||
|
SUBSCRIBINGSTATUS_INGRACEPERIOD = 5;
|
||||||
|
SUBSCRIBINGSTATUS_NOTINGRACEPERIOD = 6;
|
||||||
|
}
|
||||||
|
enum LinkmicStatus
|
||||||
|
{
|
||||||
|
Disable = 0;
|
||||||
|
Enable = 1;
|
||||||
|
Just_Following = 2;
|
||||||
|
Multi_Linking = 3;
|
||||||
|
Multi_Linking_Only_Following = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum MemberMessageAction {
|
||||||
|
UNKNOWN = 0;
|
||||||
|
JOINED = 1; // User Joined the Stream
|
||||||
|
SUBSCRIBED = 3; // User Subscribed to the Host
|
||||||
|
//?? = 26
|
||||||
|
//?? = 27
|
||||||
|
//?? = 50 (share?)
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ControlAction {
|
||||||
|
ControlActionUNKNOWN = 0;
|
||||||
|
STREAM_PAUSED = 1; // Stream Paused by Host
|
||||||
|
STREAM_ENDED = 3; // Stream Ended by Host
|
||||||
|
}
|
||||||
|
|
||||||
|
enum LinkLayerMessageType
|
||||||
|
{
|
||||||
|
Linker_Unknown = 0;
|
||||||
|
Linker_Create = 1;
|
||||||
|
Linker_Invite = 2;
|
||||||
|
Linker_Apply = 3;
|
||||||
|
Linker_Permit = 4;
|
||||||
|
Linker_Reply = 5;
|
||||||
|
Linker_Kick_Out = 6;
|
||||||
|
Linker_Cancel_Apply = 7;
|
||||||
|
Linker_Cancel_Invite = 8;
|
||||||
|
Linker_Leave = 9;
|
||||||
|
Linker_Finish = 10;
|
||||||
|
Linker_List_Change = 11;
|
||||||
|
Linker_Join_Direct = 12;
|
||||||
|
Linker_Join_Group = 13;
|
||||||
|
Linker_Permit_Group = 14;
|
||||||
|
Linker_Cancel_Group = 15;
|
||||||
|
Linker_Leave_Group = 16;
|
||||||
|
Linker_P2P_Group_Change = 17;
|
||||||
|
Linker_Group_Change = 18;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum BarrageType
|
||||||
|
{
|
||||||
|
BarrageType_Unknown = 0;
|
||||||
|
EComOrdering = 1;
|
||||||
|
EComBuying = 2;
|
||||||
|
Normal = 3;
|
||||||
|
Subscribe = 4;
|
||||||
|
EventView = 5;
|
||||||
|
EventRegistered = 6;
|
||||||
|
SubscribeGift = 7;
|
||||||
|
UserUpgrade = 8;
|
||||||
|
GradeUserEntranceNotification = 9;
|
||||||
|
FansLevelUpgrade = 10;
|
||||||
|
FansLevelEntrance = 11;
|
||||||
|
GamePartnership = 12;
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
719
API/src/main/proto/webcast.proto
Normal file
719
API/src/main/proto/webcast.proto
Normal file
@@ -0,0 +1,719 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
package TikTok;
|
||||||
|
|
||||||
|
// Instruction if data.proto or enums.proto is not be found!
|
||||||
|
// https://stackoverflow.com/questions/62837953/protocol-buffer-imports-not-recognized-in-intellij
|
||||||
|
//
|
||||||
|
import "data.proto";
|
||||||
|
import "enums.proto";
|
||||||
|
|
||||||
|
option java_package = "io.github.jwdeveloper.tiktok.messages.webcast";
|
||||||
|
option java_multiple_files = true;
|
||||||
|
|
||||||
|
|
||||||
|
//@WebcastPushFrame
|
||||||
|
// Response from TikTokServer. Container for Messages
|
||||||
|
message WebcastPushFrame {
|
||||||
|
uint64 SeqId = 1;
|
||||||
|
uint64 LogId = 2;
|
||||||
|
uint64 Service = 3;
|
||||||
|
uint64 Method = 4;
|
||||||
|
map<string,string> headers = 5;
|
||||||
|
string PayloadEncoding = 6;
|
||||||
|
string PayloadType = 7;
|
||||||
|
bytes Payload = 8;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
message WebcastWebsocketAck {
|
||||||
|
uint64 Id = 1;
|
||||||
|
string Type = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//@WebcastResponse
|
||||||
|
// Response from TikTokServer. Container for Messages
|
||||||
|
message WebcastResponse {
|
||||||
|
repeated Message messages = 1;
|
||||||
|
string cursor = 2;
|
||||||
|
int64 fetchInterval = 3;
|
||||||
|
int64 now = 4;
|
||||||
|
string internalExt = 5;
|
||||||
|
int32 fetchType = 6;
|
||||||
|
map<string, string> routeParamsMap = 7;
|
||||||
|
int64 heartBeatDuration = 8;
|
||||||
|
bool needsAck = 9;
|
||||||
|
string pushServer = 10;
|
||||||
|
bool isFirst = 11;
|
||||||
|
string historyCommentCursor = 12;
|
||||||
|
bool historyNoMore = 13;
|
||||||
|
|
||||||
|
// Server-Message. Binary will deserialize into specific message
|
||||||
|
message Message {
|
||||||
|
string method = 1;
|
||||||
|
bytes payload = 2;
|
||||||
|
int64 msgId = 3;
|
||||||
|
int32 msgType = 4;
|
||||||
|
int64 offset = 5;
|
||||||
|
bool isHistory = 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//@GiftMessage
|
||||||
|
message WebcastGiftMessage {
|
||||||
|
Common common = 1;
|
||||||
|
int64 giftId = 2;
|
||||||
|
int64 fanTicketCount = 3;
|
||||||
|
int64 groupCount = 4;
|
||||||
|
int64 repeatCount = 5;
|
||||||
|
int64 comboCount = 6;
|
||||||
|
User user = 7;
|
||||||
|
User toUser = 8;
|
||||||
|
int32 repeatEnd = 9;
|
||||||
|
int64 groupId = 11;
|
||||||
|
int64 incomeTaskgifts = 12;
|
||||||
|
int64 roomFanTicketCount = 13;
|
||||||
|
GiftStruct gift = 15;
|
||||||
|
string logId = 16;
|
||||||
|
int64 sendType = 17;
|
||||||
|
string monitorExtra = 22;
|
||||||
|
int64 colorId = 24;
|
||||||
|
bool isFirstSent = 25;
|
||||||
|
string orderId = 28;
|
||||||
|
UserIdentity userIdentity = 32;
|
||||||
|
|
||||||
|
message GiftIMPriority {
|
||||||
|
repeated int64 queueSizesList = 1;
|
||||||
|
int64 selfQueuePriority = 2;
|
||||||
|
int64 priority = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message PublicAreaCommon {
|
||||||
|
Image userLabel = 1;
|
||||||
|
int64 userConsumeInRoom = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message UserIdentity {
|
||||||
|
bool isGiftGiverOfAnchor = 1;
|
||||||
|
bool isSubscriberOfAnchor = 2;
|
||||||
|
bool isMutualFollowingWithAnchor = 3;
|
||||||
|
bool isFollowerOfAnchor = 4;
|
||||||
|
bool isModeratorOfAnchor = 5;
|
||||||
|
bool isAnchor = 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastRoomMessage
|
||||||
|
message WebcastRoomMessage {
|
||||||
|
Common common = 1;
|
||||||
|
string content = 2;
|
||||||
|
bool supprotLandscape = 3;
|
||||||
|
int64 source = 4;
|
||||||
|
Image icon = 5;
|
||||||
|
string scene = 6;
|
||||||
|
bool isWelcome = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastBarrageMessage
|
||||||
|
message WebcastBarrageMessage {
|
||||||
|
Common common = 1;
|
||||||
|
BarrageEvent event = 2;
|
||||||
|
BarrageType msgType = 3; // Enum
|
||||||
|
Image icon = 4;
|
||||||
|
Text content = 5;
|
||||||
|
int32 duration = 6;
|
||||||
|
Image background = 7;
|
||||||
|
Image rightIcon = 8;
|
||||||
|
BarrageTypeUserGradeParam userGradeParam = 100;
|
||||||
|
BarrageTypeFansLevelParam fansLevelParam = 101;
|
||||||
|
BarrageTypeSubscribeGiftParam subscribeGiftParam = 102;
|
||||||
|
|
||||||
|
message BarrageTypeUserGradeParam {
|
||||||
|
int32 currentGrade = 1;
|
||||||
|
int32 displayConfig = 2;
|
||||||
|
string userId = 3;
|
||||||
|
User user = 4;
|
||||||
|
}
|
||||||
|
message BarrageTypeFansLevelParam {
|
||||||
|
int32 currentGrade = 1;
|
||||||
|
int32 displayConfig = 2;
|
||||||
|
User user = 4;
|
||||||
|
}
|
||||||
|
message BarrageTypeSubscribeGiftParam {
|
||||||
|
int64 giftSubCount = 1;
|
||||||
|
bool showGiftSubCount = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message BarrageEvent {
|
||||||
|
string eventName = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @BarrageType
|
||||||
|
// webcast.im.BarrageMessage
|
||||||
|
enum BarrageType {
|
||||||
|
UNKNOWN = 0;
|
||||||
|
ECOMORDERING = 1;
|
||||||
|
ECOMBUYING = 2;
|
||||||
|
NORMAL = 3;
|
||||||
|
SUBSCRIBE = 4;
|
||||||
|
EVENTVIEW = 5;
|
||||||
|
EVENTREGISTERED = 6;
|
||||||
|
SUBSCRIBEGIFT = 7;
|
||||||
|
USERUPGRADE = 8;
|
||||||
|
GRADEUSERENTRANCENOTIFICATION = 9;
|
||||||
|
FANSLEVELUPGRADE = 10;
|
||||||
|
FANSLEVELENTRANCE = 11;
|
||||||
|
GAMEPARTNERSHIP = 12;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastCaptionMessage
|
||||||
|
// Closed Captioning for Video
|
||||||
|
message WebcastCaptionMessage {
|
||||||
|
Common header = 1;
|
||||||
|
uint64 timeStamp = 2;
|
||||||
|
uint32 data1 = 3;
|
||||||
|
CaptionData captionData = 4;
|
||||||
|
|
||||||
|
message CaptionData {
|
||||||
|
string ISOLanguage = 1;
|
||||||
|
string Text = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Comment sent by User
|
||||||
|
//@WebcastChatMessage
|
||||||
|
message WebcastChatMessage {
|
||||||
|
Common common = 1;
|
||||||
|
User user = 2;
|
||||||
|
string content = 3;
|
||||||
|
bool visibleToSender = 4;
|
||||||
|
Image backgroundImage = 5;
|
||||||
|
string fullScreenTextColor = 6;
|
||||||
|
Image backgroundImageV2 = 7;
|
||||||
|
Image giftImage = 10;
|
||||||
|
int32 inputType = 11;
|
||||||
|
User atUser = 12;
|
||||||
|
repeated EmoteWithIndex emotesList = 13;
|
||||||
|
string contentLanguage = 14;
|
||||||
|
int32 quickChatScene = 16;
|
||||||
|
int32 communityFlaggedStatus = 17;
|
||||||
|
|
||||||
|
// @EmoteWithIndex
|
||||||
|
// proto.webcast.im.ChatMessage
|
||||||
|
message EmoteWithIndex {
|
||||||
|
int64 index = 1;
|
||||||
|
Emote emote = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// System-Control Message from Room (e.g. Host ended Stream)
|
||||||
|
//@WebcastControlMessage
|
||||||
|
message WebcastControlMessage {
|
||||||
|
Common common = 1;
|
||||||
|
ControlAction action = 2;
|
||||||
|
string tips = 3;
|
||||||
|
Extra extra = 4;
|
||||||
|
//PerceptionDialogInfo perceptionDialog = 5;
|
||||||
|
Text perceptionAudienceText = 6;
|
||||||
|
PunishEventInfo punishInfo = 7;
|
||||||
|
Text floatText = 8;
|
||||||
|
int32 floatStyle = 9;
|
||||||
|
|
||||||
|
// @Extra
|
||||||
|
// proto.webcast.im.ControlMessage
|
||||||
|
message Extra {
|
||||||
|
string banInfoUrl = 1;
|
||||||
|
int64 reasonNo = 2;
|
||||||
|
Text title = 3;
|
||||||
|
Text violationReason = 4;
|
||||||
|
Text content = 5;
|
||||||
|
Text gotItButton = 6;
|
||||||
|
Text banDetailButton = 7;
|
||||||
|
string source = 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Emote sent by user
|
||||||
|
//@WebcastEmoteChatMessage
|
||||||
|
message WebcastEmoteChatMessage {
|
||||||
|
Common common = 1;
|
||||||
|
User user = 2;
|
||||||
|
repeated Emote emoteList = 3;
|
||||||
|
MsgFilter msgFilter = 4;
|
||||||
|
UserIdentity userIdentity = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastEnvelopeMessage
|
||||||
|
message WebcastEnvelopeMessage {
|
||||||
|
Common common = 1;
|
||||||
|
EnvelopeInfo envelopeInfo = 2;
|
||||||
|
int64 display = 3; // @warning Enum not found, should be Display
|
||||||
|
|
||||||
|
// @EnvelopeInfo
|
||||||
|
// proto.webcast.im.EnvelopeMessage
|
||||||
|
// C:\Users\ja\RiderProjects\TikTokProBufferGenerator\Application\output\sources\test.js
|
||||||
|
message EnvelopeInfo {
|
||||||
|
string envelopeId = 1;
|
||||||
|
int64 businessType = 2; // @warning Enum not found, should be BusinessType
|
||||||
|
string envelopeIdc = 3;
|
||||||
|
string sendUserName = 4;
|
||||||
|
int32 diamondCount = 5;
|
||||||
|
int32 peopleCount = 6;
|
||||||
|
int32 unpackAt = 7;
|
||||||
|
string sendUserId = 8;
|
||||||
|
Image sendUserAvatar = 9;
|
||||||
|
string createAt = 10;
|
||||||
|
string roomId = 11;
|
||||||
|
int64 followShowStatus = 12; // @warning Enum not found, should be FollowShowStatus
|
||||||
|
int32 skinId = 13;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastGoalUpdateMessage
|
||||||
|
message WebcastGoalUpdateMessage {
|
||||||
|
Common common = 1;
|
||||||
|
Indicator indicator = 2;
|
||||||
|
Goal goal = 3;
|
||||||
|
int64 contributorId = 4;
|
||||||
|
Image contributorAvatar = 5;
|
||||||
|
string contributorDisplayId = 6;
|
||||||
|
// SubGoal contributeSubgoal = 7;
|
||||||
|
int64 contributeCount = 9;
|
||||||
|
int64 contributeScore = 10;
|
||||||
|
int64 giftRepeatCount = 11;
|
||||||
|
string contributorIdStr = 12;
|
||||||
|
bool pin = 13;
|
||||||
|
bool unpin = 14;
|
||||||
|
// GoalPinInfo pinInfo = 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Message related to Chat-moderation?
|
||||||
|
//@WebcastImDeleteMessage
|
||||||
|
message WebcastImDeleteMessage {
|
||||||
|
Common header = 1;
|
||||||
|
bytes data = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastInRoomBannerMessage
|
||||||
|
message WebcastInRoomBannerMessage {
|
||||||
|
Common header = 1;
|
||||||
|
string json = 2; // Json-Data for BannerMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
// User sent one or multiple likes to Stream. Maxes at 15 likes per message
|
||||||
|
//@WebcastLikeMessage
|
||||||
|
message WebcastLikeMessage {
|
||||||
|
Common common = 1;
|
||||||
|
int32 count = 2;
|
||||||
|
int32 total = 3;
|
||||||
|
User user = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status of Room (ViewerCount + Top Viewers)
|
||||||
|
//@WebcastRoomUserSeqMessage
|
||||||
|
message WebcastRoomUserSeqMessage {
|
||||||
|
Common common = 1;
|
||||||
|
repeated Contributor ranksList = 2;
|
||||||
|
int64 total = 3;
|
||||||
|
string popStr = 4;
|
||||||
|
repeated Contributor seatsList = 5;
|
||||||
|
int64 popularity = 6;
|
||||||
|
int32 totalUser = 7;
|
||||||
|
int64 anonymous = 8;
|
||||||
|
|
||||||
|
// @Contributor
|
||||||
|
message Contributor {
|
||||||
|
int32 score = 1;
|
||||||
|
User user = 2;
|
||||||
|
int32 rank = 3;
|
||||||
|
int64 delta = 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sent for a variety of events, including Follow & Share
|
||||||
|
//@WebcastSocialMessage
|
||||||
|
message WebcastSocialMessage {
|
||||||
|
Common common = 1;
|
||||||
|
User user = 2;
|
||||||
|
int64 shareType = 3;
|
||||||
|
int64 action = 4;
|
||||||
|
string shareTarget = 5;
|
||||||
|
int64 followCount = 6;
|
||||||
|
int64 shareDisplayStyle = 7;
|
||||||
|
int64 shareCount = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastSubNotifyMessage
|
||||||
|
message WebcastSubNotifyMessage {
|
||||||
|
Common common = 1;
|
||||||
|
User user = 2;
|
||||||
|
ExhibitionType exhibitionType = 3; // Enum
|
||||||
|
int64 subMonth = 4;
|
||||||
|
SubscribeType subscribeType = 5; // Enum
|
||||||
|
OldSubscribeStatus oldSubscribeStatus = 6; // Enum
|
||||||
|
SubscribingStatus subscribingStatus = 8; // Enum
|
||||||
|
bool isSend = 9;
|
||||||
|
bool isCustom = 10;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastRankUpdateMessage
|
||||||
|
message WebcastRankUpdateMessage {
|
||||||
|
Common common = 1;
|
||||||
|
repeated RankUpdate updatesList = 2;
|
||||||
|
int64 groupType = 3; // @warning Enum not found, should be GroupType
|
||||||
|
int64 priority = 5;
|
||||||
|
repeated RankTabInfo tabsList = 6;
|
||||||
|
bool isAnimationLoopPlay = 7;
|
||||||
|
bool animationLoopForOff = 8;
|
||||||
|
|
||||||
|
|
||||||
|
message RankTabInfo {
|
||||||
|
int64 rankType = 1; // @warning Enum not found, should be RankType
|
||||||
|
string title = 2;
|
||||||
|
Text titleText = 3;
|
||||||
|
int64 listLynxType = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @RankUpdate
|
||||||
|
// proto.webcast.im.RankUpdateMessage
|
||||||
|
message RankUpdate {
|
||||||
|
int64 rankType = 1; // @warning Enum not found, should be RankType
|
||||||
|
int64 ownerRank = 2;
|
||||||
|
Text defaultContent = 3;
|
||||||
|
bool showEntranceAnimation = 5;
|
||||||
|
int64 countdown = 6;
|
||||||
|
int64 relatedTabRankType = 8; // @warning Enum not found, should be RelatedTabRankType
|
||||||
|
int64 requestFirstShowType = 9; // @warning Enum not found, should be RequestFirstShowType
|
||||||
|
int64 supportedVersion = 10;
|
||||||
|
bool owneronrank = 11;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sent for a variety of events, including Join & Subscribe
|
||||||
|
//@WebcastMemberMessage
|
||||||
|
message WebcastMemberMessage {
|
||||||
|
Common common = 1;
|
||||||
|
User user = 2;
|
||||||
|
int32 memberCount = 3;
|
||||||
|
User operator = 4;
|
||||||
|
bool isSetToAdmin = 5;
|
||||||
|
bool isTopUser = 6;
|
||||||
|
int64 rankScore = 7;
|
||||||
|
int64 topUserNo = 8;
|
||||||
|
int64 enterType = 9;
|
||||||
|
MemberMessageAction action = 10;
|
||||||
|
string actionDescription = 11;
|
||||||
|
int64 userId = 12;
|
||||||
|
EffectConfig effectConfig = 13;
|
||||||
|
string popStr = 14;
|
||||||
|
EffectConfig enterEffectConfig = 15;
|
||||||
|
Image backgroundImage = 16;
|
||||||
|
Image backgroundImageV2 = 17;
|
||||||
|
Text anchorDisplayText = 18;
|
||||||
|
string clientEnterSource = 19;
|
||||||
|
string clientEnterType = 20;
|
||||||
|
string clientLiveReason = 21;
|
||||||
|
int64 actionDuration = 22;
|
||||||
|
string userShareType = 23;
|
||||||
|
|
||||||
|
// @EffectConfig
|
||||||
|
// proto.webcast.im.MemberMessage
|
||||||
|
// C:\Users\ja\RiderProjects\TikTokProBufferGenerator\Application\output\sources\test.js
|
||||||
|
message EffectConfig {
|
||||||
|
int64 type = 1;
|
||||||
|
Image icon = 2;
|
||||||
|
int64 avatarPos = 3;
|
||||||
|
Text text = 4;
|
||||||
|
Image textIcon = 5;
|
||||||
|
int32 stayTime = 6;
|
||||||
|
int64 animAssetId = 7;
|
||||||
|
Image badge = 8;
|
||||||
|
repeated int64 flexSettingArrayList = 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// --- HandMade --
|
||||||
|
//@WebcastPollMessage
|
||||||
|
message WebcastPollMessage {
|
||||||
|
Common common = 1;
|
||||||
|
int32 messageType = 2;
|
||||||
|
int64 pollId = 3;
|
||||||
|
PollStartContent startContent = 4;
|
||||||
|
PollEndContent endContent = 5;
|
||||||
|
PollUpdateVotesContent updateContent = 6;
|
||||||
|
int32 pollKind = 7; // Possibly an Enum?
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastQuestionNewMessage
|
||||||
|
message WebcastQuestionNewMessage {
|
||||||
|
Common common = 1;
|
||||||
|
QuestionDetails details = 2;
|
||||||
|
|
||||||
|
message QuestionDetails {
|
||||||
|
uint64 id = 1;
|
||||||
|
string text = 2;
|
||||||
|
uint64 timeStamp = 4;
|
||||||
|
User user = 5;
|
||||||
|
uint32 data1 = 20;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastRankTextMessage
|
||||||
|
message WebcastRankTextMessage {
|
||||||
|
Common common = 1;
|
||||||
|
int32 scene = 2;
|
||||||
|
int64 ownerIdxBeforeUpdate = 3;
|
||||||
|
int64 ownerIdxAfterUpdate = 4;
|
||||||
|
Text selfGetBadgeMsg = 5;
|
||||||
|
Text otherGetBadgeMsg = 6;
|
||||||
|
int64 curUserId = 7;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastHourlyRankMessage
|
||||||
|
message WebcastHourlyRankMessage {
|
||||||
|
Common common = 1;
|
||||||
|
RankContainer data = 2;
|
||||||
|
uint32 data2 = 3;
|
||||||
|
|
||||||
|
message RankContainer {
|
||||||
|
uint32 data1 = 1;
|
||||||
|
RankingData rankingdata = 2;
|
||||||
|
uint32 data2 = 3;
|
||||||
|
Ranking rankings = 4;
|
||||||
|
RankingData2 rankingdata2 = 5;
|
||||||
|
uint32 data3 = 6;
|
||||||
|
uint32 data4 = 7;
|
||||||
|
|
||||||
|
message RankingData {
|
||||||
|
uint32 data1 = 1;
|
||||||
|
Ranking rankdata = 2;
|
||||||
|
string data2 = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RankingData2 {
|
||||||
|
uint32 data1 = 1;
|
||||||
|
uint32 data2 = 2;
|
||||||
|
Ranking rankdata = 3;
|
||||||
|
string data3 = 4;
|
||||||
|
uint32 data4 = 5;
|
||||||
|
uint32 data5 = 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastLinkMicArmies
|
||||||
|
message WebcastLinkMicArmies {
|
||||||
|
Common common = 1;
|
||||||
|
uint64 id = 2;
|
||||||
|
repeated LinkMicArmiesItems battleItems = 3;
|
||||||
|
uint64 id2 = 4;
|
||||||
|
uint64 timeStamp1 = 5;
|
||||||
|
uint64 timeStamp2 = 6;
|
||||||
|
int32 battleStatus = 7; // SHOULD BE AN ENUM
|
||||||
|
uint64 data1 = 8;
|
||||||
|
uint64 data2 = 9;
|
||||||
|
uint32 data3 = 10;
|
||||||
|
Image Image = 11;
|
||||||
|
uint32 data4 = 12;
|
||||||
|
uint32 data5 = 13;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastLinkMicBattle
|
||||||
|
message WebcastLinkMicBattle {
|
||||||
|
Common common = 1;
|
||||||
|
uint64 id = 2;
|
||||||
|
LinkMicBattleConfig battleConfig = 3;
|
||||||
|
uint32 data2 = 4;
|
||||||
|
repeated LinkMicBattleDetails details = 5;
|
||||||
|
repeated LinkMicBattleTeam teams1 = 9;
|
||||||
|
repeated LinkMicBattleTeam teams2 = 10;
|
||||||
|
repeated LinkMicBattleTeamData teamData = 13;
|
||||||
|
|
||||||
|
message LinkMicBattleConfig {
|
||||||
|
uint64 id1 = 1;
|
||||||
|
uint64 timestamp = 2;
|
||||||
|
uint32 data1 = 3;
|
||||||
|
uint64 id2 = 4;
|
||||||
|
uint32 data2 = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
message LinkMicBattleData {
|
||||||
|
uint64 id = 1;
|
||||||
|
uint32 data1 = 2;
|
||||||
|
uint32 data2 = 3;
|
||||||
|
uint32 data3 = 5;
|
||||||
|
string url = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message LinkMicBattleDetails {
|
||||||
|
uint64 id = 1;
|
||||||
|
LinkMicBattleData details = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message LinkMicBattleTeam {
|
||||||
|
uint64 id = 1;
|
||||||
|
repeated User users = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message LinkMicBattleTeamData {
|
||||||
|
uint64 teamId = 1;
|
||||||
|
LinkMicBattleData data = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastLinkMicFanTicketMethod
|
||||||
|
message WebcastLinkMicFanTicketMethod {
|
||||||
|
Common common = 1;
|
||||||
|
FanTicketRoomNoticeContent FanTicketRoomNotice = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastLinkMicMethod
|
||||||
|
message WebcastLinkMicMethod {
|
||||||
|
Common common = 1;
|
||||||
|
int64 messageType = 2;
|
||||||
|
string accessKey = 3;
|
||||||
|
int64 anchorLinkmicId = 4;
|
||||||
|
int64 userId = 5;
|
||||||
|
int64 fanTicket = 6;
|
||||||
|
int64 totalLinkMicFanTicket = 7;
|
||||||
|
int64 channelId = 8;
|
||||||
|
int64 layout = 9;
|
||||||
|
int64 vendor = 10;
|
||||||
|
int64 dimension = 11;
|
||||||
|
string theme = 12;
|
||||||
|
int64 inviteUid = 13;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastLiveIntroMessage
|
||||||
|
message WebcastLiveIntroMessage {
|
||||||
|
Common common = 1;
|
||||||
|
int64 roomId = 2;
|
||||||
|
AuditStatus auditStatus = 3;
|
||||||
|
string content = 4;
|
||||||
|
User host = 5;
|
||||||
|
int32 introMode = 6;
|
||||||
|
repeated BadgeStruct badges = 7;
|
||||||
|
string language = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastUnauthorizedMemberMessage
|
||||||
|
message WebcastUnauthorizedMemberMessage {
|
||||||
|
Common common = 1;
|
||||||
|
int32 action = 2;
|
||||||
|
Text nickNamePrefix = 3;
|
||||||
|
string nickName = 4;
|
||||||
|
Text enterText = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastMsgDetectMessage
|
||||||
|
message WebcastMsgDetectMessage {
|
||||||
|
Common common = 1;
|
||||||
|
int32 detectType = 2; // Possibly an Enum?
|
||||||
|
TriggerCondition triggerCondition = 3;
|
||||||
|
TimeInfo timeInfo = 4;
|
||||||
|
int32 triggerBy = 5; // Possible an Enum?
|
||||||
|
string fromRegion = 6;
|
||||||
|
|
||||||
|
message TimeInfo {
|
||||||
|
int64 clientStartMs = 1;
|
||||||
|
int64 apiRecvTimeMs = 2;
|
||||||
|
int64 apiSendToGoimMs = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TriggerCondition {
|
||||||
|
bool uplinkDetectHttp = 1;
|
||||||
|
bool uplinkDetectWebSocket = 2;
|
||||||
|
bool detectP2PMsg = 3;
|
||||||
|
bool detectRoomMsg = 4;
|
||||||
|
bool httpOptimize = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastOecLiveShoppingMessage
|
||||||
|
message WebcastOecLiveShoppingMessage {
|
||||||
|
Common common = 1;
|
||||||
|
uint32 data1 = 2;
|
||||||
|
LiveShoppingData shopData = 4;
|
||||||
|
TimeStampContainer shopTimings = 5; // Uses index 1, 2 & 3
|
||||||
|
LiveShoppingDetails details = 9;
|
||||||
|
|
||||||
|
message LiveShoppingData {
|
||||||
|
string title = 1;
|
||||||
|
string priceString = 2; // $55.99
|
||||||
|
string imageUrl = 3;
|
||||||
|
string shopUrl = 4;
|
||||||
|
uint64 data1 = 6;
|
||||||
|
string shopName = 7; // "Shopify"
|
||||||
|
uint64 data2 = 8;
|
||||||
|
string shopUrl2 = 9;
|
||||||
|
uint64 data3 = 10;
|
||||||
|
uint64 data4 = 11;
|
||||||
|
}
|
||||||
|
|
||||||
|
message LiveShoppingDetails {
|
||||||
|
string id1 = 1;
|
||||||
|
string data1 = 3;
|
||||||
|
uint32 data2 = 4;
|
||||||
|
uint64 timestamp = 5;
|
||||||
|
ValueLabel data = 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastRoomPinMessage
|
||||||
|
// Host Pins comment to stream
|
||||||
|
message WebcastRoomPinMessage {
|
||||||
|
Common common = 1;
|
||||||
|
bytes pinnedMessage = 2; // Usually this is a ChatMessage, but it can also be another message.
|
||||||
|
string originalMsgType = 30; // Use this Type/Method to Deserialize the PinnedMessage
|
||||||
|
uint64 timestamp = 31;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@SystemMessage
|
||||||
|
message WebcastSystemMessage {
|
||||||
|
Common common = 1;
|
||||||
|
string message = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
//@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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//@WebcastLinkLayerMessage
|
||||||
|
message WebcastLinkLayerMessage {
|
||||||
|
Common common = 1;
|
||||||
|
LinkLayerMessageType messageType = 2;
|
||||||
|
int64 channelId = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
|
|||||||
import io.github.jwdeveloper.tiktok.http.TikTokApiService;
|
import io.github.jwdeveloper.tiktok.http.TikTokApiService;
|
||||||
import io.github.jwdeveloper.tiktok.listener.ListenersManager;
|
import io.github.jwdeveloper.tiktok.listener.ListenersManager;
|
||||||
import io.github.jwdeveloper.tiktok.listener.TikTokListenersManager;
|
import io.github.jwdeveloper.tiktok.listener.TikTokListenersManager;
|
||||||
import io.github.jwdeveloper.tiktok.live.ConnectionState;
|
import io.github.jwdeveloper.tiktok.models.ConnectionState;
|
||||||
import io.github.jwdeveloper.tiktok.live.GiftManager;
|
import io.github.jwdeveloper.tiktok.live.GiftManager;
|
||||||
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||||
import io.github.jwdeveloper.tiktok.live.LiveRoomInfo;
|
import io.github.jwdeveloper.tiktok.live.LiveRoomInfo;
|
||||||
|
|||||||
@@ -26,6 +26,14 @@ import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
|||||||
import io.github.jwdeveloper.tiktok.events.TikTokEventBuilder;
|
import io.github.jwdeveloper.tiktok.events.TikTokEventBuilder;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEventConsumer;
|
import io.github.jwdeveloper.tiktok.events.TikTokEventConsumer;
|
||||||
import io.github.jwdeveloper.tiktok.events.messages.*;
|
import io.github.jwdeveloper.tiktok.events.messages.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokConnectedEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokDisconnectedEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokGiftComboFinishedEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokGiftEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokJoinEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokLikeEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokBarrageEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.poll.TikTokPollEvent;
|
||||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
|
||||||
import io.github.jwdeveloper.tiktok.gifts.TikTokGiftManager;
|
import io.github.jwdeveloper.tiktok.gifts.TikTokGiftManager;
|
||||||
import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
|
import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
|
||||||
|
|||||||
@@ -22,13 +22,16 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok;
|
package io.github.jwdeveloper.tiktok;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.live.ConnectionState;
|
import io.github.jwdeveloper.tiktok.models.ConnectionState;
|
||||||
import io.github.jwdeveloper.tiktok.live.LiveRoomInfo;
|
import io.github.jwdeveloper.tiktok.live.LiveRoomInfo;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class TikTokRoomInfo implements LiveRoomInfo
|
public class TikTokRoomInfo implements LiveRoomInfo
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private int likesCount;
|
||||||
|
|
||||||
private int viewersCount;
|
private int viewersCount;
|
||||||
|
|
||||||
private String roomId;
|
private String roomId;
|
||||||
|
|||||||
@@ -23,12 +23,9 @@
|
|||||||
package io.github.jwdeveloper.tiktok.gifts;
|
package io.github.jwdeveloper.tiktok.gifts;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.Gift;
|
import io.github.jwdeveloper.tiktok.events.objects.Gift;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.TikTokGift;
|
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
|
||||||
import io.github.jwdeveloper.tiktok.live.GiftManager;
|
import io.github.jwdeveloper.tiktok.live.GiftManager;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastGiftMessage;
|
|
||||||
import io.github.jwdeveloper.tiktok.models.GiftId;
|
|
||||||
import lombok.Getter;
|
|
||||||
import sun.misc.Unsafe;
|
import sun.misc.Unsafe;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -37,13 +34,10 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class TikTokGiftManager implements GiftManager {
|
public class TikTokGiftManager implements GiftManager {
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Map<GiftId, TikTokGift> activeGifts;
|
|
||||||
private final Map<Integer, Gift> indexById;
|
private final Map<Integer, Gift> indexById;
|
||||||
private final Map<String, Gift> indexByName;
|
private final Map<String, Gift> indexByName;
|
||||||
|
|
||||||
public TikTokGiftManager() {
|
public TikTokGiftManager() {
|
||||||
activeGifts = new HashMap<>();
|
|
||||||
indexById = new HashMap<>();
|
indexById = new HashMap<>();
|
||||||
indexByName = new HashMap<>();
|
indexByName = new HashMap<>();
|
||||||
init();
|
init();
|
||||||
@@ -56,26 +50,7 @@ public class TikTokGiftManager implements GiftManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TikTokGift updateActiveGift(WebcastGiftMessage giftMessage) {
|
public Gift registerGift(int id, String name, int diamondCost, Picture picture) {
|
||||||
var giftId = new GiftId(giftMessage.getGiftId(), giftMessage.getUser().getIdStr());
|
|
||||||
if (activeGifts.containsKey(giftId)) {
|
|
||||||
var gift = activeGifts.get(giftId);
|
|
||||||
gift.setAmount(giftMessage.getComboCount());
|
|
||||||
} else {
|
|
||||||
var newGift = new TikTokGift(findById((int) giftMessage.getGiftId()), giftMessage);
|
|
||||||
activeGifts.put(giftId, newGift);
|
|
||||||
}
|
|
||||||
|
|
||||||
var gift = activeGifts.get(giftId);
|
|
||||||
|
|
||||||
if (giftMessage.getRepeatEnd() > 0) {
|
|
||||||
gift.setStreakFinished(true);
|
|
||||||
activeGifts.remove(giftId);
|
|
||||||
}
|
|
||||||
return gift;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Gift registerGift(int id, String name, int diamondCost) {
|
|
||||||
try {
|
try {
|
||||||
var constructor = Unsafe.class.getDeclaredConstructors()[0];
|
var constructor = Unsafe.class.getDeclaredConstructors()[0];
|
||||||
constructor.setAccessible(true);
|
constructor.setAccessible(true);
|
||||||
@@ -95,6 +70,10 @@ public class TikTokGiftManager implements GiftManager {
|
|||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(enumInstance, diamondCost);
|
field.set(enumInstance, diamondCost);
|
||||||
|
|
||||||
|
field = Gift.class.getDeclaredField("picture");
|
||||||
|
field.setAccessible(true);
|
||||||
|
field.set(enumInstance, picture);
|
||||||
|
|
||||||
indexById.put(enumInstance.getId(), enumInstance);
|
indexById.put(enumInstance.getId(), enumInstance);
|
||||||
indexByName.put(enumInstance.getName(), enumInstance);
|
indexByName.put(enumInstance.getName(), enumInstance);
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import io.github.jwdeveloper.tiktok.events.messages.TikTokWebsocketMessageEvent;
|
|||||||
import io.github.jwdeveloper.tiktok.events.messages.TikTokUnhandledWebsocketMessageEvent;
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokUnhandledWebsocketMessageEvent;
|
||||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveMessageException;
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveMessageException;
|
||||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokMessageMappingException;
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokMessageMappingException;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastResponse;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -75,11 +75,11 @@ public abstract class TikTokMessageHandler {
|
|||||||
|
|
||||||
|
|
||||||
public void handleSingleMessage(TikTokLiveClient client, WebcastResponse.Message message) throws Exception {
|
public void handleSingleMessage(TikTokLiveClient client, WebcastResponse.Message message) throws Exception {
|
||||||
if (!handlers.containsKey(message.getType())) {
|
if (!handlers.containsKey(message.getMethod())) {
|
||||||
tikTokEventHandler.publish(client, new TikTokUnhandledWebsocketMessageEvent(message));
|
tikTokEventHandler.publish(client, new TikTokUnhandledWebsocketMessageEvent(message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var handler = handlers.get(message.getType());
|
var handler = handlers.get(message.getMethod());
|
||||||
var tiktokEvent = handler.handle(message);
|
var tiktokEvent = handler.handle(message);
|
||||||
tikTokEventHandler.publish(client, new TikTokWebsocketMessageEvent(tiktokEvent, message));
|
tikTokEventHandler.publish(client, new TikTokWebsocketMessageEvent(tiktokEvent, message));
|
||||||
tikTokEventHandler.publish(client, tiktokEvent);
|
tikTokEventHandler.publish(client, tiktokEvent);
|
||||||
@@ -88,7 +88,7 @@ public abstract class TikTokMessageHandler {
|
|||||||
protected TikTokEvent mapMessageToEvent(Class<?> inputClazz, Class<?> outputClass, WebcastResponse.Message message) {
|
protected TikTokEvent mapMessageToEvent(Class<?> inputClazz, Class<?> outputClass, WebcastResponse.Message message) {
|
||||||
try {
|
try {
|
||||||
var parseMethod = inputClazz.getDeclaredMethod("parseFrom", ByteString.class);
|
var parseMethod = inputClazz.getDeclaredMethod("parseFrom", ByteString.class);
|
||||||
var deserialized = parseMethod.invoke(null, message.getBinary());
|
var deserialized = parseMethod.invoke(null, message.getPayload());
|
||||||
|
|
||||||
var constructors = Arrays.stream(outputClass.getConstructors())
|
var constructors = Arrays.stream(outputClass.getConstructors())
|
||||||
.filter(ea -> Arrays.stream(ea.getParameterTypes())
|
.filter(ea -> Arrays.stream(ea.getParameterTypes())
|
||||||
|
|||||||
@@ -25,9 +25,16 @@ package io.github.jwdeveloper.tiktok.handlers;
|
|||||||
import io.github.jwdeveloper.tiktok.TikTokRoomInfo;
|
import io.github.jwdeveloper.tiktok.TikTokRoomInfo;
|
||||||
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
import io.github.jwdeveloper.tiktok.events.TikTokEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.messages.*;
|
import io.github.jwdeveloper.tiktok.events.messages.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokBarrageEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.poll.TikTokPollEndEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.poll.TikTokPollEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.poll.TikTokPollStartEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.poll.TikTokPollUpdateEvent;
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.Gift;
|
import io.github.jwdeveloper.tiktok.events.objects.Gift;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.objects.Text;
|
||||||
import io.github.jwdeveloper.tiktok.gifts.TikTokGiftManager;
|
import io.github.jwdeveloper.tiktok.gifts.TikTokGiftManager;
|
||||||
import io.github.jwdeveloper.tiktok.messages.*;
|
import io.github.jwdeveloper.tiktok.messages.webcast.*;
|
||||||
import io.github.jwdeveloper.tiktok.models.SocialTypes;
|
import io.github.jwdeveloper.tiktok.models.SocialTypes;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
|
||||||
@@ -36,7 +43,6 @@ import java.util.regex.Pattern;
|
|||||||
public class TikTokMessageHandlerRegistration extends TikTokMessageHandler {
|
public class TikTokMessageHandlerRegistration extends TikTokMessageHandler {
|
||||||
private final TikTokGiftManager giftManager;
|
private final TikTokGiftManager giftManager;
|
||||||
private final TikTokRoomInfo roomInfo;
|
private final TikTokRoomInfo roomInfo;
|
||||||
|
|
||||||
private final Pattern socialMediaPattern = Pattern.compile("pm_mt_guidance_viewer_([0-9]+)_share");
|
private final Pattern socialMediaPattern = Pattern.compile("pm_mt_guidance_viewer_([0-9]+)_share");
|
||||||
|
|
||||||
public TikTokMessageHandlerRegistration(TikTokEventObserver tikTokEventHandler,
|
public TikTokMessageHandlerRegistration(TikTokEventObserver tikTokEventHandler,
|
||||||
@@ -52,32 +58,30 @@ public class TikTokMessageHandlerRegistration extends TikTokMessageHandler {
|
|||||||
|
|
||||||
//ConnectionEvents events
|
//ConnectionEvents events
|
||||||
registerMapping(WebcastControlMessage.class, this::handleWebcastControlMessage);
|
registerMapping(WebcastControlMessage.class, this::handleWebcastControlMessage);
|
||||||
registerMapping(SystemMessage.class, TikTokRoomEvent.class);
|
registerMapping(WebcastSystemMessage.class, TikTokRoomEvent.class);
|
||||||
|
|
||||||
|
|
||||||
//Room status events
|
//Room status events
|
||||||
registerMapping(WebcastLiveIntroMessage.class, TikTokRoomEvent.class);
|
registerMapping(WebcastLiveIntroMessage.class, TikTokRoomEvent.class);
|
||||||
registerMapping(WebcastRoomUserSeqMessage.class, this::handleRoomUserSeqMessage);
|
registerMapping(WebcastRoomUserSeqMessage.class, this::handleRoomUserSeqMessage);
|
||||||
registerMapping(RoomMessage.class, TikTokRoomEvent.class);
|
|
||||||
registerMapping(WebcastRoomMessage.class, TikTokRoomEvent.class);
|
registerMapping(WebcastRoomMessage.class, TikTokRoomEvent.class);
|
||||||
registerMapping(WebcastCaptionMessage.class, TikTokCaptionEvent.class);
|
registerMapping(WebcastCaptionMessage.class, TikTokCaptionEvent.class);
|
||||||
|
|
||||||
//User Interactions events
|
//User Interactions events
|
||||||
registerMapping(WebcastChatMessage.class, TikTokCommentEvent.class);
|
registerMapping(WebcastChatMessage.class, TikTokCommentEvent.class);
|
||||||
registerMapping(WebcastLikeMessage.class, TikTokLikeEvent.class);
|
registerMapping(WebcastLikeMessage.class, this::handleLike);
|
||||||
registerMapping(WebcastGiftMessage.class, this::handleGift);
|
registerMapping(WebcastGiftMessage.class, this::handleGift);
|
||||||
registerMapping(WebcastSocialMessage.class, this::handleSocialMedia);
|
registerMapping(WebcastSocialMessage.class, this::handleSocialMedia);
|
||||||
registerMapping(WebcastMemberMessage.class, this::handleMemberMessage);
|
registerMapping(WebcastMemberMessage.class, this::handleMemberMessage);
|
||||||
|
|
||||||
//Host Interaction events
|
//Host Interaction events
|
||||||
registerMapping(WebcastPollMessage.class, TikTokPollEvent.class);
|
registerMapping(WebcastPollMessage.class, this::handlePollEvent);
|
||||||
registerMapping(WebcastRoomPinMessage.class, TikTokRoomPinEvent.class);
|
registerMapping(WebcastRoomPinMessage.class, this::handlePinMessage);
|
||||||
registerMapping(WebcastGoalUpdateMessage.class, TikTokGoalUpdateEvent.class);
|
registerMapping(WebcastGoalUpdateMessage.class, TikTokGoalUpdateEvent.class);
|
||||||
|
|
||||||
//LinkMic events
|
//LinkMic events
|
||||||
registerMapping(WebcastLinkMicBattle.class, TikTokLinkMicBattleEvent.class);
|
registerMapping(WebcastLinkMicBattle.class, TikTokLinkMicBattleEvent.class);
|
||||||
registerMapping(WebcastLinkMicArmies.class, TikTokLinkMicArmiesEvent.class);
|
registerMapping(WebcastLinkMicArmies.class, TikTokLinkMicArmiesEvent.class);
|
||||||
registerMapping(LinkMicMethod.class, TikTokLinkMicMethodEvent.class);
|
|
||||||
registerMapping(WebcastLinkMicMethod.class, TikTokLinkMicMethodEvent.class);
|
registerMapping(WebcastLinkMicMethod.class, TikTokLinkMicMethodEvent.class);
|
||||||
registerMapping(WebcastLinkMicFanTicketMethod.class, TikTokLinkMicFanTicketEvent.class);
|
registerMapping(WebcastLinkMicFanTicketMethod.class, TikTokLinkMicFanTicketEvent.class);
|
||||||
|
|
||||||
@@ -102,7 +106,7 @@ public class TikTokMessageHandlerRegistration extends TikTokMessageHandler {
|
|||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
private TikTokEvent handleWebcastControlMessage(WebcastResponse.Message msg) {
|
private TikTokEvent handleWebcastControlMessage(WebcastResponse.Message msg) {
|
||||||
var message = WebcastControlMessage.parseFrom(msg.getBinary());
|
var message = WebcastControlMessage.parseFrom(msg.getPayload());
|
||||||
return switch (message.getAction()) {
|
return switch (message.getAction()) {
|
||||||
case STREAM_PAUSED -> new TikTokLivePausedEvent();
|
case STREAM_PAUSED -> new TikTokLivePausedEvent();
|
||||||
case STREAM_ENDED -> new TikTokLiveEndedEvent();
|
case STREAM_ENDED -> new TikTokLiveEndedEvent();
|
||||||
@@ -112,8 +116,8 @@ public class TikTokMessageHandlerRegistration extends TikTokMessageHandler {
|
|||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
private TikTokEvent handleGift(WebcastResponse.Message msg) {
|
private TikTokEvent handleGift(WebcastResponse.Message msg) {
|
||||||
var giftMessage = WebcastGiftMessage.parseFrom(msg.getBinary());
|
var giftMessage = WebcastGiftMessage.parseFrom(msg.getPayload());
|
||||||
giftManager.updateActiveGift(giftMessage);
|
|
||||||
|
|
||||||
var gift = giftManager.findById((int) giftMessage.getGiftId());
|
var gift = giftManager.findById((int) giftMessage.getGiftId());
|
||||||
if (gift == Gift.UNDEFINED) {
|
if (gift == Gift.UNDEFINED) {
|
||||||
@@ -123,7 +127,8 @@ public class TikTokMessageHandlerRegistration extends TikTokMessageHandler {
|
|||||||
gift = giftManager.registerGift(
|
gift = giftManager.registerGift(
|
||||||
(int) giftMessage.getGift().getId(),
|
(int) giftMessage.getGift().getId(),
|
||||||
giftMessage.getGift().getName(),
|
giftMessage.getGift().getName(),
|
||||||
giftMessage.getGift().getDiamondCount());
|
giftMessage.getGift().getDiamondCount(),
|
||||||
|
Picture.Map(giftMessage.getGift().getImage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (giftMessage.getRepeatEnd() > 0) {
|
if (giftMessage.getRepeatEnd() > 0) {
|
||||||
@@ -135,9 +140,9 @@ public class TikTokMessageHandlerRegistration extends TikTokMessageHandler {
|
|||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
private TikTokEvent handleSocialMedia(WebcastResponse.Message msg) {
|
private TikTokEvent handleSocialMedia(WebcastResponse.Message msg) {
|
||||||
var message = WebcastSocialMessage.parseFrom(msg.getBinary());
|
var message = WebcastSocialMessage.parseFrom(msg.getPayload());
|
||||||
|
|
||||||
var socialType = message.getHeader().getSocialData().getType();
|
var socialType = Text.map(message.getCommon().getDisplayText()).getKey();
|
||||||
var matcher = socialMediaPattern.matcher(socialType);
|
var matcher = socialMediaPattern.matcher(socialType);
|
||||||
|
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
@@ -147,17 +152,17 @@ public class TikTokMessageHandlerRegistration extends TikTokMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return switch (socialType) {
|
return switch (socialType) {
|
||||||
case SocialTypes.LikeType -> new TikTokLikeEvent(message);
|
case SocialTypes.LikeType -> new TikTokLikeEvent(message, roomInfo.getLikesCount());
|
||||||
case SocialTypes.FollowType -> new TikTokFollowEvent(message);
|
case SocialTypes.FollowType -> new TikTokFollowEvent(message);
|
||||||
case SocialTypes.ShareType -> new TikTokShareEvent(message);
|
case SocialTypes.ShareType -> new TikTokShareEvent(message);
|
||||||
case SocialTypes.JoinType -> new TikTokJoinEvent(message);
|
case SocialTypes.JoinType -> new TikTokJoinEvent(message, roomInfo.getViewersCount());
|
||||||
default -> new TikTokUnhandledSocialEvent(message);
|
default -> new TikTokUnhandledSocialEvent(message);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
private TikTokEvent handleMemberMessage(WebcastResponse.Message msg) {
|
private TikTokEvent handleMemberMessage(WebcastResponse.Message msg) {
|
||||||
var message = WebcastMemberMessage.parseFrom(msg.getBinary());
|
var message = WebcastMemberMessage.parseFrom(msg.getPayload());
|
||||||
return switch (message.getAction()) {
|
return switch (message.getAction()) {
|
||||||
case JOINED -> new TikTokJoinEvent(message);
|
case JOINED -> new TikTokJoinEvent(message);
|
||||||
case SUBSCRIBED -> new TikTokSubscribeEvent(message);
|
case SUBSCRIBED -> new TikTokSubscribeEvent(message);
|
||||||
@@ -170,4 +175,32 @@ public class TikTokMessageHandlerRegistration extends TikTokMessageHandler {
|
|||||||
roomInfo.setViewersCount(event.getViewerCount());
|
roomInfo.setViewersCount(event.getViewerCount());
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TikTokEvent handleLike(WebcastResponse.Message msg) {
|
||||||
|
var event = (TikTokLikeEvent) mapMessageToEvent(WebcastLikeMessage.class, TikTokLikeEvent.class, msg);
|
||||||
|
roomInfo.setLikesCount(event.getTotalLikes());
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
private TikTokEvent handlePinMessage(WebcastResponse.Message msg) {
|
||||||
|
var pinMessage = WebcastRoomPinMessage.parseFrom(msg.getPayload());
|
||||||
|
var chatMessage = WebcastChatMessage.parseFrom(pinMessage.getPinnedMessage());
|
||||||
|
var chatEvent = new TikTokCommentEvent(chatMessage);
|
||||||
|
return new TikTokRoomPinEvent(pinMessage, chatEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO check
|
||||||
|
@SneakyThrows
|
||||||
|
private TikTokEvent handlePollEvent(WebcastResponse.Message msg) {
|
||||||
|
var poolMessage = WebcastPollMessage.parseFrom(msg.getPayload());
|
||||||
|
return switch (poolMessage.getMessageType()) {
|
||||||
|
case 0 -> new TikTokPollStartEvent(poolMessage);
|
||||||
|
case 1 -> new TikTokPollEndEvent(poolMessage);
|
||||||
|
case 2 -> new TikTokPollUpdateEvent(poolMessage);
|
||||||
|
default -> new TikTokPollEvent(poolMessage);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,20 +22,16 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.http;
|
package io.github.jwdeveloper.tiktok.http;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import io.github.jwdeveloper.tiktok.ClientSettings;
|
import io.github.jwdeveloper.tiktok.ClientSettings;
|
||||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveException;
|
||||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveOfflineHostException;
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveOfflineHostException;
|
||||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveRequestException;
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveRequestException;
|
||||||
import io.github.jwdeveloper.tiktok.live.LiveRoomMeta;
|
import io.github.jwdeveloper.tiktok.live.LiveRoomMeta;
|
||||||
import io.github.jwdeveloper.tiktok.mappers.LiveRoomMetaMapper;
|
import io.github.jwdeveloper.tiktok.mappers.LiveRoomMetaMapper;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastResponse;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
|
||||||
import io.github.jwdeveloper.tiktok.models.gifts.TikTokGiftInfo;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class TikTokApiService {
|
public class TikTokApiService {
|
||||||
@@ -137,34 +133,10 @@ public class TikTokApiService {
|
|||||||
try {
|
try {
|
||||||
var response = tiktokHttpClient.getDeserializedMessage("im/fetch/", clientSettings.getClientParameters());
|
var response = tiktokHttpClient.getDeserializedMessage("im/fetch/", clientSettings.getClientParameters());
|
||||||
clientSettings.getClientParameters().put("cursor", response.getCursor());
|
clientSettings.getClientParameters().put("cursor", response.getCursor());
|
||||||
clientSettings.getClientParameters().put("internal_ext", response.getAckIds());
|
clientSettings.getClientParameters().put("internal_ext", response.getInternalExt());
|
||||||
return response;
|
return response;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new TikTokLiveRequestException("Failed to fetch client data", e);
|
throw new TikTokLiveRequestException("Failed to fetch client data", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, TikTokGiftInfo> fetchAvailableGifts() {
|
|
||||||
try {
|
|
||||||
var response = tiktokHttpClient.getJObjectFromWebcastAPI("gift/list/", clientSettings.getClientParameters());
|
|
||||||
if (!response.has("data")) {
|
|
||||||
return new HashMap<>();
|
|
||||||
}
|
|
||||||
var dataJson = response.getAsJsonObject("data");
|
|
||||||
if (!dataJson.has("gifts")) {
|
|
||||||
return new HashMap<>();
|
|
||||||
}
|
|
||||||
var giftsJsonList = dataJson.get("gifts").getAsJsonArray();
|
|
||||||
var gifts = new HashMap<Integer, TikTokGiftInfo>();
|
|
||||||
var gson = new Gson();
|
|
||||||
for (var jsonGift : giftsJsonList) {
|
|
||||||
var gift = gson.fromJson(jsonGift, TikTokGiftInfo.class);
|
|
||||||
logger.info("Found Gift " + gift.getName() + " with ID " + gift.getId());
|
|
||||||
gifts.put(gift.getId(), gift);
|
|
||||||
}
|
|
||||||
return gifts;
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new TikTokLiveRequestException("Failed to fetch giftTokens from WebCast, see stacktrace for more info.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import io.github.jwdeveloper.tiktok.Constants;
|
import io.github.jwdeveloper.tiktok.Constants;
|
||||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveRequestException;
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveRequestException;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastResponse;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.http.HttpClient;
|
import java.net.http.HttpClient;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
|
|||||||
import io.github.jwdeveloper.tiktok.handlers.TikTokMessageHandlerRegistration;
|
import io.github.jwdeveloper.tiktok.handlers.TikTokMessageHandlerRegistration;
|
||||||
import io.github.jwdeveloper.tiktok.http.HttpUtils;
|
import io.github.jwdeveloper.tiktok.http.HttpUtils;
|
||||||
import io.github.jwdeveloper.tiktok.http.TikTokCookieJar;
|
import io.github.jwdeveloper.tiktok.http.TikTokCookieJar;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastResponse;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
|
||||||
import org.java_websocket.client.WebSocketClient;
|
import org.java_websocket.client.WebSocketClient;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@@ -67,10 +67,11 @@ public class TikTokWebSocketClient {
|
|||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (webcastResponse.getSocketUrl().isEmpty() ||
|
if (webcastResponse.getPushServer().isEmpty() ||
|
||||||
webcastResponse.getSocketParamsList().isEmpty()) {
|
webcastResponse.getRouteParamsMapMap().isEmpty()) {
|
||||||
throw new TikTokLiveException("Could not find Room");
|
throw new TikTokLiveException("Could not find Room");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var url = getWebSocketUrl(webcastResponse);
|
var url = getWebSocketUrl(webcastResponse);
|
||||||
if (clientSettings.isHandleExistingEvents()) {
|
if (clientSettings.isHandleExistingEvents()) {
|
||||||
@@ -102,16 +103,10 @@ public class TikTokWebSocketClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getWebSocketUrl(WebcastResponse webcastResponse) {
|
private String getWebSocketUrl(WebcastResponse webcastResponse) {
|
||||||
var params = webcastResponse.getSocketParamsList().get(0);
|
|
||||||
var name = params.getName();
|
|
||||||
var value = params.getValue();
|
|
||||||
var headers = Constants.DefaultRequestHeaders();
|
|
||||||
|
|
||||||
|
|
||||||
var clone = new TreeMap<>(clientSettings.getClientParameters());
|
var clone = new TreeMap<>(clientSettings.getClientParameters());
|
||||||
clone.putAll(headers);
|
clone.putAll(Constants.DefaultRequestHeaders());
|
||||||
clone.put(name, value);
|
clone.putAll(webcastResponse.getRouteParamsMapMap());
|
||||||
var url = webcastResponse.getSocketUrl();
|
var url = webcastResponse.getPushServer();
|
||||||
return HttpUtils.parseParametersEncode(url, clone);
|
return HttpUtils.parseParametersEncode(url, clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ import io.github.jwdeveloper.tiktok.events.messages.TikTokErrorEvent;
|
|||||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokProtocolBufferException;
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokProtocolBufferException;
|
||||||
import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
|
import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
|
||||||
import io.github.jwdeveloper.tiktok.handlers.TikTokMessageHandlerRegistration;
|
import io.github.jwdeveloper.tiktok.handlers.TikTokMessageHandlerRegistration;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastResponse;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastPushFrame;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastWebsocketAck;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastWebsocketMessage;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastWebsocketAck;
|
||||||
import org.java_websocket.client.WebSocketClient;
|
import org.java_websocket.client.WebSocketClient;
|
||||||
import org.java_websocket.drafts.Draft_6455;
|
import org.java_websocket.drafts.Draft_6455;
|
||||||
import org.java_websocket.handshake.ServerHandshake;
|
import org.java_websocket.handshake.ServerHandshake;
|
||||||
@@ -105,16 +105,16 @@ public class TikTokWebSocketListener extends WebSocketClient {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var websocketMessage = websocketMessageOptional.get();
|
var websocketMessage = websocketMessageOptional.get();
|
||||||
sendAckId(websocketMessage.getId());
|
sendAckId(websocketMessage.getSeqId());
|
||||||
|
|
||||||
var webResponse = getWebResponseMessage(websocketMessage.getBinary());
|
var webResponse = getWebResponseMessage(websocketMessage.getPayload());
|
||||||
webResponseHandler.handle(tikTokLiveClient, webResponse);
|
webResponseHandler.handle(tikTokLiveClient, webResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<WebcastWebsocketMessage> getWebcastWebsocketMessage(byte[] buffer) {
|
private Optional<WebcastPushFrame> getWebcastWebsocketMessage(byte[] buffer) {
|
||||||
try {
|
try {
|
||||||
var websocketMessage = WebcastWebsocketMessage.parseFrom(buffer);
|
var websocketMessage = WebcastPushFrame.parseFrom(buffer);
|
||||||
if (websocketMessage.getBinary().isEmpty()) {
|
if (websocketMessage.getPayload().isEmpty()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
return Optional.of(websocketMessage);
|
return Optional.of(websocketMessage);
|
||||||
|
|||||||
@@ -22,8 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.common;
|
package io.github.jwdeveloper.tiktok.common;
|
||||||
|
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastWebsocketMessage;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
package io.github.jwdeveloper.tiktok.gifts;
|
package io.github.jwdeveloper.tiktok.gifts;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.events.objects.Gift;
|
import io.github.jwdeveloper.tiktok.events.objects.Gift;
|
||||||
import org.junit.Assert;
|
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
@@ -33,40 +33,37 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
|||||||
|
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
|
||||||
public class TikTokGiftManagerTest
|
public class TikTokGiftManagerTest {
|
||||||
{
|
|
||||||
|
|
||||||
@InjectMocks
|
@InjectMocks
|
||||||
TikTokGiftManager giftManager;
|
TikTokGiftManager giftManager;
|
||||||
|
|
||||||
|
private static final Picture rosePicture = new Picture("https://p19-webcast.tiktokcdn.com/img/maliva/webcast-va/eba3a9bb85c33e017f3648eaf88d7189~tplv-obj.png");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void registerGift()
|
void registerGift() {
|
||||||
{
|
var fakeGift = giftManager.registerGift(123, "Fake gift", 123123, rosePicture);
|
||||||
var fakeGift = giftManager.registerGift(123,"Fake gift",123123);
|
|
||||||
var gifts = giftManager.getGifts();
|
var gifts = giftManager.getGifts();
|
||||||
var optional = gifts.stream().filter(r -> r == fakeGift).findFirst();
|
var optional = gifts.stream().filter(r -> r == fakeGift).findFirst();
|
||||||
Assertions.assertTrue(optional.isPresent());
|
Assertions.assertTrue(optional.isPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void findById()
|
void findById() {
|
||||||
{
|
var target = giftManager.registerGift(123, "FAKE", 123123, rosePicture);
|
||||||
var target = giftManager.registerGift(123,"FAKE",123123);
|
|
||||||
var result = giftManager.findById(target.getId());
|
var result = giftManager.findById(target.getId());
|
||||||
Assertions.assertEquals(target,result);
|
Assertions.assertEquals(target, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void findByName()
|
void findByName() {
|
||||||
{
|
var target = giftManager.registerGift(123, "FAKE", 123123, rosePicture);
|
||||||
var target = giftManager.registerGift(123,"FAKE",123123);
|
var result = giftManager.findByName(target.getName());
|
||||||
var result = giftManager.findByName(target.getName());
|
Assertions.assertEquals(target, result);
|
||||||
Assertions.assertEquals(target,result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void getGifts()
|
void getGifts() {
|
||||||
{
|
|
||||||
Assertions.assertEquals(Gift.values().length, giftManager.getGifts().size());
|
Assertions.assertEquals(Gift.values().length, giftManager.getGifts().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class ConfigurationExample {
|
|||||||
clientSettings.setTimeout(Duration.ofSeconds(2)); // Connection timeout
|
clientSettings.setTimeout(Duration.ofSeconds(2)); // Connection timeout
|
||||||
clientSettings.setLogLevel(Level.ALL); // Log level
|
clientSettings.setLogLevel(Level.ALL); // Log level
|
||||||
clientSettings.setPrintToConsole(true); // Printing all logs to console even if log level is Level.OFF
|
clientSettings.setPrintToConsole(true); // Printing all logs to console even if log level is Level.OFF
|
||||||
clientSettings.setHandleExistingEventsAfterConnection(true); // Invokes all TikTok events that had occurred before connection
|
clientSettings.setHandleExistingEvents(true); // Invokes all TikTok events that had occurred before connection
|
||||||
clientSettings.setRetryOnConnectionFailure(true); // Reconnecting if TikTok user is offline
|
clientSettings.setRetryOnConnectionFailure(true); // Reconnecting if TikTok user is offline
|
||||||
clientSettings.setRetryConnectionTimeout(Duration.ofSeconds(1)); // Timeout before next reconnection
|
clientSettings.setRetryConnectionTimeout(Duration.ofSeconds(1)); // Timeout before next reconnection
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,11 @@
|
|||||||
package io.github.jwdeveloper.tiktok;
|
package io.github.jwdeveloper.tiktok;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.events.messages.*;
|
import io.github.jwdeveloper.tiktok.events.messages.*;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokConnectedEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokDisconnectedEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokGiftEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokJoinEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokLikeEvent;
|
||||||
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||||
import io.github.jwdeveloper.tiktok.util.ConsoleColors;
|
import io.github.jwdeveloper.tiktok.util.ConsoleColors;
|
||||||
|
|
||||||
@@ -35,6 +40,8 @@ public class Main {
|
|||||||
|
|
||||||
public static void main(String[] args) throws IOException
|
public static void main(String[] args) throws IOException
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
LiveClient client = TikTokLive.newClient(TEST_TIKTOK_USER)
|
LiveClient client = TikTokLive.newClient(TEST_TIKTOK_USER)
|
||||||
.configure(clientSettings ->
|
.configure(clientSettings ->
|
||||||
{
|
{
|
||||||
@@ -42,6 +49,10 @@ public class Main {
|
|||||||
clientSettings.setRetryOnConnectionFailure(true);
|
clientSettings.setRetryOnConnectionFailure(true);
|
||||||
clientSettings.setHandleExistingEvents(true);
|
clientSettings.setHandleExistingEvents(true);
|
||||||
})
|
})
|
||||||
|
.onGift((liveClient, event) ->
|
||||||
|
{
|
||||||
|
var i=0;
|
||||||
|
})
|
||||||
.onConnected(Main::onConnected)
|
.onConnected(Main::onConnected)
|
||||||
.onDisconnected(Main::onDisconnected)
|
.onDisconnected(Main::onDisconnected)
|
||||||
.onRoomViewerData(Main::onViewerData)
|
.onRoomViewerData(Main::onViewerData)
|
||||||
@@ -93,7 +104,7 @@ public class Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void onFollow(LiveClient tikTokLive, TikTokFollowEvent e) {
|
private static void onFollow(LiveClient tikTokLive, TikTokFollowEvent e) {
|
||||||
print(e.getNewFollower().getUniqueId(), "followed!");
|
print(e.getUser().getUniqueId(), "followed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void onShare(LiveClient tikTokLive, TikTokShareEvent e) {
|
private static void onShare(LiveClient tikTokLive, TikTokShareEvent e) {
|
||||||
@@ -106,10 +117,10 @@ public class Main {
|
|||||||
|
|
||||||
private static void onLike(LiveClient tikTokLive, TikTokLikeEvent e) {
|
private static void onLike(LiveClient tikTokLive, TikTokLikeEvent e) {
|
||||||
|
|
||||||
print(e.getSender().getUniqueId(), "liked!");
|
print(e.getUser().getUniqueId(), "liked!");
|
||||||
}
|
}
|
||||||
private static void onEmote(LiveClient tikTokLive, TikTokEmoteEvent e) {
|
private static void onEmote(LiveClient tikTokLive, TikTokEmoteEvent e) {
|
||||||
print(e.getUser().getUniqueId(), "sent", e.getEmoteId());
|
print(e.getUser().getUniqueId(), "sent", e.getEmotes().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void print(Object... messages) {
|
private static void print(Object... messages) {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class SimpleExample {
|
|||||||
})
|
})
|
||||||
.onFollow((liveClient, event) ->
|
.onFollow((liveClient, event) ->
|
||||||
{
|
{
|
||||||
print(ConsoleColors.BLUE, "Follow -> ", ConsoleColors.WHITE_BRIGHT, event.getNewFollower().getNickName());
|
print(ConsoleColors.BLUE, "Follow -> ", ConsoleColors.WHITE_BRIGHT, event.getUser().getNickName());
|
||||||
})
|
})
|
||||||
.onJoin((client, event) ->
|
.onJoin((client, event) ->
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,8 +23,9 @@
|
|||||||
package io.github.jwdeveloper.tiktok.tools.collector;
|
package io.github.jwdeveloper.tiktok.tools.collector;
|
||||||
|
|
||||||
import io.github.jwdeveloper.tiktok.TikTokLive;
|
import io.github.jwdeveloper.tiktok.TikTokLive;
|
||||||
import io.github.jwdeveloper.tiktok.events.messages.TikTokGiftEvent;
|
import io.github.jwdeveloper.tiktok.events.messages.*;
|
||||||
import io.github.jwdeveloper.tiktok.events.messages.TikTokJoinEvent;
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokJoinEvent;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.messages.TikTokLikeEvent;
|
||||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveMessageException;
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveMessageException;
|
||||||
import io.github.jwdeveloper.tiktok.tools.collector.db.TikTokDatabase;
|
import io.github.jwdeveloper.tiktok.tools.collector.db.TikTokDatabase;
|
||||||
import io.github.jwdeveloper.tiktok.tools.collector.tables.ExceptionInfoModel;
|
import io.github.jwdeveloper.tiktok.tools.collector.tables.ExceptionInfoModel;
|
||||||
@@ -40,11 +41,7 @@ public class RunCollector {
|
|||||||
|
|
||||||
//https://protobuf-decoder.netlify.app/
|
//https://protobuf-decoder.netlify.app/
|
||||||
//https://streamdps.com/tiktok-widgets/gifts/
|
//https://streamdps.com/tiktok-widgets/gifts/
|
||||||
/*
|
|
||||||
mia_tattoo
|
|
||||||
moniczkka
|
|
||||||
besin1276
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static List<String> ignoredEvents;
|
public static List<String> ignoredEvents;
|
||||||
|
|
||||||
@@ -55,9 +52,14 @@ public class RunCollector {
|
|||||||
//ignoredEvents = List.of("TikTokJoinEvent","TikTokLikeEvent");
|
//ignoredEvents = List.of("TikTokJoinEvent","TikTokLikeEvent");
|
||||||
|
|
||||||
filter = new ArrayList<>();
|
filter = new ArrayList<>();
|
||||||
filter.add(TikTokGiftEvent.class);
|
filter.add(TikTokUnhandledSocialEvent.class);
|
||||||
|
filter.add(TikTokFollowEvent.class);
|
||||||
|
filter.add(TikTokLikeEvent.class);
|
||||||
|
filter.add(TikTokShareEvent.class);
|
||||||
|
filter.add(TikTokJoinEvent.class);
|
||||||
|
|
||||||
var db = new TikTokDatabase("test");
|
|
||||||
|
var db = new TikTokDatabase("social_db");
|
||||||
db.init();
|
db.init();
|
||||||
|
|
||||||
var errors = db.selectErrors();
|
var errors = db.selectErrors();
|
||||||
@@ -113,7 +115,7 @@ public class RunCollector {
|
|||||||
var errorModel = new TikTokErrorModel();
|
var errorModel = new TikTokErrorModel();
|
||||||
if (exception instanceof TikTokLiveMessageException ex) {
|
if (exception instanceof TikTokLiveMessageException ex) {
|
||||||
errorModel.setHostName(tiktokUser);
|
errorModel.setHostName(tiktokUser);
|
||||||
errorModel.setErrorName(ex.messageName());
|
errorModel.setErrorName(ex.messageMethod());
|
||||||
errorModel.setErrorType("error-message");
|
errorModel.setErrorType("error-message");
|
||||||
errorModel.setExceptionContent(exceptionContent);
|
errorModel.setExceptionContent(exceptionContent);
|
||||||
errorModel.setMessage(ex.messageToBase64());
|
errorModel.setMessage(ex.messageToBase64());
|
||||||
|
|||||||
@@ -20,21 +20,19 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.models.gifts;
|
package io.github.jwdeveloper.tiktok.tools.tester;
|
||||||
|
|
||||||
import lombok.Data;
|
import io.github.jwdeveloper.tiktok.events.objects.Gift;
|
||||||
|
|
||||||
import java.util.List;
|
public class RefelcionTest {
|
||||||
|
public static void main(String[] run) throws NoSuchFieldException, IllegalAccessException {
|
||||||
|
var gift = Gift.PANDA;
|
||||||
|
var url = gift.getPicture();
|
||||||
|
|
||||||
|
var field = gift.getClass().getDeclaredField("picture");
|
||||||
|
field.setAccessible(true);
|
||||||
|
field.set(gift, null);
|
||||||
|
|
||||||
@Data
|
var url2 = gift.getPicture();
|
||||||
public class Icon {
|
}
|
||||||
private String avg_color;
|
|
||||||
private int height;
|
|
||||||
private int image_type;
|
|
||||||
private boolean is_animated;
|
|
||||||
private String open_web_url;
|
|
||||||
private String uri;
|
|
||||||
private List<String> url_list;
|
|
||||||
private int width;
|
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ import io.github.jwdeveloper.tiktok.events.messages.TikTokGiftEvent;
|
|||||||
import io.github.jwdeveloper.tiktok.gifts.TikTokGiftManager;
|
import io.github.jwdeveloper.tiktok.gifts.TikTokGiftManager;
|
||||||
import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
|
import io.github.jwdeveloper.tiktok.handlers.TikTokEventObserver;
|
||||||
import io.github.jwdeveloper.tiktok.handlers.TikTokMessageHandlerRegistration;
|
import io.github.jwdeveloper.tiktok.handlers.TikTokMessageHandlerRegistration;
|
||||||
import io.github.jwdeveloper.tiktok.messages.WebcastResponse;
|
import io.github.jwdeveloper.tiktok.messages.webcast.WebcastResponse;
|
||||||
import io.github.jwdeveloper.tiktok.tools.collector.db.TikTokDatabase;
|
import io.github.jwdeveloper.tiktok.tools.collector.db.TikTokDatabase;
|
||||||
|
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
@@ -75,7 +75,6 @@ public class RunTester {
|
|||||||
sb.append(" combo: " + event.getComboCount());
|
sb.append(" combo: " + event.getComboCount());
|
||||||
sb.append(" index " + event.getComboIndex());
|
sb.append(" index " + event.getComboIndex());
|
||||||
sb.append(" sender " + event.getSender().getNickName());
|
sb.append(" sender " + event.getSender().getNickName());
|
||||||
sb.append(" finished " + event.getComboFinished());
|
|
||||||
System.out.println(sb.toString());
|
System.out.println(sb.toString());
|
||||||
});
|
});
|
||||||
observer.<TikTokGiftComboFinishedEvent>subscribe(TikTokGiftComboFinishedEvent.class, (liveClient, event) ->
|
observer.<TikTokGiftComboFinishedEvent>subscribe(TikTokGiftComboFinishedEvent.class, (liveClient, event) ->
|
||||||
|
|||||||
@@ -78,20 +78,5 @@ public class EventsListGenerator
|
|||||||
}
|
}
|
||||||
return EventType.Custom; // Default value if annotation not present
|
return EventType.Custom; // Default value if annotation not present
|
||||||
}
|
}
|
||||||
private class EventTypeComparator implements Comparator<Class<?>> {
|
|
||||||
@Override
|
|
||||||
public int compare(Class<?> class1, Class<?> class2) {
|
|
||||||
EventType eventType1 = getEventType(class1);
|
|
||||||
EventType eventType2 = getEventType(class2);
|
|
||||||
return eventType1.compareTo(eventType2);
|
|
||||||
}
|
|
||||||
|
|
||||||
private EventType getEventType(Class<?> clazz) {
|
|
||||||
EventMeta annotation = clazz.getAnnotation(EventMeta.class);
|
|
||||||
if (annotation != null) {
|
|
||||||
return annotation.eventType();
|
|
||||||
}
|
|
||||||
return EventType.Custom;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
public class FullEventsExampleClass
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
TikTokLive.newClient("username")
|
||||||
|
.onConnected((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.onDisconnected((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.onError((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.onGift((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.onLike((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.onJoin((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.onFollow((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.onShare((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.onRoomViewerData((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.onComment((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.onEnvelope((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.onLiveEnded((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
})
|
||||||
|
.onLivePaused((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
}).onEmote((liveClient, event) ->
|
||||||
|
{
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,10 +30,15 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public class ReadmeGenerator
|
public class ReadmeGenerator
|
||||||
{
|
{
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
var generator = new ReadmeGenerator();
|
||||||
|
generator.generate();
|
||||||
|
|
||||||
|
}
|
||||||
public void generate()
|
public void generate()
|
||||||
{
|
{
|
||||||
var template = FilesUtility.getFileFromResource(Main.class,"template.md");
|
var template = FilesUtility.getFileFromResource(ReadmeGenerator.class,"template.md");
|
||||||
var variables = new HashMap<String,Object>();
|
var variables = new HashMap<String,Object>();
|
||||||
|
|
||||||
variables.put("version", getCurrentVersion());
|
variables.put("version", getCurrentVersion());
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ package io.github.jwdeveloper.tiktok.gifts;
|
|||||||
import com.squareup.javapoet.JavaFile;
|
import com.squareup.javapoet.JavaFile;
|
||||||
import com.squareup.javapoet.MethodSpec;
|
import com.squareup.javapoet.MethodSpec;
|
||||||
import com.squareup.javapoet.TypeSpec;
|
import com.squareup.javapoet.TypeSpec;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||||
import io.github.jwdeveloper.tiktok.gifts.downloader.GiftDto;
|
import io.github.jwdeveloper.tiktok.gifts.downloader.GiftDto;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@@ -44,17 +45,6 @@ public class GenerateGiftsEnum {
|
|||||||
var downloader = new GiftsDownloader();
|
var downloader = new GiftsDownloader();
|
||||||
var gifts = downloader.getGiftsFromFile();
|
var gifts = downloader.getGiftsFromFile();
|
||||||
var groupedByName = gifts.stream().collect(Collectors.groupingBy(GiftDto::getName));
|
var groupedByName = gifts.stream().collect(Collectors.groupingBy(GiftDto::getName));
|
||||||
for (var entry : groupedByName.entrySet()) {
|
|
||||||
if (entry.getValue().size() > 1) {
|
|
||||||
System.out.println("LOOK AT THIS SHIT: " + entry.getKey());
|
|
||||||
for (var v : entry.getValue()) {
|
|
||||||
System.out.println(v.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("-------------------------");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("Total gifts" + gifts.size());
|
System.out.println("Total gifts" + gifts.size());
|
||||||
var result = generate(groupedByName);
|
var result = generate(groupedByName);
|
||||||
result.writeTo(new File("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\API\\src\\main\\java"));
|
result.writeTo(new File("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\API\\src\\main\\java"));
|
||||||
@@ -68,17 +58,19 @@ public class GenerateGiftsEnum {
|
|||||||
.addAnnotation(Getter.class)
|
.addAnnotation(Getter.class)
|
||||||
.addField(int.class, "id", Modifier.PRIVATE, Modifier.FINAL)
|
.addField(int.class, "id", Modifier.PRIVATE, Modifier.FINAL)
|
||||||
.addField(String.class, "name", Modifier.PRIVATE, Modifier.FINAL)
|
.addField(String.class, "name", Modifier.PRIVATE, Modifier.FINAL)
|
||||||
.addField(int.class, "diamondCost", Modifier.PRIVATE, Modifier.FINAL);
|
.addField(int.class, "diamondCost", Modifier.PRIVATE, Modifier.FINAL)
|
||||||
|
.addField(Picture.class, "picture", Modifier.PRIVATE, Modifier.FINAL);
|
||||||
|
|
||||||
var constructor = MethodSpec.constructorBuilder()
|
var constructor = MethodSpec.constructorBuilder()
|
||||||
.addModifiers(Modifier.PRIVATE)
|
.addModifiers(Modifier.PRIVATE)
|
||||||
.addParameter(int.class, "id")
|
.addParameter(int.class, "id")
|
||||||
.addParameter(String.class, "name")
|
.addParameter(String.class, "name")
|
||||||
.addParameter(int.class, "diamondCost")
|
.addParameter(int.class, "diamondCost")
|
||||||
|
.addParameter(Picture.class, "picture")
|
||||||
.addStatement("this.id = id")
|
.addStatement("this.id = id")
|
||||||
.addStatement("this.name = name")
|
.addStatement("this.name = name")
|
||||||
.addStatement("this.diamondCost = diamondCost")
|
.addStatement("this.diamondCost = diamondCost")
|
||||||
|
.addStatement("this.picture = picture")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
var inRangeMethod = MethodSpec.methodBuilder("hasDiamondCostRange")
|
var inRangeMethod = MethodSpec.methodBuilder("hasDiamondCostRange")
|
||||||
@@ -99,7 +91,7 @@ public class GenerateGiftsEnum {
|
|||||||
enumBuilder.addMethod(constructor);
|
enumBuilder.addMethod(constructor);
|
||||||
|
|
||||||
|
|
||||||
enumBuilder.addEnumConstant("UNDEFINED", addGift(-1, "undefined", -1));
|
enumBuilder.addEnumConstant("UNDEFINED", addGift(-1, "undefined", -1, new Picture("")));
|
||||||
for (var giftInfo : giftInfoMap.entrySet()) {
|
for (var giftInfo : giftInfoMap.entrySet()) {
|
||||||
|
|
||||||
|
|
||||||
@@ -125,7 +117,7 @@ public class GenerateGiftsEnum {
|
|||||||
if (contier > 1) {
|
if (contier > 1) {
|
||||||
enumName += "_" + value.getId();
|
enumName += "_" + value.getId();
|
||||||
}
|
}
|
||||||
enumBuilder.addEnumConstant(enumName, addGift(value.getId(), value.getName(), value.getDiamondCost()));
|
enumBuilder.addEnumConstant(enumName, addGift(value.getId(), value.getName(), value.getDiamondCost(), new Picture(value.getImage())));
|
||||||
contier++;
|
contier++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,18 +141,21 @@ public class GenerateGiftsEnum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void onEnums(TypeSpec.Builder builder) {
|
public static void onEnums(TypeSpec.Builder builder) {
|
||||||
builder.addEnumConstant("RUGBY_BALL", addGift(6249, "Rugby Ball", 10));
|
// builder.addEnumConstant("RUGBY_BALL", addGift(6249, "Rugby Ball", 10));
|
||||||
builder.addEnumConstant("I_LOVE_YOU", addGift(5779, "I Love you", 10));
|
// builder.addEnumConstant("I_LOVE_YOU", addGift(5779, "I Love you", 10));
|
||||||
builder.addEnumConstant("BOUQUET_FLOWER", addGift(5780, "Bouquet Flower", 30));
|
// builder.addEnumConstant("BOUQUET_FLOWER", addGift(5780, "Bouquet Flower", 30));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static TypeSpec addGift(int id, String name, int diamont) {
|
public static TypeSpec addGift(int id, String name, int diamont, Picture picture)
|
||||||
|
{
|
||||||
|
var pictureValue = "new Picture(\""+picture.getLink()+"\")";
|
||||||
return TypeSpec.anonymousClassBuilder(
|
return TypeSpec.anonymousClassBuilder(
|
||||||
"$L, $S, $L",
|
"$L, $S, $L, $S",
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
diamont)
|
diamont,
|
||||||
|
pictureValue)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,16 +22,18 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.gifts;
|
package io.github.jwdeveloper.tiktok.gifts;
|
||||||
|
|
||||||
|
import com.google.gson.ExclusionStrategy;
|
||||||
|
import com.google.gson.FieldAttributes;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||||
import io.github.jwdeveloper.tiktok.gifts.downloader.GiftDto;
|
import io.github.jwdeveloper.tiktok.gifts.downloader.GiftDto;
|
||||||
import io.github.jwdeveloper.tiktok.gifts.downloader.GiftOfficialJson;
|
import io.github.jwdeveloper.tiktok.gifts.downloader.GiftOfficialJson;
|
||||||
import io.github.jwdeveloper.tiktok.gifts.downloader.GiftScraperJson;
|
import io.github.jwdeveloper.tiktok.gifts.downloader.GiftScraperJson;
|
||||||
import io.github.jwdeveloper.tiktok.utils.FilesUtility;
|
import io.github.jwdeveloper.tiktok.utils.FilesUtility;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
@@ -65,15 +67,14 @@ public class GiftsDownloader {
|
|||||||
|
|
||||||
|
|
||||||
var outputHashMap = new TreeMap<Integer, GiftDto>();
|
var outputHashMap = new TreeMap<Integer, GiftDto>();
|
||||||
for (var gift : scraperGifts)
|
for (var gift : scraperGifts) {
|
||||||
{
|
|
||||||
outputHashMap.put(gift.getId(), gift);
|
outputHashMap.put(gift.getId(), gift);
|
||||||
}
|
}
|
||||||
for (var gift : officialGifts)
|
for (var gift : officialGifts) {
|
||||||
{
|
|
||||||
outputHashMap.put(gift.getId(), gift);
|
outputHashMap.put(gift.getId(), gift);
|
||||||
}
|
}
|
||||||
var gson = new GsonBuilder().setPrettyPrinting().create();
|
var gson = new GsonBuilder().setPrettyPrinting()
|
||||||
|
.create();
|
||||||
var json = gson.toJson(outputHashMap);
|
var json = gson.toJson(outputHashMap);
|
||||||
FilesUtility.saveFile("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\Tools\\src\\main\\resources\\gifts\\output.json", json);
|
FilesUtility.saveFile("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\Tools\\src\\main\\resources\\gifts\\output.json", json);
|
||||||
System.out.println("Gifts saved to file!");
|
System.out.println("Gifts saved to file!");
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.gifts.downloader;
|
package io.github.jwdeveloper.tiktok.gifts.downloader;
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||||
|
import io.github.jwdeveloper.tiktok.utils.JsonIgnore;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.google.gson.GsonBuilder;
|
|||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import io.github.jwdeveloper.tiktok.Constants;
|
import io.github.jwdeveloper.tiktok.Constants;
|
||||||
|
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||||
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveRequestException;
|
import io.github.jwdeveloper.tiktok.exceptions.TikTokLiveRequestException;
|
||||||
import io.github.jwdeveloper.tiktok.http.TikTokCookieJar;
|
import io.github.jwdeveloper.tiktok.http.TikTokCookieJar;
|
||||||
import io.github.jwdeveloper.tiktok.http.TikTokHttpClient;
|
import io.github.jwdeveloper.tiktok.http.TikTokHttpClient;
|
||||||
@@ -64,6 +65,10 @@ public class GiftOfficialJson {
|
|||||||
.get("image").getAsJsonObject()
|
.get("image").getAsJsonObject()
|
||||||
.get("url_list").getAsJsonArray().get(0).getAsString();
|
.get("url_list").getAsJsonArray().get(0).getAsString();
|
||||||
|
|
||||||
|
if(image.endsWith(".webp"))
|
||||||
|
{
|
||||||
|
image = image.replace(".webp",".jpg");
|
||||||
|
}
|
||||||
var gift = new GiftDto();
|
var gift = new GiftDto();
|
||||||
gift.setId(id);
|
gift.setId(id);
|
||||||
gift.setName(name);
|
gift.setName(name);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
package io.github.jwdeveloper.tiktok.gifts.downloader;
|
package io.github.jwdeveloper.tiktok.gifts.downloader;
|
||||||
|
|
||||||
|
|
||||||
|
import io.github.jwdeveloper.tiktok.events.objects.Picture;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
|
|
||||||
|
|||||||
@@ -20,16 +20,14 @@
|
|||||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
package io.github.jwdeveloper.tiktok.models.gifts;
|
package io.github.jwdeveloper.tiktok.utils;
|
||||||
|
|
||||||
import lombok.Data;
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
import java.util.List;
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
@Data
|
public @interface JsonIgnore {
|
||||||
public class DisplayText {
|
|
||||||
private DefaultFormat default_format;
|
|
||||||
private String default_pattern;
|
|
||||||
private String key;
|
|
||||||
private List<Object> pieces;
|
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user