mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-28 01:09:40 -05:00
made: settings.fetchGifts default to true,
attach to options `setOffline` create static method `of` for events -TikTokGiftEvent -TikTokCommentEvent -TikTokSubscribeEvent -TikTokFollowEvent -TikTokLikeEvent -TikTokJoinEvent
This commit is contained in:
@@ -1,55 +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;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class ChatMessageExample {
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
var roomData = TikTokLive.requests()
|
||||
.fetchLiveData("X");
|
||||
|
||||
var gifts = TikTokLive.requests().fetchGiftsData();
|
||||
|
||||
|
||||
var user = TikTokLive.requests()
|
||||
.fetchLiveUserData("mark");
|
||||
|
||||
TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME)
|
||||
.configure(clientSettings ->
|
||||
{
|
||||
clientSettings.setPrintToConsole(true);
|
||||
clientSettings.getHttpSettings().setTimeout(Duration.ofSeconds(21));
|
||||
})
|
||||
.onComment((liveClient, event) ->
|
||||
{
|
||||
System.out.println("Chat message: " + event.getUser().getName() + " " + event.getText());
|
||||
})
|
||||
.onWebsocketUnhandledMessage((liveClient, event) ->
|
||||
{
|
||||
liveClient.getLogger().info(event.getMessage().getMethod());
|
||||
}).buildAndConnect();
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SimpleExample {
|
||||
public class ConnectionExample {
|
||||
public static String TIKTOK_HOSTNAME = "kvadromama_marina1";
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
@@ -40,10 +40,10 @@ public class SimpleExample {
|
||||
|
||||
var gifts = TikTokLive.gifts();
|
||||
|
||||
TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME)
|
||||
TikTokLive.newClient(ConnectionExample.TIKTOK_HOSTNAME)
|
||||
.configure(clientSettings ->
|
||||
{
|
||||
clientSettings.setHostName(SimpleExample.TIKTOK_HOSTNAME); // This method is useful in case you want change hostname later
|
||||
clientSettings.setHostName(ConnectionExample.TIKTOK_HOSTNAME); // This method is useful in case you want change hostname later
|
||||
clientSettings.setClientLanguage("en"); // Language
|
||||
clientSettings.setLogLevel(Level.ALL); // Log level
|
||||
clientSettings.setPrintToConsole(true); // Printing all logs to console even if log level is Level.OFF
|
||||
@@ -39,7 +39,7 @@ public class CustomEventExample {
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME)
|
||||
TikTokLive.newClient(ConnectionExample.TIKTOK_HOSTNAME)
|
||||
.configure(clientSettings ->
|
||||
{
|
||||
clientSettings.setPrintToConsole(true);
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package io.github.jwdeveloper.tiktok;
|
||||
|
||||
import io.github.jwdeveloper.tiktok.data.events.TikTokCommentEvent;
|
||||
import io.github.jwdeveloper.tiktok.data.events.TikTokSubNotifyEvent;
|
||||
import io.github.jwdeveloper.tiktok.data.events.TikTokSubscribeEvent;
|
||||
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftEvent;
|
||||
import io.github.jwdeveloper.tiktok.data.events.social.TikTokFollowEvent;
|
||||
import io.github.jwdeveloper.tiktok.data.events.social.TikTokJoinEvent;
|
||||
import io.github.jwdeveloper.tiktok.data.events.social.TikTokLikeEvent;
|
||||
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||
|
||||
public class Events_And_Gifts_Testing_Example {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
LiveClient client = TikTokLive.newClient(ConnectionExample.TIKTOK_HOSTNAME)
|
||||
.configure(liveClientSettings ->
|
||||
{
|
||||
liveClientSettings.setOffline(true);
|
||||
liveClientSettings.setPrintToConsole(true);
|
||||
})
|
||||
.onConnected((liveClient, event) ->
|
||||
{
|
||||
liveClient.getLogger().info("Connected");
|
||||
})
|
||||
.onDisconnected((liveClient, event) ->
|
||||
{
|
||||
liveClient.getLogger().info("Disconnected");
|
||||
})
|
||||
.onGiftCombo((liveClient, event) ->
|
||||
{
|
||||
liveClient.getLogger().info("Connected");
|
||||
})
|
||||
.onGift((liveClient, event) ->
|
||||
{
|
||||
liveClient.getLogger().info("New fakeGift: " + event.getGift());
|
||||
})
|
||||
.buildAndConnect();
|
||||
|
||||
var gifts = TikTokLive.gifts();
|
||||
var fakeGift = TikTokGiftEvent.of(gifts.getByName("Rose"));
|
||||
fakeGift = TikTokGiftEvent.of("Rose", 1, 23);
|
||||
|
||||
var fakeMessage = TikTokCommentEvent.of("Mark", "Hello world");
|
||||
|
||||
var fakeSubscriber = TikTokSubscribeEvent.of("Mark");
|
||||
var fakeFollow = TikTokFollowEvent.of("Mark");
|
||||
var fakeLike = TikTokLikeEvent.of("Mark", 12);
|
||||
var fakeJoin = TikTokJoinEvent.of("Mark");
|
||||
|
||||
|
||||
client.publishEvent(fakeGift);
|
||||
client.publishEvent(fakeMessage);
|
||||
client.publishEvent(fakeSubscriber);
|
||||
client.publishEvent(fakeFollow);
|
||||
client.publishEvent(fakeLike);
|
||||
client.publishEvent(fakeJoin);
|
||||
|
||||
client.disconnect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void GetBuilder() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package io.github.jwdeveloper.tiktok;
|
||||
|
||||
import io.github.jwdeveloper.tiktok.data.events.gift.TikTokGiftEvent;
|
||||
import io.github.jwdeveloper.tiktok.live.LiveClient;
|
||||
|
||||
public class GiftTestingExample {
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
LiveClient client = TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME)
|
||||
.configure(liveClientSettings ->
|
||||
{
|
||||
// liveClientSettings.setOffline(true);
|
||||
})
|
||||
.onConnected((liveClient, event) ->
|
||||
{
|
||||
liveClient.getLogger().info("Connected");
|
||||
})
|
||||
.onGiftCombo((liveClient, event) ->
|
||||
{
|
||||
|
||||
})
|
||||
.onGift((liveClient, event) ->
|
||||
{
|
||||
liveClient.getLogger().info("New fakeGift: " + event.getGift());
|
||||
})
|
||||
.buildAndConnect();
|
||||
|
||||
var gifts = TikTokLive.gifts();
|
||||
var fakeGift = TikTokGiftEvent.of(gifts.getByName("Rose"));
|
||||
var fakeGift2 = TikTokGiftEvent.of("Rose", 1, 23);
|
||||
client.publishEvent(fakeGift);
|
||||
client.publishEvent(fakeGift2);
|
||||
}
|
||||
|
||||
|
||||
public void GetTesterBuilder() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void GetBuilder() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class ListenerExample
|
||||
showLogo();
|
||||
CustomListener customListener = new CustomListener();
|
||||
|
||||
TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME)
|
||||
TikTokLive.newClient(ConnectionExample.TIKTOK_HOSTNAME)
|
||||
.addListener(customListener)
|
||||
.buildAndConnect();
|
||||
System.in.read();
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.net.Proxy;
|
||||
|
||||
public class ProxyExample {
|
||||
public static void main(String[] args) throws Exception {
|
||||
TikTokLive.newClient(SimpleExample.TIKTOK_HOSTNAME)
|
||||
TikTokLive.newClient(ConnectionExample.TIKTOK_HOSTNAME)
|
||||
.configure(clientSettings -> {
|
||||
clientSettings.setPrintToConsole(true);
|
||||
clientSettings.getHttpSettings().configureProxy(proxySettings -> {
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package io.github.jwdeveloper.tiktok;
|
||||
|
||||
public class TestingGiftsExample {
|
||||
}
|
||||
Reference in New Issue
Block a user