mirror of
https://github.com/jwdeveloper/TikTokLiveJava.git
synced 2026-02-27 16:59:39 -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:
@@ -22,54 +22,56 @@
|
||||
*/
|
||||
package io.github.jwdeveloper.tiktok;
|
||||
|
||||
import io.github.jwdeveloper.tiktok.data.models.gifts.Gift;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CodeExample
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
public class CodeExample {
|
||||
public static void main(String[] args) {
|
||||
TikTokLive.newClient("mrBeast")
|
||||
.onGift((liveClient, event) ->
|
||||
{
|
||||
System.out.println("Thank you for Money!");
|
||||
})
|
||||
.buildAndConnect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void codeExample()
|
||||
{
|
||||
TikTokLive.newClient("bangbetmenygy")
|
||||
.onGift((liveClient, event) ->
|
||||
{
|
||||
if(event.getGift() == Gift.ROSE)
|
||||
{
|
||||
liveClient.getLogger().info("Rose from "+event.getUser().getDisplayName());
|
||||
return;
|
||||
}
|
||||
liveClient.getLogger().info("Thank you for "+event.getGift().getName());
|
||||
})
|
||||
.onJoin((liveClient, event) ->
|
||||
{
|
||||
liveClient.getLogger().info("Hello "+event.getUser().getDisplayName());
|
||||
})
|
||||
.onConnected((liveClient, event) ->
|
||||
{
|
||||
liveClient.getLogger().info("Connected to live ");
|
||||
})
|
||||
.onError((liveClient, event) ->
|
||||
{
|
||||
liveClient.getLogger().info("ERROR! "+event.getException().getMessage());
|
||||
System.out.println("Thank you for Money!");
|
||||
})
|
||||
.buildAndConnect();
|
||||
}
|
||||
|
||||
public static void configExample()
|
||||
{
|
||||
|
||||
public static void codeExample() {
|
||||
// <code>
|
||||
TikTokLive.newClient("bangbetmenygy")
|
||||
.onGift((liveClient, event) ->
|
||||
{
|
||||
String message = switch (event.getGift()) {
|
||||
case ROSE -> "ROSE!";
|
||||
case GG -> "GOOD GAME";
|
||||
case TIKTOK -> "Ye";
|
||||
case CORGI -> "Nice gift";
|
||||
default -> "Thank you for " + event.getGift().getName();
|
||||
};
|
||||
System.out.println(event.getUser().getProfileName() + " sends " + message);
|
||||
})
|
||||
.onGiftCombo((liveClient, event) ->
|
||||
{
|
||||
System.out.println(event.getComboState()+ " " + event.getCombo() + " " + event.getGift().getName());
|
||||
})
|
||||
.onJoin((liveClient, event) ->
|
||||
{
|
||||
System.out.println(event.getUser().getProfileName() + "Hello on my stream! ");
|
||||
})
|
||||
.onConnected((liveClient, event) ->
|
||||
{
|
||||
System.out.println("Connected to live ");
|
||||
})
|
||||
.onError((liveClient, event) ->
|
||||
{
|
||||
System.out.println("Error! " + event.getException().getMessage());
|
||||
})
|
||||
.buildAndConnect();
|
||||
// </code>
|
||||
}
|
||||
|
||||
public static void configExample() {
|
||||
// <code>
|
||||
TikTokLive.newClient("bangbetmenygy")
|
||||
.configure((settings) ->
|
||||
{
|
||||
@@ -92,6 +94,7 @@ public class CodeExample
|
||||
settings.setRoomId("XXXXXXXXXXXXXXXXX");
|
||||
})
|
||||
.buildAndConnect();
|
||||
// </code>
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.github.jwdeveloper.tiktok;
|
||||
|
||||
import io.github.jwdeveloper.tiktok.utils.FilesUtility;
|
||||
import io.github.jwdeveloper.tiktok.utils.TemplateUtility;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class CodeExamplesGenerator {
|
||||
public static void main(String[] args) {
|
||||
var result = new CodeExamplesGenerator().run();
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
public String run() {
|
||||
|
||||
var content = FilesUtility.loadFileContent("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\Tools-ReadmeGenerator\\src\\main\\java\\io\\github\\jwdeveloper\\tiktok\\CodeExample.java");
|
||||
var p = "<code>(.*?)</code>";
|
||||
var r = Pattern.compile(p, Pattern.DOTALL);
|
||||
var m = r.matcher(content);
|
||||
|
||||
|
||||
var pattern = """
|
||||
```java
|
||||
{{code}}
|
||||
```
|
||||
3. Configure (optional)
|
||||
|
||||
```java
|
||||
{{config}}
|
||||
```
|
||||
""";
|
||||
|
||||
|
||||
var values = new HashMap<String, Object>();
|
||||
m.find();
|
||||
var code = m.group(0)
|
||||
.replace("<code>", "")
|
||||
.replace("// </code>", "")
|
||||
.replaceAll("(?m)^ {8}", "");
|
||||
values.put("code", code);
|
||||
|
||||
m.find();
|
||||
values.put("config", m.group(1));
|
||||
var result = TemplateUtility.generateTemplate(pattern, values);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -82,11 +82,15 @@ public class EventsInfoGenerator {
|
||||
variables.put("method-name", dto.getMethodName());
|
||||
variables.put("content", doc);
|
||||
variables.put("event-name", dto.getEventClazz().getSimpleName());
|
||||
|
||||
var baseUrl = "https://github.com/jwdeveloper/TikTokLiveJava/blob/master/API/src/main/java/";
|
||||
baseUrl += dto.getEventClazz().getPackageName().replace(".","/");
|
||||
baseUrl += "/"+dto.getEventClazz().getSimpleName()+".java";
|
||||
variables.put("event-file-url",baseUrl);
|
||||
var temp = """
|
||||
|
||||
|
||||
|
||||
## {{method-name}} [{{event-name}}](https://github.com/jwdeveloper/TikTok-Live-Java/blob/master/API/src/main/java/io/github/jwdeveloper/tiktok/events/messages.java)
|
||||
## {{method-name}} [{{event-name}}]({{event-file-url}})
|
||||
|
||||
{{content}}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 jwdeveloper jacekwoln@gmail.com
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package io.github.jwdeveloper.tiktok;
|
||||
|
||||
import io.github.jwdeveloper.tiktok.utils.FilesUtility;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ListenerExampleGenerator
|
||||
{
|
||||
public static void main(String[] arg)
|
||||
{
|
||||
var result = new ListenerExampleGenerator();
|
||||
System.out.println(result);
|
||||
}
|
||||
|
||||
|
||||
public String run()
|
||||
{
|
||||
var content = FilesUtility.loadFileContent("C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\Examples\\src\\main\\java\\io\\github\\jwdeveloper\\tiktok\\ListenerExample.java");
|
||||
var p = "<code>(.*?)</code>";
|
||||
var r = Pattern.compile(p, Pattern.DOTALL);
|
||||
var m = r.matcher(content);
|
||||
m.find();
|
||||
return m.group(1);
|
||||
}
|
||||
}
|
||||
@@ -26,48 +26,38 @@ import io.github.jwdeveloper.tiktok.utils.FilesUtility;
|
||||
import io.github.jwdeveloper.tiktok.utils.TemplateUtility;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ReadmeGenerator
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
public class ReadmeGenerator {
|
||||
public static void main(String[] args) {
|
||||
var generator = new ReadmeGenerator();
|
||||
generator.generate();
|
||||
|
||||
}
|
||||
public void generate()
|
||||
{
|
||||
var template = FilesUtility.getFileFromResource(ReadmeGenerator.class,"template.md");
|
||||
var variables = new HashMap<String,Object>();
|
||||
|
||||
public void generate() {
|
||||
var template = FilesUtility.getFileFromResource(ReadmeGenerator.class, "template.md");
|
||||
var variables = new HashMap<String, Object>();
|
||||
|
||||
variables.put("version", getCurrentVersion());
|
||||
|
||||
var exampleCodePath = "C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\Examples\\src\\main\\java\\io\\github\\jwdeveloper\\tiktok\\SimpleExample.java";
|
||||
variables.put("code-content", getCodeExample(exampleCodePath));
|
||||
|
||||
variables.put("code-content", new CodeExamplesGenerator().run());
|
||||
variables.put("events-content", new EventsInfoGenerator().run());
|
||||
|
||||
var listenerExamplePath = "C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\Examples\\src\\main\\java\\io\\github\\jwdeveloper\\tiktok\\ListenerExample.java";
|
||||
// variables.put("listener-content", getCodeExample(listenerExamplePath));
|
||||
|
||||
variables.put("listener-content",new ListenerExampleGenerator().run());
|
||||
|
||||
template = TemplateUtility.generateTemplate(template, variables);
|
||||
var outputPath = "C:\\Users\\ja\\IdeaProjects\\TikTokLiveJava\\Tools-ReadmeGenerator\\src\\main\\resources\\output.md";
|
||||
FilesUtility.saveFile(outputPath, template);
|
||||
}
|
||||
|
||||
public String getCurrentVersion()
|
||||
{
|
||||
var version = System.getenv("version");;
|
||||
public String getCurrentVersion() {
|
||||
var version = System.getenv("version");
|
||||
;
|
||||
|
||||
return version == null?"NOT_FOUND":version;
|
||||
return version == null ? "NOT_FOUND" : version;
|
||||
}
|
||||
|
||||
public String getCodeExample(String path)
|
||||
{
|
||||
public String getCodeExample(String path) {
|
||||
var content = FilesUtility.loadFileContent(path);
|
||||
content = content.substring(content.indexOf("*/")+2);
|
||||
content = content.substring(content.indexOf("*/") + 2);
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user